how to get all datasource in form event handlers in dynamics d365
[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();
//sender.dataSource(formDataSourceStr(HcmWorkerPositions, hcmWorker)); you can also try this.
if(formrun && name == 'hcmWorker')//hcmworker is second datasource.
{
for(idx=1;formrun.dataSourceCount();idx++)
{
if(formrun.dataSource(idx).cursor() is HcmEmploymentDetail)
{
formDatasource = formrun.dataSource(idx);
formDatasource.research(true);
break;
}
}
}
}
No comments:
Post a Comment