- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-08-2022 03:28 PM
Hi
Could you please help me with the following script?
I would like to change to include 'contains' of the catalog item instead of equal to
gr.cat_item.name contains "User account" doesn't seem to be correct.
answer = ifScript();
function ifScript() {
if (gr.cat_item.name == "User account" && gr.variables.business_unit == "IT") {
return 'Yes';
}
return 'No';
}
Thanks for the help!
Solved! Go to Solution.
- Labels:
-
Service Catalog
-
Workflow

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-08-2022 04:39 PM
Hi, You’re assigned values before the gr query is happening so they will always be empty.
sorry for phone formatting
answer = ifScript();
function ifScript() {
var gr = new GlideRecord("sc_req_item");
gr.addQuery("request", current.getUniqueValue());
gr.query();
if (gr.next()) {
var catItemName = gr.cat_item.name.toString(); var businessUnit = gr.variables.business_unit.getDisplayValue();
if (catItemName.includes("User Account") && businessUnit == "IT"){
return 'yes';
}
return 'no'; }
}
It should be more like that.if you’re having issues still add some gs.logs and check the values of cat item name and business values at different points Hope this helps.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-08-2022 04:54 PM
Thanks
Thanks for explaining that too. the knowledge will help me in future.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-08-2022 05:23 PM
Hi
No problem. Glad it's working. If you wouldn't mind could you go ahead and mark my answer as correct?
Many thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-08-2022 06:57 PM
It's just weird that if multiple catalog items were added, sometimes the workflow works and other time won't work.
Would you happen to know why?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-08-2022 07:01 PM
FYI, this if statement is on sc_request workflow.