Array Question

Derek10
Tera Expert

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.

21 REPLIES 21


I did the adjustment on line 6, is that were you implied, if so seems to be crashing still.


var gr = new GlideRecord('sc_item_option_mtom');  


workflow.scratchpad.germany = 'false';
gs.log('germ1 is   ' +workflow.scratchpad.germany);
gr.addQuery('request_item','current.sys_id');  
gr.addQuery('sc_item_option.value',true);  
gr.addQuery('sc_item_option.item_option_new.name','ENDSWITH','_germ');   // check this field name I'm not sure that is the right one  
gr.query();  
gs.log('query is ' +gr.next);
if(gr.next()){
      //run whatever code you need for route A  
workflow.scratchpad.germany = 'true';
gs.log('germ2 is   ' +workflow.scratchpad.germany);
}
gs.log('germ3 is   ' +workflow.scratchpad.germany);


Can you take a screenshot of one of the variables you're trying to match against?



In line 4 you have current.sys_id in quotes, which would make it a string.



Try it like so:


gr.addQuery('request_item',current.sys_id);   

 


It was the blasted syntax! The quotes were the culprit!