Built in functions used to control translate values dynamically.

Built in functions used to control translate values dynamically.

We can control the Translate values in peoplecode using the function AddDropDownItem.

Syntax :

AddDropDownItem(CodeString, DescriptionString)

Description

The AddDropDownItem method adds an item to the dropdown list in the control for the field. The first time this method is called, it overrides the prompt table or translate table used to populate the list. Those items no longer appear in the list. Only the items added using this method display.

Subsequent calls to this method adds additional items to the dropdown list. The items added with the first call to the method also display.

If there is an existing value and the dropdown list is changed with these functions, the selection shows as (Invalid value) unless the new list contains an entry with the same code as the existing value.

Considerations Using AddDropDownItem

If the data for the dropdown is language sensitive, the values for the dropdown should come from the message catalog or from a database field that has a related language record, and should not be hard-coded.

A good place for your Peoplecode program to populate a dropdown list is in the RowInit event. This event executes before the page is shown for the first time, so it prevents unnecessary SQL.

Parameters

CodeString

Specify the value used to set the field value if this item is selected.

 Codes longer than the size of the field are truncated.

DescriptionString

Specify the value the end-user sees in the dropdown list.

Returns

None.

Example

Using a hard coded list is not appropriate for this function because translations do not work.

The data must come from the Translate Table (or other record) directly so that the data is translated correctly.

Local Rowset &Xlat;

&FLD = GetRecord(Record.JOB).GetField(Field.ACTION);

&FLD.ClearDropDownList();

Evaluate %Component

When Component.JOB_DATA_CONCUR

&Xlat = CreateRowset(Record.PSXLATITEM);

&Xlat.Fill("WHERE FILL.FIELDNAME = 'ACTION' AND Fill.FIELDVALUE in ('ADL','HIR') and EFFDT = (select max(EFFDT) from PSXLATITEM

B where B.FIELDNAME = 'ACTION' and B.FIELDVALUE in ('ADL','HIR') and EFFDT <= JOB.EFFDT)");

&Xlat_cnt = &Xlat.ActiveRowCount;

For &I = 1 To &Xlat_cnt

&CodeIn = &Xlat.GetRow(&I).GetRecord(1).FIELDVALUE.Value;

&DescIn = &Xlat.GetRow(&I).GetRecord(1).XLATLONGNAME.Value;

&FLD.AddDropDownItem(&CodeIn, &DescIn);

End-For;

Break;

When-Other

End-Evaluate;

See Also

Field class: ClearDropDownList method.


-Ganesh A.M

 

0 comments: