How to use Custom JavaScript function within a Workflow Subaction(Advanced)

Created by Joshua Miller, Modified on Sun, 23 Mar at 8:07 PM by Joshua Miller

Custom JavaScript is able to be used in a high-level way within the Subactions of the Workflow

Instructions


  1. Select Module in the top left banner then select the appropriate module name link.
  2. Select the appropriate module for which the Subaction JavaScript is needed.
  3. Select the Workflows tab, followed by the relevant workflow.
  4. Select the Actions tab, followed by the Action to be customized.
  5. Select the Subactions tab, on the right side of the assignment expression, paste the code below to assign a field value to the total number of days since submitted.
     (The below code requires that the time being compared against be customDateTime1)


Example - Days since Submitted

{(function(){var one_day=1000*60*60*24 * 1.0; var date1_ms = new Date('%(submittedOn)%').getTime();var date2_ms = new Date('%(customDateTime1)%').getTime();var diffDays = Math.ceil(date2_ms - date1_ms) / one_day;return diffDays;})()}


Example - Week from Submitted

{(function(){

var submittedOn = new Date('%(submittedOn)%');

var submittedPlus7 = new Date(submittedOn);

submittedPlus7.setDate(submittedPlus7.getDate() + 7);

return submittedPlus7.toISOString();

}) ()}


Was this article helpful?

That’s Great!

Thank you for your feedback

Sorry! We couldn't be helpful

Thank you for your feedback

Let us know how can we improve this article!

Select at least one of the reasons
CAPTCHA verification is required.

Feedback sent

We appreciate your effort and will try to fix the article