Update workflow activities via script

Mandeep Karan
Tera Guru

Is there any way to update workflow activities of existing workflows via script? we have a requirement to update the value of assignment group in all the activities(catalog task/ approval group) where specific group is used.

Regards,

Mandeep

1 ACCEPTED SOLUTION

Mark Roethof
Tera Patron
Tera Patron

Hi there,

Technically: Yes. Open the wf_activity table, filter for your workflow, activity definition "Run Script", and filter on the name (if it didn't change over time). You could get an overview like below example. Just look for the published record. The record contains a "script" field with the actual script. Technically you could just update this. Also thru a Fix Script, Background script, etc..

find_real_file.png

find_real_file.png

This might also be a nice opportunity to not just change the hardcoded sys_id (which is not best practice) but for example use a system property.

If my answer helped you in any way, please then mark it as helpful.

Kind regards,
Mark

---

LinkedIn

 

Kind regards,

 

Mark Roethof

Independent ServiceNow Consultant

10x ServiceNow MVP

---

 

~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field

LinkedIn

View solution in original post

4 REPLIES 4

Mark Roethof
Tera Patron
Tera Patron

Hi there,

Technically: Yes. Open the wf_activity table, filter for your workflow, activity definition "Run Script", and filter on the name (if it didn't change over time). You could get an overview like below example. Just look for the published record. The record contains a "script" field with the actual script. Technically you could just update this. Also thru a Fix Script, Background script, etc..

find_real_file.png

find_real_file.png

This might also be a nice opportunity to not just change the hardcoded sys_id (which is not best practice) but for example use a system property.

If my answer helped you in any way, please then mark it as helpful.

Kind regards,
Mark

---

LinkedIn

 

Kind regards,

 

Mark Roethof

Independent ServiceNow Consultant

10x ServiceNow MVP

---

 

~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field

LinkedIn

I can't see the script field on workflow activities. could you please let me know where i can find it?

find_real_file.png

find_real_file.png

 

Regards,

Mandeep

Yes you are correct. In the popup the script field is shown, though actually the script field is stored in the Values table [sys_variable_value].

find_real_file.png

If my answer helped you in any way, please then mark it as helpful.

Kind regards,
Mark

---

LinkedIn

 

Kind regards,

 

Mark Roethof

Independent ServiceNow Consultant

10x ServiceNow MVP

---

 

~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field

LinkedIn

Thank you!