Check Email Address and Type on a PeopleSoft Grid

Your rating: None Average: 5 (2 votes)

The grid looks like this:

PeopleCode to restrict Xlat Values

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:
More...

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;

Please try to help out with unanswered topics on the forum. Chances are you have had the same issue/question some time in your IT career!