How to access workflow objects in custom activity?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-04-2017 12:13 AM
Hi,
I am trying to create a custom activity using Orchestration activity designer but I am having some problems. The main issue is that the "workflow" and "current" objects are not available in the custom activity code. We are using the "Run Script" template. We are running Helsinki.
When going through the API reference (i.e., https://developer.servicenow.com/app.do#!/api_doc?v=helsinki&id=c_WorkflowScopedAPI), it indicates the following:
There are no constructors for creating an instance of a scoped workflow object. Instead, use the global workflow object available in activity scripts.
However, this seems to be incorrect.
Can anyone please point me in the right direction?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-04-2017 06:29 AM
Hi Tadas,
I have just checked in a Helsinki instance, and the documentation for the workflow object is correct.
The workflow and current global objects should be accessible from a "Run Script" component
I can let you know what I have just done to test that this is working so you can check whether is working in your end.
open the "Workflow Editor" and create a new workflow.
As an example, set the workflow properties using
Name = test
Table = incident
And save.
Right click on any part of the workflow editor panel, select "Add Core Activity" and then select the "Run Script" in the opened dialog.
Fill up any name and the following script:
gs.info("Workflow name: " + workflow.name);
gs.info("Current sysId: " + current.sys_id);
Save it and connect the created component between the Begin and End components.
Click in the top left icon and select "Publish"
Then, create and save a New Incident.
If you go to the system logs, you should be able to see the messages
Workflow name: test
Current sysId: <the sys id of the created incident>
You can take a look to: Creating a Workflow - ServiceNow Wiki
and Using the Workflow Editor - ServiceNow Wiki
for additional information on how to create workflows.
Hope it helps.
Ginés.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-05-2017 01:37 AM
Hi,
sorry but you are missing the point...
Yes, the current and workflow objects are available in the generic "Run Script" activity in the workflow editor.
However, what I am talking about is creating my own kind of activity using Orchestration activity designer (based on the predefined template called "Run Script").
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-20-2019 11:59 AM
Hi,
I have the same problem. Cannot use "workflow" or "activity" objects inside a custom orchestration activity.
Has anyone solved this?
Thanks