
- 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 06:59 AM
replace
subscription.condition = '^u_affected_ci = current.variables.application';
with
subscription.condition = '^u_affected_ci ='+current.variables.application;

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-03-2018 07:22 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-03-2018 07:25 AM
Use the below
subscription.condition = '^u_affected_ci ='+current.variables.application.getDisplayValue();

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-03-2018 08:14 AM
Do you know how I can get it to add all of the selected applications as or statements? The user can select multiple applications and all of those needs to be added to the condition builder as or statements