D365 Customization Barriers and How to Overcome Them: ohya's Practical Diary [#004] ~When you open a form, "today's date" is automatically entered!? A smart solution with JavaScript~
Hello, this is ohya.
This time, we will introduce how to automatically enter today's date when opening a form in Dynamics 365.
"Well, that's easy, right?" you might think.
Actually thisThis cannot be done with Power Automate or business rules.That's it...!
At first glance, it may seem like a simple requirement, but it's actually surprisingly complex!
🛠️This time's wall: "I want to have 'Today' pop up the moment I open the form!"
We created a "Contact History" table to record sales activities.
In the "Contact Date" field,I want "today's date" to be automatically entered when the form is opened.There was a request.
But here's the problem...! I couldn't achieve my goal using the usual methods.
❌ Why the usual method didn't work
-
- Business Rules → There is no function to set "Today's date"
- Power automat → It only works when it is saved
- When you open the formPower Automate will not respond because no records have been created yet!
In other words, to "fill in the form the moment it is opened",A different approach is neededIt was.
✅ Solution: Real-time input with JavaScript!
So this time,Use JavaScript to automatically enter "today's date" when displaying a formWe adopted a method to do this.
1. Create a JavaScript web resource
First, include the following code: .js Create the file:
2. Add a web resource to your form
- Open the form editor
- Add the above JS file to "Form Library"
- On the "form load" event
setTodayDateRegister a function executionContextDon't forget to set it to pass!

3. Operation check
As soon as you open the form, enter the contact date in the "Contact Date" field.Today's date is automatically enteredIt will be possible to do so!
✅ Summary
- Requirements that cannot be achieved with business rules or Power Automate can be solved with JavaScript!
- To "Set values when form is opened"Form Events + JavaScriptis valid
- With a small ingenuity,Reduces user effort and errorsThat's the fun of customization!
✍️ Conclusion
Even a little auto-fill can be a big help to users.
Like this time,Real-time input assistance using JavaScriptgreatly expands the scope of customization for D365.
Next time, I'll be sharing the knowledge I've gained through hands-on experience, so stay tuned!
Person who wrote this article
Articles in the same category
-
Why not learn the essence of CRM in our "CRM Introductory Course"? -
Are small and medium-sized enterprises at risk? Strengthening governance and security measures […] -
Living with "Doko Bus +" ♦ Special Edition: Introducing the operation screen -
Living with "Doko Bus +" ♦ Part 3: Providing easy local transportation [...] -
D365 Customization Barriers and How to Overcome Them: ohya's Practical Notes [#010[...] -
Living with "Doko Bus +" ♦ Part 2: The ease that comes with convenience [...]
