locked
Adding 4 days with a workflow process RRS feed

  • Question

  • I created a workflow that when there is a new record it adds 4 days to the date that in my custom field called dhc_dateclaimreceived. Doesn't look like it is working. How would I go about adding 4 days to a field. Here is what I have. Please let me know what I am doing wrong.

    Tuesday, June 23, 2015 1:13 PM

Answers

  • Personally i would recommend using the workflow to do this because sometimes javascripts cause problems for users with strict/wrong browser settings.

    Instead of using your custom workflow action (Date Utilites : Add Date) use the out of the box workflow action Update, click set properties for that and in the form window that opens up click inside the date field you intend to update and on the right side,

    1. under Day set 4
    2. in the dropdown there below select after
    3. Look for : Process
    4. Execution Time
    5. Click Add
    6. Click OK
    7. Save and close the form.

    This means you will set the date exactly 4 days after the workflow runs, if you wish to use your created on field to update instead (might be safer if your workflows take time to run then select under Look for : [Your entity] and in the second drop down Craeted On.

    Also in the workflow under the Administration Tab, I would advice to check the delete after workflow runs successfully check box, this will keep your CRM system nice and clean. 


    Halldór Jóhannsson


    Thursday, June 25, 2015 3:17 PM

All replies

  • Hello,

    Date Utilities (and its underlying method, Add Days) is a custom workflow activity and not an OOB functionality in CRM.

    Why not simple use the update message avaiable in the workflow wizard?

    You've the correct context on your workflow (running on create for Organization), now all you have to do is set an Update Message to this newly created "Claim" record, and set your custom datetime field to itself plus 4 days (all available in the wizard itself);

    Alternatively you could go for a simple Plugin which would run on create and perform this action on the Pre Event pipeline phase to set this value in context via code.

    Tuesday, June 23, 2015 3:10 PM
  • I am not sure how or where to find this update message. I believe that would work for me.
    Tuesday, June 23, 2015 3:23 PM
  • if you want to Add four days when record create you can also write JavaScript on form save

    as

    function setClaimReceived_Date()
    {
    //run only once on first time create
    if(Xrm.Page.ui.getFormType()==1)
    {
    var d = new Date();
    d.setDate(4);
    Xrm.Page.getAttribute("dhc_dateclaimreceived").setValue(d);
    }
    
    }
    


    Muhammad Sohail

    Wednesday, June 24, 2015 5:42 AM
  • Muhammad,

    This is perfect! The only thing I would need to add is some kind of where clause (I am not sure how to add that in JavaScript). It would need to say 

    dhc_cdeaction = 'Y - Fax Blast Holds' and dhc_clientcode1 NOT IN('12410','13160')

    Thursday, June 25, 2015 1:42 PM
  • Personally i would recommend using the workflow to do this because sometimes javascripts cause problems for users with strict/wrong browser settings.

    Instead of using your custom workflow action (Date Utilites : Add Date) use the out of the box workflow action Update, click set properties for that and in the form window that opens up click inside the date field you intend to update and on the right side,

    1. under Day set 4
    2. in the dropdown there below select after
    3. Look for : Process
    4. Execution Time
    5. Click Add
    6. Click OK
    7. Save and close the form.

    This means you will set the date exactly 4 days after the workflow runs, if you wish to use your created on field to update instead (might be safer if your workflows take time to run then select under Look for : [Your entity] and in the second drop down Craeted On.

    Also in the workflow under the Administration Tab, I would advice to check the delete after workflow runs successfully check box, this will keep your CRM system nice and clean. 


    Halldór Jóhannsson


    Thursday, June 25, 2015 3:17 PM
  • Thank you so much Halldór  this worked!
    Thursday, June 25, 2015 4:59 PM
  • Glad to hear this worked out 8)

    Halldór Jóhannsson

    Thursday, June 25, 2015 5:03 PM