Check Email Address and Type on a PeopleSoft Grid

时间:2022-09-24 08:55:40

What I would like to accomplish is every time the user adds a new email address i would want to check for the following:
1. Check for blank email type
2. Edit to check for '@' character
3. Check if email address is blank
4. Check for duplicate email type in the same grid

And here is the PeopleCode on how to do the above:
Check Email Address and Type on a PeopleSoft Grid

Local Rowset &RSEmail;

&RSEmail = GetLevel0()(1).GetRowset(Scroll.EMAIL_ADDRESSES);

/* error checks */
For &I = 1 To &RSEmail.ActiveRowCount
/* check for blank email type */
If None(&RSEmail(&I).EMAIL_ADDRESSES.E_ADDR_TYPE.Value) Then
SetCursorPos(%Page, EMAIL_ADDRESSES.E_ADDR_TYPE, &I);
Error MsgGetText(Message Set Number, Message Number, "Email Type is required.");
End-If;

If All(&RSEmail(&I).EMAIL_ADDRESSES.EMAIL_ADDR.Value) Then
/* edit to check for '@' character */
&AT = "";
&AT = Find("@", &RSEmail(&I).EMAIL_ADDRESSES.EMAIL_ADDR.Value);
If &AT = "" Then
SetCursorPos(%Page, EMAIL_ADDRESSES.EMAIL_ADDR, &I);
Error MsgGet(Message Set Number, Message Number, "Email address must contain the @ character.");
End-If;
Else
/* error if email address is blank */
SetCursorPos(%Page, EMAIL_ADDRESSES.EMAIL_ADDR, &I);
Error MsgGetText(Message Set Number, Message Number, "Email Address is required.");
End-If;

/* check for duplicate email type */
&type = &RSEmail(&I).EMAIL_ADDRESSES.E_ADDR_TYPE.Value;
&ROWNUM = &RSEmail(&I).RowNumber;

For &j = 1 To &RSEmail.ActiveRowCount
If &type = &RSEmail(&j).EMAIL_ADDRESSES.E_ADDR_TYPE.Value And
&j <> &ROWNUM Then
/*Alert user that selected email address type has already been chosen*/
SetCursorPos(%Page, EMAIL_ADDRESSES.E_ADDR_TYPE, &j);
Error MsgGetText(Message Set Number, Message Number, "Message not found");
End-If;
End-For;
End-For;