Monday, April 12, 2021

Form control lookup event handler in D365fo

 [FormControlEventHandler(formControlStr(EcoResProductCreate, SAZBaseItemIdentification_ItemId), FormControlEventType::Lookup)]
    public static void SAZBaseItemIdentification_ItemId_OnLookup(FormControl sender, FormControlEventArgs e)
    {
        SysTableLookup      sysTableLookup  = SysTableLookup::newParameters(tableNum(InventTable), sender);
        Query               query           = new Query();

        QueryBuildDataSource qbdsInventTable = query.addDataSource(tableNum(InventTable));
        qbdsInventTable = qbdsInventTable.addDataSource(tableNum(EcoResProductLifecycleState)); 
        qbdsInventTable.joinMode(JoinMode::InnerJoin); 
        qbdsInventTable.relations(true);
        
        qbdsInventTable.addRange(fieldNum(EcoResProductLifecycleState, SAZIsCopyItemSourceStatus)).value(enum2Str(NoYes::Yes));
        
        sysTableLookup.addLookupfield(fieldNum(InventTable, ItemId));
        sysTableLookup.addLookupMethod(tableMethodStr(InventTable, itemName));

        sysTableLookup.parmQuery(query);
        sysTableLookup.performFormLookup();

        FormControlCancelableSuperEventArgs ce = e as FormControlCancelableSuperEventArgs;
        ce.CancelSuperCall();
    }

No comments:

Post a Comment

Table browser URL in D365FO

Critical Thinking icon icon by Icons8