- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-25-2024 09:21 PM
I found myself in need to amend a catalog item that uses a legacy workflow (let's call it workflow A) to trigger another legacy workflow (let's call it B) at the end. Workflow B is used by another catalog item and is fully independent. It uses two variables, which are present and are of the same type and identically named in both catalog items; it writes to workflow log and leaves important details for the user in work_notes . So I added workflow B as a step in workflow A. I can see that workflow B executes, but neither its workflow log entries nor its work notes show up anywhere. Is there a way to fix that? Perhaps a property or a group of settings that control how workflow.info and current.work_notes behave in a workflow when it's triggered as a subflow?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-03-2025 03:07 PM - edited 01-03-2025 03:09 PM
Update, to avoid confusing others: there was no problem with the workflow after all; only a little bug in the code, introduced by accident. Both workflows use the same table (sc_req_item) and rely on the same standardized variables, so both have access to the current record and are able to write work notes. Both log into their individual workflow contexts, i.e. Workflow A has its own context and Workflow B has its own.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-25-2024 09:40 PM
are you passing some inputs to Workflow B when it's called from Workflow A?
you can pass the inputs and use that in workflow B
how are you calling the 2nd workflow? is it via script? if yes then send this as input
1) Create workflow input variable
2) Then send the data like this
var inc = new GlideRecord('incident');
inc.get('8d44ecd62ff56010aedd55f62799b691');
inc.short_description = 'test';
inc.update();
var wflow = new Workflow();
var wfId = wflow.getWorkflowFromName("Incident") ;
var vars= {};
// you need to set the value in the same column name u_username
vars.u_username = 'my_id_to_workflow';
wflow.startFlow (wfId, inc, inc.operation() , vars) ;
3) Then access it like this
// u_username is the column name which you need to use to access the value
gs.info("workflow value"+ workflow.inputs.u_username);
Output:
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-26-2024 07:15 PM - edited 12-26-2024 07:23 PM
This is not what I am doing. I added the workflow B (shown below) as a step in workflow A:
There is no script involved in invoking this workflow; it is self contained and relies on two standardized variables that are included in the catalog item invoking workflow A (which now also includes workflow B shown above). I see in debugger that Workflow B successfully picks up the variable values.
Now, back to my question: I can see that workflow B executes, but its
workflow.info entries don't show in workflow log and its current.work_notes entries don't appear in work notes - unlike those from workflow A. Is there a way to fix that?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-26-2024 07:47 PM
for workflow.info did you try gs.info() and see if log came
for current.work_notes the workflow B won't know what's the current object.
If you wish to write work notes to record via workflow B then ensure you pass the record sysId and query the record in workflow B and then set work notes
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-03-2025 03:07 PM - edited 01-03-2025 03:09 PM
Update, to avoid confusing others: there was no problem with the workflow after all; only a little bug in the code, introduced by accident. Both workflows use the same table (sc_req_item) and rely on the same standardized variables, so both have access to the current record and are able to write work notes. Both log into their individual workflow contexts, i.e. Workflow A has its own context and Workflow B has its own.