Hello,
I am looking for a solution which will allow me to set the time part of a date/time filed in Dynamics 365, does anyone know if thats possible?
Thanks in advance
Hello,
I am looking for a solution which will allow me to set the time part of a date/time filed in Dynamics 365, does anyone know if thats possible?
Thanks in advance
Hello again,
My mistake I forgot to tick the "pass execution context as first parameter" checking that allows the script to work.
Is it possible to use a similar script to add X hours to the date time filed in the same way?
Thanks
Thank you so much for the quick reply however the script generated the error below
TypeError: Cannot read property 'getFormContext' of undefined
I used the script exactly as you has it above with the only exception of changing the ("new_remindat") parts to be ("new_enddate") to match the field name on my form
I would appreciate anymore help you could offer.
Thanks
Hi,
Thank you for your query.
Assuming your field is Date & Time, following is sample JS code:
function setTimePart(executionContext) { const formContext = executionContext.getFormContext(); var reminderDateTime = formContext.getAttribute("new_remindat").getValue(); if (reminderDateTime) { reminderDateTime.setHours(10); reminderDateTime.setMinutes(30); // Sets time part to 10:30 formContext.getAttribute("new_remindat").setValue(reminderDateTime); } }
For more details on JS Time manipulation please refer to:
Stay up to date on forum activity by subscribing. You can also customize your in-app and email Notification settings across all subscriptions.
André Arnaud de Cal... 291,280 Super User 2024 Season 2
Martin Dráb 230,214 Most Valuable Professional
nmaenpaa 101,156