Restrict Xlat Values in a Drop Down List

Your rating: None Average: 4.4 (8 votes)

As you can see from the picture below, I have prevented the Xlat value of "BUSN" to appear in the dropdown list although it is an active value on the Email Type Field. See the PeoleCode below to accomplish such a task.

PeopleCode to restrict Xlat Values

/*Ensure that user is not able to add a business email address from self service */
Local Rowset &RSL0 = GetLevel0();
Local Rowset &data = &RSL0(1).GetRowset(Scroll.EMAIL_ADDRESSES);Local Rowset &xlat = CreateRowset(Record.PSXLATITEM);

/*Get Xlat field name */
Local string &xlat_field = "E_ADDR_TYPE";

/*We will not allow "BUSN"*/
Local string &invalid_addr_type = "BUSN";
If %IsMultiLanguageEnabled And
%Language <> %Language_Base Then
&xlat.Fill("WHERE FIELDNAME = :1 AND FIELDVALUE <> :2 AND EFFDT = (SELECT MAX(EFFDT) FROM PSXLATITEMLANG B WHERE B.FIELDNAME =:3 AND EFFDT <= %CURRENTDATEIN) AND LANGUAGE_CD =:4", &xlat_field, &invalid_addr_type, &xlat_field, %Language);
Else
&xlat.Fill("WHERE FIELDNAME = :1 AND FIELDVALUE <> :2 AND EFFDT = (SELECT MAX(EFFDT) FROM PSXLATITEM B WHERE B.FIELDNAME =:3 AND EFFDT <= %CURRENTDATEIN)", &xlat_field, &invalid_addr_type, &xlat_field);
End-If;

For &i = 1 To &data.ActiveRowCount;
If &data(&i).EMAIL_ADDRESSES.E_ADDR_TYPE.Value <> "BUSN" Or
None(&data(&i).EMAIL_ADDRESSES.E_ADDR_TYPE.Value) Then
&data(&i).EMAIL_ADDRESSES.E_ADDR_TYPE.ClearDropDownList();

For &K = 1 To &xlat.ActiveRowCount
&data(&i).EMAIL_ADDRESSES.E_ADDR_TYPE.AddDropDownItem(&xlat(&K).PSXLATITEM.FIELDVALUE.Value, &xlat(&K).PSXLATITEM.XLATLONGNAME.Value);
End-For;
End-If;
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.
Guest's picture
Guest (not verified)
Re: Restrict Xlat Values in a Drop Down List

Very usefull code, the only thing I'd add is:

In "&xlat.Fill ..." you should add FIELDVALUE as criteria, as you might have different effective dates for your xlat values.

Below the code illustrating my comment. This code is put in the searchinit so some users don't see all values:

Local Rowset &xlat = CreateRowset(Record.PSXLATITEM);

&Permission_list = %PermissionLists;
&PL = &Permission_list.Find("PERM_1");
If None(&PL) Then
&PL = &Permission_list.Find("PERM_2");
End-If;

If None(&PL) Then

&FLD = GetField(Field.FIELD_A);
&FLD.ClearDropDownList();
&fld_name = "FIELD_A";
&fld_v1 = "A";
&fld_v2 = "B";
&fld_v3 = "C";

&xlat.Fill("WHERE FILL.FIELDNAME = :1 AND FILL.FIELDVALUE not in (:2,:3,:4) AND FILL.EFFDT = (SELECT MAX(B.EFFDT) FROM PSXLATITEM B WHERE B.FIELDNAME =:1 AND B.FIELDVALUE = FILL.FIELDVALUE and B.EFFDT <= %CURRENTDATEIN)", &fld_name, &fld_v1, &fld_v2, &fld_v3);

For &i = 1 To &xlat.ActiveRowCount
&FLD.AddDropDownItem(&xlat(&i).PSXLATITEM.FIELDVALUE.Value, &xlat(&i).PSXLATITEM.XLATLONGNAME.Value);
End-For;
End-If;

Guest's picture
Guest
Dododave

Since a few pieces of machinery for our new control system weren’t available locally, we were forced to get them ordered from outside. We were in a bit of a rush too, so we decided to go with mforwarding.com. From then on, we haven’t looked back and use them extensively for any and all of our parcel needs. – Raymond

Guest's picture
Guest
How did I ended up here?

Howdy I am called Ana, greetings from Geneve, I made such a different topic to get your attention.............

Such extraordinary writting like yours has to be valued so no need for thanks....

I write pages in several pages and that is what I´m making at this time, lol!:) and it was part of the reason I visited on this page...to seek for ideas to my website

II am very found of reading as well as fishing, and I also enjoy a lot Radiohead, my greatest hobbie at the time is poker, like many of you...I imagine....as well as board games.

I forgot to tell, I was born In Panama there it comes my critical behaviour...lol

I always like to finish my topics with something like this, as the the poet once said "We shouldn’t let a sour hour lower our power"

Just a little waring you should put anothers social network pluggins on your website, like facebook, this has been a perfect tool to get away from google panda 1.6, thas has been driving webmasters crazy, they are every time telling to write quality conten , by the way what is quality to Google staff ???

Good afternoon to everybody, Bye