Sunday, June 26, 2022

How to get element from formRun Dynamics 365 FO

[FormControlEventHandler(formControlStr(SalesAgreementListPage, MCOSAtoPO), FormControlEventType::Clicked)]

public static void MCOSAtoPO_OnClicked(FormControl sender, FormControlEventArgs e)

    {

        FormRun                 element             = sender.formRun();

        FormDataSource          SalesAgreementHeader_DS    = element.dataSource(formDataSourceStr(SalesAgreementListPage, SalesAgreementHeader));

        SalesAgreementHeader    SalesAgreementHeader = SalesAgreementHeader_ds.cursor();

        SysGlobalCache globalCache;

        globalCache = ClassFactory.globalCache();

        globalCache.set(strFmt("%1%2",curUserId(),"SalesAgreementHeader"), 0, SalesAgreementHeader.RecId);

    }