SBX - Search With Button

SBX - Forum Post Title

CRM workflow date update includes saturdays/sundays

Microsoft Dynamics CRM Forum

MayankP asked a question on 6 Aug 2008 2:24 AM
My Badges

Question Status

Unanswered

Hi, I want to create CRM workflow which updates the case follow up date based on priority. I

f priority is high --> follow up date would be 24 hrs (1 day) after the case create date.

 If priority is normal --> follow up date would be 72 hrs (1 day) after the case create date

Now the problem is that CRM includes (or counts) the weekends (Saturday/Sundays) while calculating the days after 3 days. I want to exclude these non business days to be counted in workflow.

Is there any ways we can avoid saturdays/sundays while dynamically setting date values in CRM 4.0 workflow? Any idea??

Thanks

Regards,

Mayank

Reply
Greg Wartes responded on 6 Aug 2008 2:24 PM
My Badges

I have not tried it, but you can go to settings - Business Management - Business Closures - select dates.

Reply
MayankP responded on 7 Aug 2008 2:29 AM
My Badges
i have tried doing that but it does not working how ever i am got idea to solve this using java script..i am working on it..i will post reply of this soon.. Anyways thanks Greg !!
Reply
MayankP responded on 7 Aug 2008 8:19 AM
My Badges

Here is how we have implemented this change. on save of Case entity we have written follwing java script to update the follow up by date. and if it comes as saturday/sunday we are moving it to monday.


if(crmForm.FormType == 1)
{

crmForm.all.followupby.DataValue = new Date();
//alert(crmForm.all.followupby.DataValue);

//high
 if(crmForm.all.prioritycode.DataValue ==1)
{
  crmForm.all.followupby.DataValue =   crmForm.all.followupby.DataValue.setDate(crmForm.all.followupby.DataValue.getDate() + 1);
}
else if (crmForm.all.prioritycode.DataValue ==2)
{
 crmForm.all.followupby.DataValue =  crmForm.all.followupby.DataValue.setDate(crmForm.all.followupby.DataValue.getDate() + 3);
}
else if (crmForm.all.prioritycode.DataValue ==3)
{
 crmForm.all.followupby.DataValue =    crmForm.all.followupby.DataValue.setDate(crmForm.all.followupby.DataValue.getDate() + 5);
}

//alert(crmForm.all.followupby.DataValue);

if(String (crmForm.all.followupby.DataValue).substr(0,3) == "Sat")
{
crmForm.all.followupby.DataValue =    crmForm.all.followupby.DataValue.setDate(crmForm.all.followupby.DataValue.getDate() + 2)
}
else if (String (crmForm.all.followupby.DataValue).substr(0,3) == "Sun")
{
crmForm.all.followupby.DataValue =    crmForm.all.followupby.DataValue.setDate(crmForm.all.followupby.DataValue.getDate() + 1)
}
//alert(crmForm.all.followupby.DataValue);

}

 

this works reallly nicely and fits well for our scenario.

bye !! 

 

 

 

 

Reply
Baris Kanlica responded on 8 Aug 2008 4:12 AM
My Badges

It's very nice. Thanks for your sharing. Can I put this code to my blog with your name?

Baris KANLICA
Software Specialist and Consultant
www.cub-e.net

Reply
MayankP responded on 8 Aug 2008 8:55 AM
My Badges

Yeah, sure

Reply

SBX - Two Col Forum

SBX - Migrated JS