AddDropDownItem PeopleCode

2.2k views Asked by At

I got this PeopleCode somewhere that says it can dynamically add items in the drop down list:

Component number &rownum;

Local SQL &SQL;
Local Rowset &rset0, &rset1;
Local String &type, &descr;

&rset0 = GetLevel0();
&rset1 = &rset0(1).GetRowset(Scroll.LEVEL1_REC);

&FLD = &rset1(&rownum).GetRecord(Record.LEVEL1_REC).GetField(Field.LEVEL1_REC_FIELD);
&FLD.ClearDropDownList();

&SQL = CreateSQL("SELECT A.TYPE, A.DESCR FROM PS_ABCD_TBL A WHERE A.EFF_STATUS = 'A' AND SOME CONDITION");

While &SQL.Fetch(&type, &descr)
    &FLD.AddDropDownItem(&type, &descr);
End-While;

My problem is I do not know exactly what event in the peoplecode should I put this in.

What I want to achieve is something like this:

A user will select a date. When the date is before June 2018, it displays a set of drop down items. However, if the selected date is on or after June 1, 2018, it will display another set of drop down list items.

1

There are 1 answers

0
Darryls99 On

So you are wanting the dropdown list to change when the date changes if I understand correctly. You should then put your code in the FieldChange Event for the date field.

In PeopleSoft you have Record.Field.FieldChange Event and Component.Record.Field.FieldChange. The Record.Field.FieldChange event will fire whenever this field is changed regardless of what component it is in. While Component.Record.Field.FieldChange PeopleCode only fires when that field is changed in the component where you saved the code.

In your case you likely want it on the Component.Record.Field.Fieldchange event as your logic sounds component\page specific.