Personalized Community is here!
Quickly customize your community to find the content you seek.
Now Available in Community - New TechTalk Videos for 2021
2021 Release Wave 1Discover the latest updates and new features to Dynamics 365 planned April 2021 through September 2021.
Release overview guides and videos Release Plan | Preview 2021 Release Wave 1 Timeline
The FastTrack program is designed to help you accelerate your Dynamics 365 deployment with confidence.
FastTrack Program | Finance and Operations TechTalks | Customer Engagement TechTalks | Upcoming TechTalks | All TechTalks
To assign default values to form in Microsoft Dynamics 365 for Finance and Operations is very common requirement. Event handlers in D365FO is very useful to implement the logic and fulfill the requirements of the clients.
Importantly, there are many event handlers for different purposes. To assign default values to form in D365FO, I am using OnInitValue form data source event handler. This event handler is triggered when form is initializing the fields of the data sources those belonged to that form.
In addition to the above, you can also add the criteria or conditions before assigning the default values. You can assign values by fetching it from somewhere in the system. You can do many things regarding initialization of the fields using this event handler.
I am assigning a value to a field in HcmEmploymentLeave form using OnInitValue form data source event handler.
[FormDataSourceEventHandler(formDataSourceStr(HcmEmploymentLeave, HcmEmploymentLeave), FormDataSourceEventType::InitValue)]
public static void HcmEmploymentLeave_OnInitValue(FormDataSource sender, FormDataSourceEventArgs e)
FormRun formRun = sender.formRun();
Object hcmEmploymentLeave_ds = formRun.dataSource(formDataSourceStr(HcmEmploymentLeave, HcmEmploymentLeave)) as FormDataSource;
HcmEmploymentLeave hcmEmploymentLeave = hcmEmploymentLeave_ds.cursor();
//Assigning value to the field
Above code is just an example to show you how it works. You can apply these steps to any form.
So, in this way you can use OnInitValue form data source event handler in D365FO to assign default values to form.
Moreover, if this helps you, please Like, Comment and Share to help other people.
If you found any ambiguity or a better solution, please feel free to ask.
Blog: Click here
YouTube: Click here
GitHub: Click here
The post Assign default values to form in D365FO appeared first on NevoiTech Blog.
Business Applications communities