Wednesday, 12 August 2020

FormEventType::Closing in d365

 FormEventType::Closing


Example on formeventtype:closing

 [FormEventHandler(formStr(FormName), FormEventType::Closing)]
    public static void FormNamee_OnClosing(xFormRun sender, FormEventArgs e)
    {
        FormDataSource datasource_ds    = sender.dataSource(formDataSourceStr(FormName, DataSourceName));
        TableName      buffTable        = datasource_ds.cursor();
    }


Example 2. Form DataSource while closing the form (same will apply for OnInitialized,
[FormEventHandler(formStr(EcoResAttributeValue), FormEventType::Closing)]
public static void EcoResAttributeValue_OnClosing(xFormRun sender, FormEventArgs e)
{
     FormDataSource ecoResProduct_ds   =          sender.dataSource(formDataSourceStr(EcoResAttributeValue, EcoResProductAttributeValue));
      EcoResProductAttributeValue      ecoResAttributeValue = ecoResProduct_ds.cursor();
<YOUR CODE>
}   

example 3
class HRIHcmWorkerPositionsFormEvents
{
    [FormEventHandler(formStr(HcmWorkerPositions), FormEventType::Closing)]
    public static void HcmWorkerPositions_OnClosing(xFormRun sender, FormEventArgs e)
    {
        FormRun         element = sender;
        FormRun         formrun;
        FormDataSource  formDatasource;
        int             idx;
        str             name;

        formrun = element.args().caller();

        name = element.args().callerName();

        if(formrun && name == 'hcmWorker')
        {            
            for(idx=1;formrun.dataSourceCount();idx++)
            {
                if(formrun.dataSource(idx).cursor() is HcmEmploymentDetail)
                {
                    formDatasource = formrun.dataSource(idx);
                    formDatasource.research(true);
                    break;
                }
            }
        }
    }

}

Thanks,
Vikas Mehta


No comments:

Post a Comment

AZURE INTERVIEW QUESTIONS AND ANSWERS

AZURE INTERVIEW QUESTIONS AND ANSWERES 2021 2. What is cloud computing? Explanation:  It is the use of servers on the internet to “store...