
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-25-2018 09:05 AM
Hello,
Needing some help with a workflow run script. I am trying to take reference values from a List Colletor variable (i.e., Business Services) on my catalog request item and associate those records to a related list of my Certificate record. Basically, I want to associate all Business Services that is tied to Certificate record being viewed or Certificate record that is used by the following Business Services.
My script is adding records to my M2M related list table but my Business Service and Certificate Common Name columns are blank; so I am currently getting three blank records.
Assistance with what I might be missing?
//var cert = current.common_name.getValue('sys_id'); // Request Item reference variable of certificate record
//var list = current.variables.u_business_service_list; // Request Item list collector of related business services
var cert = '9ad10b62dbd56f001bd3c170ba9619e1'; // Testing with certificate's sys_id
var list = [];
var list = 'App 1,App 2,App 3'; // Testing with strings
var array = list.split(',');
for (var i=0; i < array.length; i++) {
// M2M table, related list, certificate to business service
var bs = new GlideRecord('x_teth_ekcm_m2m_business_ser_certificates');
bs.setLimit(10);
bs.addQuery('business_service', '!=', array[i]);
bs.addQuery('certificate_common_name', '!=', cert);
bs.query();
if(bs) {
bs.initialize();
bs.business_service = array[i];
bs.certificate_common_name = cert;
bs.update();
}
}
Thank you,
-Wesley
Solved! Go to Solution.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-30-2018 08:01 AM
Hi Wesley,
Can you do this; don't declare bsArray and use like this
var bsArray = current.variables.u_business_service_list.toString();
bsArray = bsArray.split(",");
Mark Correct if this solves your issue and also mark Helpful if you find my response worthy based on the impact.
Thanks
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-09-2021 09:08 PM
Hi,
update the query as this so that it iterates all sys_ids using IN operator
var cldappl = current.variables.application_names.toString();//List Collector
var gr = new GlideRecord('u_table_name');
gr.addQuery('sys_id', 'IN' , cldappl);
gr.query();
while (gr.next()) {
gr.u_business_owner = current.variables.please_update_the_business_owner;//field is getting updated in the table this is again a list collector.
gr.update();
}
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-10-2021 05:44 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-10-2021 05:59 AM
I would suggest to open new thread as this is quite older one and answered
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-10-2021 06:01 AM
I have opened new thread if you can check.
Multiple Value Update in a table through a Catalog form using scripts