Multi Select Look Up in Class
class Nar_productvarientsDialog extends Runbase
{
DialogRunbase dialog;
DialogGroup dialogGrp;
FormBuildStringControl fbsCtrlPromotion;
FormStringControl fsCtrlPromotion;
container returnPromotion;
SysLookupMultiSelectCtrl msCtrlPromotion;
str promotionRange;
}
---------------------------------------------------------------------------------------------------
public query buildQuery()
{
Query q = new Query();
QueryBuildDataSource qbds;
InventTable inventTable;
;
qbds = q.addDataSource(tablenum(InventTable));
qbds.addSelectionField(fieldNum(InventTable,ItemId));
while select inventTable
{
qbds.addRange(fieldNum(InventTable,ItemId)).value(inventTable.ItemId);
}
return q;
}
class Nar_productvarientsDialog extends Runbase
{
DialogRunbase dialog;
DialogGroup dialogGrp;
FormBuildStringControl fbsCtrlPromotion;
FormStringControl fsCtrlPromotion;
container returnPromotion;
SysLookupMultiSelectCtrl msCtrlPromotion;
str promotionRange;
}
---------------------------------------------------------------------------------------------------
public query buildQuery()
{
Query q = new Query();
QueryBuildDataSource qbds;
InventTable inventTable;
;
qbds = q.addDataSource(tablenum(InventTable));
qbds.addSelectionField(fieldNum(InventTable,ItemId));
while select inventTable
{
qbds.addRange(fieldNum(InventTable,ItemId)).value(inventTable.ItemId);
}
return q;
}
--------------------------------------------------------------------------------------------------------
protected Object dialog()
{
FormBuildControl setupGroupControl;
;
dialog = super();
dialog.alwaysOnTop(true);
dialog.windowType(FormWindowType::Standard);
dialogGrp = dialog.addGroup('Promotion');
setupGroupControl = dialog.formBuildDesign().control(dialogGrp.formBuildGroup().id());
fbsCtrlPromotion = setupGroupControl.addControl(FormControlType::String, identifierstr(DICPromotionID));
fbsCtrlPromotion.label('Promotion id');
dialog.allowUpdateOnSelectCtrl(true);
this.dialogSelectCtrl();
return dialog;
}
---------------------------------------------------------------------------------------------------------
public void dialogPostRun(DialogRunbase _dialog)
{
FormRun formRun;
super(dialog);
formRun = _dialog.dialogForm().formRun();
if (formRun)
{
fsCtrlPromotion = formRun.design().control(fbsCtrlPromotion.id());
/// you can build with your own query, or created query in system by method construct
msCtrlPromotion = SysLookupMultiSelectCtrl::constructWithQuery(formRun, fsCtrlPromotion, this.buildQuery());
}
}
--------------------------------------------------------------------------------------------------------
public boolean getFromDialog()
{
boolean ret;
#Characters
ret = super();
if (msCtrlPromotion)
{
returnPromotion = msCtrlPromotion.getSelectedFieldValues(); // get actual value of the selected rows
//returnPeriodRecId = msCtrlPromotion.get(); // get RecIds of the selected rows (it's very useful when you want to look one field and return another field value)
}
promotionRange = con2StrUnlimited(returnPromotion,#comma);
return ret;
}
----------------------------------------------------------------------------------------------------------------
public static void main(Args _args)
{
Nar_productvarientsDialog nar_productvarientsDialog;
nar_productvarientsDialog = new Nar_productvarientsDialog();
if(nar_productvarientsDialog.prompt())
{
nar_productvarientsDialog.run();
}
}
No comments:
Post a Comment