Finding references / sys_ids in Workflows
Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field
| Workflow Editor is a legacy product to maintain existing workflows already in production. For new use cases and workflows, use ServiceNow Workflow Studio. Workflow Studio is a low-code alternative to Workflow Editor. |
|---|
Hi there,
Ever experienced changing Groups? Groups being renamed? Groups being split? Groups being merged? Probably: Yes
. A very common thing within organizations, some organizations even a yearly ritual.
When working with Workflows within ServiceNow, this could cause a nasty situation. You know that you are using a certain Group or sys_id in one or more Workflows, you applied those Groups through the proper Reference field, or less proper hardcoded the sys_id (well actually... by using the reference field, you are also hardcoding a sys_id!). Though which Workflow? And which Activity? O man... it's like searching for a needle in a haystack.
Approval - Group activity
So let's say, you added a Group to the "Approval - Group" activity in a proper way, by simply selecting the group on the Groups field which is of type List Collector.
Actually, not the Group name is stored within your Workflow. The sys_id is actually stored because we are dealing here with a field of style List Collector.
Workflow Activities [wf_activity]
So looking at the above last sentence: We are not searching for the Group name, we are actually after the sys_id of the group. Though where can we find this?
We know most tables related to workflows, start with "wf_". After a short search, we will even get our hands on the "wf_activity" table! Looks pretty good, this table contains all Workflow Activities used within our Workflow. Though looking into these Activities, still no sys_id to be found.
Values [sys_variable_value]
Let's just jump to the key here: the Values table [sys_variable_value]!
Looking at the image above, you'll notice that an activity can contain multiple Values records. Records with all kinds of values: Integers, Counters, Scripts, sys_ids, etcetera. Sys_ids!!!
So when searching for the needle in the haystack: actually the Values table is your place to be
Simply look for Value contains .
The record(s) returned, contain the ID field, which references the Workflow Activity the Values record is attached to. Opening the Workflow Activity, would also give you the Workflow you are after [Field: Workflow version].
---
And that's it. Hope you like it. If any questions or remarks, let me know!
Kind regards,
Mark Roethof
ServiceNow Technical Consultant @ Quint Technology
1x ServiceNow Developer MVP
1x ServiceNow Community MVP
---
https://www.servicenow.com/community/developer-articles/finding-references-sys-ids-in-workflows/ta-p/2324753
