Need help in Script to find out the all Workflow Run Script activity which all contains current.update()

Jitendra Diwak1
Kilo Sage

Hi Folks,

Need help in Script to find out the all Workflow Run Script activity which all contains current.update()

var wfw = new GlideRecord('wf_activity');
//wfw.addEncodedQuery('workflow_version.published=true^activity_definition=db8c65aec0a8016501d00259bc7203a4');
wfw.addQuery('sys_id', '901ba1a1c70010100a9b5d83c7c260eb');
wfw.query();
if(wfw.next()){
var ids = wfw.sys_id;
gs.print('ID..' +ids);

}
var valwfw = new GlideRecord('sys_variable_value');
valwfw.addQuery('document_key',ids);
valwfw.query();
if(valwfw.next());
gs.print('Hi...' +valwfw.document_key.name);

 

I tried running this by suing Background Script and it is running fine with one record. Now I require to get all the record dynamically which contains Run Script activity which all contains current.update()

 

Thanks

Jitendra

Please accept my solution if it works for and thumps up.
3 REPLIES 3

Mark Roethof
Tera Patron
Tera Patron

Hi there,

The script your sharing, does not contain anything with validating current.update()
Can you re-explain your question?

If it is actually after searching Workflow Script Utility, script field which contains current.update(), have a look at table:

sys_variable_value

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

Kind regards,
Mark
2020, 2021 ServiceNow Community MVP
2020, 2021 ServiceNow Developer MVP

---

LinkedIn
Community article, blog, video list

 

Kind regards,

 

Mark Roethof

Independent ServiceNow Consultant

10x ServiceNow MVP

---

 

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

LinkedIn

Mark Roethof
Tera Patron
Tera Patron

https://your_instance.service-now.com/sys_variable_value_list.do?sysparm_query=document%3Dwf_activity%5Evariable%3Dc35ddef20a0a0ba96248a7090eccd518%5EvalueLIKEcurrent.update()&sysparm_view=

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

Kind regards,
Mark
2020, 2021 ServiceNow Community MVP
2020, 2021 ServiceNow Developer MVP

---

LinkedIn
Community article, blog, video list

 

Kind regards,

 

Mark Roethof

Independent ServiceNow Consultant

10x ServiceNow MVP

---

 

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

LinkedIn

Hi Mark,

My requirement is to get all the run script in workflow which contains current.update() value. Here I'm querying two tables wf_activity and sys_variable_value where the condition I put from activity table is - Published is True and Activity definition is Run Script. From the values table I need to match the value with ID column and then check the Vales which contains current.update() dynamically. 

What script logic do i need to write. Below was the sample where I hv compared both tables value. I hv not checked for current.update value yet.

var wfw = new GlideRecord('wf_activity');
//wfw.addEncodedQuery('workflow_version.published=true^activity_definition=db8c65aec0a8016501d00259bc7203a4');
wfw.addQuery('sys_id', '901ba1a1c70010100a9b5d83c7c260eb');
wfw.query();
if(wfw.next()){
var ids = wfw.sys_id;
gs.print('ID..' +ids);

}
var valwfw = new GlideRecord('sys_variable_value');
valwfw.addQuery('document_key',ids);
valwfw.query();
if(valwfw.next());
gs.print('Hi...' +valwfw.document_key.name);

 

Thanks,

Jitendra

Please accept my solution if it works for and thumps up.