Sunday, 12 April 2015

Populate values of drop-down list through peoplecode

Sometime we need to populate values of drop-down list based on value of another field or some other condition.

/*Declare Local Variable*/
Local SQL &SQL;
Local Rowset &rset;
Local Field &field;
Local string &type, &descr;

/* Getting the level 0 and level 1 records */
&rset= GetLevel0()(1).GetRowset(Scroll.TEST);

/* Getting the field to which the drop down is attached */
&field = &rset(1).GetRecord(Record.TEST).GetField(Field.VALUE);

/* Clearing all existing values*/
&field.ClearDropDownList();

/* SQL for fetching values that to be added in drop down.*/
&SQL = CreateSQL("select fieldvalue, xlatlongname from psxlatitem where fieldname='VALUE’");

While &SQL.Fetch(&fieldvalue, &xlatlongname)
   & field.AddDropDownItem(&fieldvalue, &xlatlongname);
End-While;