Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics CRM (Archived)

seeing created on date , due date should auto populate to 30 days

Posted on by 5,005


//Get Created On date to build Due Date
if (Xrm.Page.getAttribute('createdon').getValue());
{

dueDate = Xrm.Page.getAttribute('createdon').getValue();

}

if (hourSLA) {
if (hourSLA % 11 == 0) {
var daysToAdd = (hourSLA / 11);
dueDate = correctTheHours(dueDate, eod, sod);
addDays(dueDate, daysToAdd);
} else {
var hoursToAdd = hourSLA % 11;
dueDate.setHours(dueDate.getHours() + hoursToAdd);
dueDate = correctTheHours(dueDate, eod, sod);

//Get the days to add via subtracting the extra hours from the total hours and dividing that result by 12 to get
the days to add.
var daysToAdd = ((hourSLA - hoursToAdd) / 11);
dueDate = addDays(dueDate, daysToAdd);
dueDate = CheckForSkipDays(dueDate);
}
} else if (daySLA) {
//Correct the hours so it is within the business day
dueDate = correctTheHours(dueDate, eod, sod);

//Add the days!
dueDate = addDays(dueDate, daySLA);
}

return dueDate;
}

-------------------------------------------------------

//If hours are before or after business hours, set to next day + hours past end of business day
function correctTheHours(dueDate, eod, sod) {

if (dueDate.getHours() >= eod) {
//
dueDate.setHours(sod + (dueDate.getHours() - eod));
dueDate.setDate(dueDate.getDate() +1);

} else if (dueDate.getHours() < sod) {

dueDate.setHours(sod + (24- eod) + dueDate.getHours());

}

return dueDate;
}

*This post is locked for comments

  • shivaram Profile Picture
    shivaram 3,315 on at
    RE: seeing created on date , due date should auto populate to 30 days

    Hi Sandeep,

    Will you please confirm one thing that,

    Lets say today you created Case. So from what time you create this case to 6Pm will consider as One day and Next day from 6am to 7Pm you need to consider one day. This is only for Business days (Exempted Public holidays and everything). Am I correct?

    Please clarify

    Thanks

  • sandeepc Profile Picture
    sandeepc 5,005 on at
    RE: seeing created on date , due date should auto populate to 30 days

    any suggestions will be marked as verified as it is urgent

  • sandeepc Profile Picture
    sandeepc 5,005 on at
    RE: seeing created on date , due date should auto populate to 30 days

    calculated fields are not there as it is crm 2013 .......morover this is onpremise account so we dnt have calculated fields.. 

  • Suggested answer
    TheMarkChristie Profile Picture
    TheMarkChristie 10,328 on at
    RE: seeing created on date , due date should auto populate to 30 days

    Hi Sandeep

    Have you thought about using workflows and calculated fields to do this?

    have a look at this article

    community.dynamics.com/.../calculated-fields-and-parent-entities

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.

Helpful resources

Quick Links

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,269 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,198 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans