Built something you're proud of? Tell the story. A quick G2 review of App Engine or Build Agent helps other developers see what's possible on ServiceNow. Share your experience.

Business rule using contains in condition

sigmachiuta
Kilo Guru

how can i use contains in the 'condition' of a BR?   Or use contains in my if statement?   The below syntax does not work

if(curent.name, 'CONTAINS', 'foo=bar'){

//do something

}

1 ACCEPTED SOLUTION

kristenankeny
Tera Guru

I've done something like this:



str = current.comments;


  var pos = str.search('Update from Request Item');



  if(pos == -1){


  gs.info('The push from Task to RITM will trigger now: ' + current.comments);


  var gr = new GlideRecord('sc_req_item');


  gr.get(current.request_item);


  gr.comments = 'Update from Task "' + current.short_description + '": ' + current.comments;


  gr.update();


  }



In your case, I would say != -1, to indicate it found your string.


View solution in original post

2 REPLIES 2

kristenankeny
Tera Guru

I've done something like this:



str = current.comments;


  var pos = str.search('Update from Request Item');



  if(pos == -1){


  gs.info('The push from Task to RITM will trigger now: ' + current.comments);


  var gr = new GlideRecord('sc_req_item');


  gr.get(current.request_item);


  gr.comments = 'Update from Task "' + current.short_description + '": ' + current.comments;


  gr.update();


  }



In your case, I would say != -1, to indicate it found your string.


Thank you!