Workflow Activity Definition - what is evailable from the script code?

alexthunder
Kilo Explorer

Dear All,

I wonder if someone could point us in the right direction with our challenge.

We are new to ServiceNow development, and making our first attempts ot implement a new Application. We have reeached the Workflows Definition section.

In the Workflow Activity Definition we can see the "Script" part which looks like the source-code written on either Java or JavaScript and it looks like opening the endless possibilities, BUT the questions is - how do we discover what is available from the source code of the script?

Let's say I write "var x =" and then what? What are the functions that are available to be called, what classes are available for making new instance of, what is the content of "this", what is the way to access the record in the database that is the subject of Workflow for the thread of code currently executed, or what is the way to make queries to other database tables?

I gues the general question is - where is the source of knowledge for finding answers to all these questions?

Cheers!

Alex

Experieco

10 REPLIES 10

You would need to install the Orchestration Plugin. After you install the Orchestration Plugin, you will see the


'Packs', 'Custom', and 'Data' Tabs



Packs are where Orchestration Applications will show up. So if you create a scoped application that wraps SAP for example it will be there. Or if you download a scoped application which includes activities, you will see them there.



'Custom' is where you go to create new activities with Activity Designer.



The Data tab is where you see available data on a workflow you are developing.



See a screenshot where I created numerous workflow activities including ones for Hadoop and Twitter automation.


Screen Shot 2015-11-24 at 12.16.35 PM.png


In as friendly a way as I can say it, if you guys don't have a firm grasp on Application Scoping in ServiceNow, you should probably not be deploying apps for it.


Michael is showing the "run script" activity available on the WorkFlow editor, which lets you execute raw javascript as part of the workflow.



What you're talking about is crafting your own activity definition, which I would *not* be doing unless you already had a clear cut use-case for doing so.


Not only because most things can be done via a Run Script that calls a Script Include, but also because custom Workflow Activity Definitions now requires the purchase of the Orchestration suite.



As for what objects you can access from an Activity Definition, you can probably get all that stuff answered via the Scripting in Servicenow training course, which details most of the objects unique to SN.  


Use Run Script when you need access to the scratchpad; otherwise, use the Java Script template in Activity Designer.



The difference between Run Script and Activity Designer is that you have well defined inputs and outputs specific to the purpose of that script.   Also, with Activity Designer you have reuse. You can reuse the activity in numerous workflows. You can see where the activity is used in. Even if you don't plan to reuse the activity, for troubleshooting purposes and best design practices, we recommend using Activity Designer. Activities created with Activity Designer give you access to the Databus.


Is activity designer available without an orchestration license?   Sources are telling me no.