Array Question

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-02-2016 05:04 AM
I have a scenario, where I have 30 variables and 3 outcomes.
I'm trying to find the best way to make this as dynamic as possible. They are all check boxes. Basically I'll be looking at 1-15 if any are true, do this, 16-30 if any are true do that, if none are true, go here.
Doing a run script as a switch because multiple outcomes can happen concurrently.
I could use abit of help with the syntax. I looked up the arrayutil in the wiki which I think will help as it does the contains option. ArrayUtil - ServiceNow Wiki
But i'm not sure how to setup the array using vars and telling it to search through all 15 at a time. I'm assuming I manually have to enter them into the array.
Any thoughts out there? This is on the workflow side for clarity.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-03-2016 06:48 AM
Change gr.addQuery('sc_item_option.question','endsWith()','_germ'); to:
gr.addQuery('sc_item_option.question','ENDSWITH','_germ');
The middle parameter is an operator not a function so it doesn't need the parenthesis. If that doesn't work, make sure the sc_item_option.question field is the one you are looking for.
As for your P.S. you can click the "Use advanced editor" link in the top right corner of the Reply box. That will give you some more formatting options for your posts. The last icon on the bottom row is >>. If you click that it will pop up a menu that has Syntax Highlighting. Under there you can choose the type of syntax highlighting you want to use. For these posts I normally choose javascript. I have noticed that some browsers have trouble editing the text once you have applied the formatting. So I generally type out the text, highlight the code and then choose the formatting option just before posting the reply.
-Steve

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-03-2016 08:17 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-03-2016 08:31 AM
You are checking for "sc_item_option.question" but what you need to check for is "sc_item_option.item_option_new.name" if I'm understanding correctly.
To recap, you want to show only options whose dependent item's question name ends in "_germ", correct?
Note: the question field column name is "item_option_new", not "question". It's also a reference field, so comparing that would be against a sys_id anyway. I get in the habit of right clicking on the field labels to get the column name.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-03-2016 08:34 AM
To answer your question on the recap, yes
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-03-2016 08:36 AM
Okay, so then changing the field you're querying to "sc_item_option.item_option_new.name" should be the next step.