Notifications
Announcements
No record found.
Hello,
is there way how to calculate end date from start date and duration? Duration is in working days.
Thanks for help
*This post is locked for comments
Hi,
This isn't possible Out of the Box. You need to achieve this either by client side scripting (OnSave event) or through Plugins. My recommendation is to achieve this though plugins.
The business logic is fairly simple, but could get complicated when you bring in the business working days and hours into consideration.
Hope this info helps.
Thanks,
Karth
See Karth's answer. Do consider business closure dates when implementing working days in CRM. Business Closure dates can be found in Settings -> Business Management.
So, i tried
function count_date () {
if (Xrm.Page.getAttribute("duration").getValue() != null) {
var enddate = Xrm.Page.data.entity.attributes.get("date_of_end")
var stardate = Xrm.Page.data.entity.attributes.get("date_of_stard")
var duration = Xrm.Page.data.entity.attributes.get("duration");
enddate.setDate(startdate().getDate + duration().getValue)
}
but not working.
You can use something like below to set end date, but as mentioned by Karth and Eyup, you need to consider working days in calculation
var startdate = Xrm.Page.getAttribute("startdate").getValue();
var duration = Xrm.Page.getAttribute("duration").getValue();
var enddate = new Date();
enddate .setTime(startdate .getTime() + (duration * 24 * 60 * 60 * 1000));
Xrm.Page.getAttribute("enddate").setValue(enddate );
Vijay Waghmare
Under review
Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.
As AI tools become more common, we’re introducing a Responsible AI Use…
We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…
These are the community rock stars!
Stay up to date on forum activity by subscribing.
SA-08121319-0 4
Calum MacFarlane 4
Alex Fun Wei Jie 2