The views and opinions expressed in this blog are those solely of the author(s) and do not necessarily reflect Microsoft’s current policy, position, or branding. For official announcements and guidance on Dynamics 365 apps and services, please visit the Microsoft Dynamics 365 Blog.
Personalized Community is here!
Quickly customize your community to find the content you seek.
Now Available in Community - New TechTalk Videos for 2020
Read More about New TechTalks for 2020
2020 Release Wave 2Discover the latest updates and new features to Dynamics 365 planned through March 2021.
Release overview guides and videos Release Plan | Preview 2020 Release Wave 2 TimelineWatch the 2020 Release Wave 1 virtual launch event
Ace your Dynamics 365 deployment with packaged services delivered by expert consultants. | Explore service offerings
Connect with the ISV success team on the latest roadmap, developer tool for AppSource certification, and ISV community engagements | ISV self-service portal
The FastTrack program is designed to help you accelerate your Dynamics 365 deployment with confidence.
FastTrack Program | Finance TechTalks | Customer Engagement TechTalks | Upcoming 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