Thursday 19 November 2020

Error message : More than one form was opened at once for the lookup control. in D365 FinOps

 Error message: More than one form was opened at once for the lookup control. in lookup in D365 F&O

If you get error message (More than one form was opened at once for the lookup control.) in notification Action Centre while clicking on lookup button in D365 then you just need to call a peace of code just after lookup performs.

        //cancel super() to prevent error.

        FormControlCancelableSuperEventArgs cancelEventArgs = e as FormControlCancelableSuperEventArgs;

        cancelEventArgs.CancelSuperCall();

For example - Lookup method:

[FormControlEventHandler(formControlStr(EcoResProductDetailsExtended, InventTable_HSNRFColorCode), FormControlEventType::Lookup)]

    public static void InventTable_HSNFRColorCode_OnLookup(FormControl sender, FormControlEventArgs e)

    {

        Query                   query = new Query();

        QueryBuildDataSource    queryBuildDataSource;

        SysTableLookup          sysTableLookup;


        sysTableLookup = SysTableLookup::newParameters(tableNum(HSNRFColorCodes), sender);

        queryBuildDataSource = query.addDataSource(tableNum(HSNRFColorCodes));

   

        sysTableLookup.addLookupField(fieldNum(HSNRFColorCodes, NRFColorCode));

        sysTableLookup.addLookupField(fieldNum(HSNRFColorCodes, NRFColorGroup));

        sysTableLookup.addLookupField(fieldNum(HSNRFColorCodes, Description));


        sysTableLookup.parmQuery(query);

        sysTableLookup.performFormLookup();

        // If you get error message (More than one form was opened at once for the lookup control.) in notification Action Centre then call below one line code.

        //cancel super() to prevent error.

        FormControlCancelableSuperEventArgs cancelEventArgs = e as FormControlCancelableSuperEventArgs;

        cancelEventArgs.CancelSuperCall();

    }


Happy DAXing...

Monday 9 November 2020

How to get ExecutionId at runtime in D365 FO Data management

 Get ExecutionId at runtime in Data entity.

Today, I am going to share a practice code to get ExecutionId at runtime in D365 FinOps.
Lets say, you are working on a data entity and you need to get ExecutionId at run time so that you can call you custom logic for that particular data job.

Check the data entity you are working on and find the 2- methods (1. postGetStagingData 2. postTargetProcess). If you don't find these methods, you can add in the Data entity extension.

Method-1:
// This is the method which executes before data execution from staging to target
public static void postGetStagingData(DMFDefinitionGroupExecution _dmfDefinitionGroupExecution)
{
        DMFExecutionId     executionId = _dmfDefinitionGroupExecution.ExecutionId;
}


Method-2:
// This is the method which executes after data execution in target at event of DMFEntityWritter.write()
public static void postTargetProcess(DMFDefinitionGroupExecution _dmfDefinitionGroupExecution)
{
        DMFExecutionId     executionId = _dmfDefinitionGroupExecution.ExecutionId;
}


Happy DAXing...