Finding references / sys_ids in Workflows - ServiceNow Community
Mark Roethof
Tera Patron
Tera Patron

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.

 

find_real_file.png

 

find_real_file.png

 

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.

 

find_real_file.png


Values [sys_variable_value]

Let's just jump to the key here: the Values table [sys_variable_value]!

 

find_real_file.png

 

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 <your_sys_id>.
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!

 

C

If this content helped you, I would appreciate it if you hit bookmark or mark it as helpful.

 

Interested in more Articles, Blogs, Videos, Podcasts, Share projects I shared/participated in?
- Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field

 

Kind regards,


Mark Roethof

ServiceNow Technical Consultant @ Quint Technology
1x ServiceNow Developer MVP

1x ServiceNow Community MVP

---

LinkedIn

Comments
rahulyamgar
Tera Guru

Hello Mark, 

This article is really helpful. But following your article, I created a simple workflow with simple approval workflow with couple of user approvers and a group approval. But I am not understanding is sys_varaible_value table crated 23 entries, it`s show xml also shows around 23 sys_variable entries. What are those created for ? Please explain.

Thanks,

Rahul 

Anders Pr_steg1
Tera Contributor

Hi Mark
That's very useful!
Would you have an idea how to approach references/sys_id's in flows as well?
Thanks,
Anders

Version history
Last update:
‎08-03-2024 06:44 AM
Updated by:
Contributors