Create static query and add fields.
class CPLBlockQualityOrdersMultiselectCtrl
{
[FormEventHandler(formStr(InventParameters), FormEventType::Initialized)]
public static void InventParameters_OnInitialized(xFormRun sender, FormEventArgs e)
{
FormRun formRun = sender as FormRun;
SysLookupMultiSelectCtrl msCtrl;
Query blockQualityOrder = formRun.buildDocuTypeQuery();
FormStringControl blockQualityorderCtrl = formRun.design().controlName('CPLSpecificBlockQualityOrder');
InventParameters inventParameters = InventParameters::find();
msCtrl = SysLookupMultiSelectCtrl::construct(formRun,blockQualityOrderCtrl,querystr(CPLBlockQualityOrder), false, [tableNum(WMSJournalName), fieldNum(WMSJournalName,journalNameId)]);
msCtrl.refreshQuery(blockQualityOrder);
msCtrl.set(formRun.getSelectedNotes(inventParameters.CPLBlockQualityOrder));
formRun.setMultiselectCtrl(msCtrl);
}
[FormDataFieldEventHandler(formDataFieldStr(InventParameters, InventParameters, CPLBlockQualityOrder), FormDataFieldEventType::Modified)]
public static void CPLBlockQualityOrder_OnModified(FormDataObject sender, FormDataFieldEventArgs e)
{
FormRun formRun = sender.datasource().formRun();
SysLookupMultiSelectCtrl msCtrl = formRun.parmsCtrl();
InventParameters inventParameters = formRun.dataSource(FormDataSourceStr(InventParameters,
inventParameters)).cursor() as InventParameters;
inventParameters.CPLBlockQualityOrder = con2Str(msCtrl.getSelectedFieldValues(), ';');
}
}
----------------------------------------------------------------------------------------------------
[ExtensionOf(formstr(InventParameters))]
public final class CPLDevInventParametersForm_Extension
{
public SysLookupMultiSelectCtrl msCtrl;
public SysLookupMultiSelectCtrl parmsCtrl()
{
return msCtrl;
}
public void setMultiselectCtrl(SysLookupMultiSelectCtrl multiselect)
{
msCtrl = multiselect;
}
public Query buildDocuTypeQuery()
{
Query wmsJournalName = new Query(queryStr(CPLBlockQualityOrder));
return wmsJournalName;
}
container getSelectedNotes(str _noteStr)
{
WMSJournalName wmsJournalName;
container tmpValues, conIds, conName;
int idx;
if(_noteStr)
{
tmpValues = str2con(_noteStr, ';');
}
for(idx=1; idx<=conLen(tmpValues); idx++)
{
wmsJournalName = WMSJournalName::find(conPeek(tmpValues, idx));
conIds += wmsJournalName.RecId;
conName += wmsJournalName.journalNameId;
}
return [conIds, conName, conIds];
}
}
Reference
https://erpdax.wordpress.com/2022/03/24/multiselect-lookup-in-d365-fo/
No comments:
Post a Comment