Check Email Address and Type on a PeopleSoft Grid

Your rating: None Average: 5 (1 vote)

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!

Comments

Have a question? Please ask it on the forum instead.

Post new comment

The content of this field is kept private and will not be shown publicly.
CAPTCHA
The question below is to prevent automated spam submissions.
3 + 14 =
Solve this simple math problem and enter the result. E.g. for 1+3, enter 4.