How do you include "Script Includes" in a workflow script?

santrym
Mega Expert

I have a script in my workflow that I want to make globally usable by other workflows. So, I added the script contents to the "Script Includes" table. Now I want to replace the script from the workflow with the newly created "Script Include", lets call it "global script". How do I replace the contents of my workflow's script and replace it with an include/call to "global script"?

Does this make sense. Any help or thoughts are appreciated!

1 ACCEPTED SOLUTION

Ken83
Mega Guru

From your workflow, I'm assuming you're using a "Run Script" activity, you need to initialize your script include that you created. Like so...



var scriptInclude = new scriptIncludeNameGoesHere();



Now that you've initialized your script include, you need to determine what function/method you want to trigger within the script include. It would look something like this..



var trigger = scriptInclude.functionNameGoesHere(//insert parameters here if you need to. If there aren't any, leave the parenthesis empty);



This line will trigger the method within your script include where you've moved your functionality and in your workflow, now you'd only have 2 lines of code and the Server side would be doing all of the lifting.


View solution in original post

6 REPLIES 6

smcdonaldaz
Tera Guru

I have an IF workflow activity where i need to determine if a person is a director level or above.  the code in my IF is as follows:

find_real_file.png

The name of the script include is "directorAndAbove" and the function inside the include is "isYes".  I pass the title and "true" or "false" is returned depending on if the regex matches.

find_real_file.png

Hope this helps.

Nestor Paredes
Tera Contributor

Just as a side note, it seems that the only place you can call script includes on a workflow are the Script activities.

The same code just does not run calling it from the code area on an approval activity for example.

 

The solution was to load the script include on a Script activity and dump the values on the scratchpad and then call these from whenever you need.