locked
Determine the Numder of Days Between Two Dates in a Workflow - CRM Online RRS feed

  • Question

  • We are using CRM Online and I'm creating a workflow that will be creating a new record in a custom entity and one of the fields is the number of days between two specifc dates. I know you can perform cacluations with JavaScript but does anyone know of a way to determien the number of days between two dates when using a workflow?
    Friday, January 25, 2013 3:52 PM

Answers

  • Hi,

    There is no way to calculate difference of dates through built-in workflow activities. You could do some similar work with a custom workflow activity. Refer to SDK examples. There is a good example about how to write a custom workflow activity.

    Friday, January 25, 2013 8:45 PM
    Moderator

All replies

  • Hi,

    There is no way to calculate difference of dates through built-in workflow activities. You could do some similar work with a custom workflow activity. Refer to SDK examples. There is a good example about how to write a custom workflow activity.

    Friday, January 25, 2013 8:45 PM
    Moderator
  • A workaround would be to create a custom entity in which add two date fields and an integer field (whole number). You then create a plugin that calculats the difference between the two dates and inserts it into the number field. You then set up your workflow to create an instance of this entity and set the dates. You can then read the number from the field on the next row in the workflow. After this I would recommend deleting the instance of the custom entity, as it is no longer needed and you do not want to hog your system. Deletion could also be done with deletion service.

    A bit of a workaround but it will work.


    Gustaf Westerlund, MVP, CEO and Chief Architect at CRM-Konsulterna in Sweden
    Blog: http://gustafwesterlund.blogspot.com
    Swedish Dyn CRM Forum: http://www.crmforum.se

    Friday, January 25, 2013 11:47 PM
  • A workaround would be to create a custom entity in which add two date fields and an integer field (whole number). You then create a plugin that calculats the difference between the two dates and inserts it into the number field. You then set up your workflow to create an instance of this entity and set the dates. You can then read the number from the field on the next row in the workflow. After this I would recommend deleting the instance of the custom entity, as it is no longer needed and you do not want to hog your system. Deletion could also be done with deletion service.

    A bit of a workaround but it will work.


    Gustaf Westerlund, MVP, CEO and Chief Architect at CRM-Konsulterna in Sweden
    Blog: http://gustafwesterlund.blogspot.com
    Swedish Dyn CRM Forum: http://www.crmforum.se

    Hi G Weterlund,

    If we want to write a plugin to do so, why to create another entity??? We could write a plugin on which triggers on update of these two fields. Then the plugin calculates and inserts the difference. However, the workflow activity is better in this case. Because, it does not need to write another plugin for other entities and fields!

    Saturday, January 26, 2013 6:57 AM
    Moderator
  • Hí,

    That is true if it's stored in that entity, it is an easier choice. The plugin-customentity is sort of like a CRM-Online workaround for not having custom workflow activities, and my answer was more in the general sense of comparing dates that may not be in the same entity. That was planned for the Polaris release by the way but I havn't checked to see if it is in there. If it is there, there is no need for the workaround, you can just create the custom activity.


    Gustaf Westerlund, MVP, CEO and Chief Architect at CRM-Konsulterna in Sweden
    Blog: http://gustafwesterlund.blogspot.com
    Swedish Dyn CRM Forum: http://www.crmforum.se

    Saturday, January 26, 2013 5:42 PM
  • Hello,

    You can create Custom Workflow Activity which are now supported for CRM Online in case your organization already has RU12 applied. Check following article - http://inogic.blogspot.ru/2013/01/custom-workflow-activities-for.html


    Freelance Developer for Dynamics CRM 4.0/2011

    Monday, January 28, 2013 1:04 PM
    Moderator
  • Hi,

    You might be interested in having a look at this set of Custom Workflow Activities : http://manipulationlibrary.codeplex.com/


    Best regards,
    Mathieu

    Microsoft .NET / Dynamics / MSSQL + BI

    Tuesday, January 29, 2013 11:20 AM