
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-03-2018 06:55 AM
I have a catalog item where users select multiple applications and multiple locations. Upon submitting the catalog item a record is created within the "sys_notif_subscription" table. I need to update the condition builder for the created record with or statements for all of the applications the user selects and all of the locations the user selects.
For example the users selects "ServiceNow" and "Microsoft" as applications and "New York" and "Kansas" as locations
The condition should reflect: u_affected_ci is ServiceNow OR u_affected_ci is Microsoft or u_offices_locations_impacted is New York OR u_offices_locations_impacted is Kansas
Please see screen shot below and my script in the current versions. Any help is greatly needed.
Script
var subscription = new GlideRecord('sys_notif_subscription');
subscription.initialize();
subscription.name = current.variables.name;
subscription.user = current.variables.requested_for;
subscription.notification = current.variables.notification;
if(current.variables.application != '' || current.variables.u_offices_locations_impacted != ''){
subscription.condition = '^u_affected_ci = current.variables.application';
}
var subscriptionID = subscription.insert();
Screen Shot
Solved! Go to Solution.
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-03-2018 08:51 AM
Okay, that's quite a bit trickier. Try this in place of your 'if' condition in your script above.
if(current.variables.application != '' || current.variables.u_offices_locations_impacted != ''){
// Initialize the query string
subscription.condition = '';
// Split the 'current.variables.application' value
var apps = current.variables.application.split(',');
// Iterate through the 'apps' array and add to the query string
for (i = 0; i < apps.length; i++) {
subscription.condition += 'u_affected_ciLIKE' + apps[i] + '^OR';
}
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-03-2018 08:51 AM
Okay, that's quite a bit trickier. Try this in place of your 'if' condition in your script above.
if(current.variables.application != '' || current.variables.u_offices_locations_impacted != ''){
// Initialize the query string
subscription.condition = '';
// Split the 'current.variables.application' value
var apps = current.variables.application.split(',');
// Iterate through the 'apps' array and add to the query string
for (i = 0; i < apps.length; i++) {
subscription.condition += 'u_affected_ciLIKE' + apps[i] + '^OR';
}
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-03-2018 09:04 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-03-2018 09:10 AM
I got it working by adding a line as you see below, thank you for the help, direction, and your time / patience. I am very thankful
var commaDelimetedapps = current.variables.application.toString();
var apps = commaDelimetedapps.split(',');

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-03-2018 07:35 AM
Thank you