Monday, April 12, 2021

Form control Modified event handler in D365fo

 [FormControlEventHandler(formControlStr(EcoResProductCreate, SAZBaseItemIdentification_ItemId), FormControlEventType::Modified)]
    public static void SAZBaseItemIdentification_ItemId_OnModified(FormControl sender, FormControlEventArgs e)
    {
        formRun callerForm = sender.formRun();

        FormStringControl senderStringControl = sender as FormStringControl;

        FormStringControl ProductLifecycleStateIdStringCtrl = callerForm.design().controlName(formControlStr(EcoResProductCreate, ProductLifecycleStateId)) as FormStringControl;

        InventTable inventTable = InventTable::find(senderStringControl.valueStr());

        if(inventTable)
        {
            if (callerForm && formHasMethod(callerForm, identifierstr(templateRecords2Controls)))
            {
                //setting data 2 Ecorsproduct controls
                callerForm.templateRecords2Controls(BaseItemTemplateHelper::construct().dataSourceListWithRecordMap(inventTable.ItemId));
            }
        }

        senderStringControl.text(inventTable.RecId != 0 ? inventTable.ItemId : strMin());

    }

No comments:

Post a Comment

Table browser URL in D365FO

Critical Thinking icon icon by Icons8