In a Before Insert BR condition is not working
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-10-2022 03:53 AM
Hi,
I created a before insert BR on a sc_task table and gave a condition that item is equal to a particular catalog item.
In script section i simply wrote gs.log
but its not working.
BR is not even invoked.
Please suggest.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-10-2022 04:00 AM
Instead of adding it in codition try adding the code in the Advance condition as below
if(current.request_item.item.name=='ABC') //Replace ABC with item name
{
gs.log('in here');
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-10-2022 04:02 AM
Can you please show the script in the condition?
Use the below script
current.request_item.item == '<sys_id>' // sys_id of the catalog item
Mark correct and helpful if useful
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-10-2022 04:10 AM
Hi,
Share how are you giving the condition? screenshot etc
Also don't use gs.log() instead use gs.info();
It would be easier to use filter conditions in the BR directly
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-10-2022 05:53 AM
First 2 thinks I think of why things go wrong:
- your condition is wrong, it is missing a point a equal sign, you validating name vs sys_id or so
- order of excution. the field is not filled at the moment you run the condition.
easiest way to debug.
I am against putting the condition in the script itself and not in the condition line like
I would also place a gs.log / gs.info before the statement as well. that way you can be sure the br is running. It would look something like this:
var itemName = 'ABC' //Replace ABC with item name
gs.log('br running with item: ' + current.request_item.item.name + '\nExpecting if should be: ' + (current.request_item.item.name == itemName));
if(current.request_item.item.name == itemName){
gs.log('br in if statement');
}
this should give you a log even if the condition is wrong. This will tell you that the br does run. Not that it is inactive or so.
Second it will give you what it expects from the if statement.
Third it will tell you if it gets into the if statement.
If this is not telling you what goes wrong then let us know the what the log statement are, then we can go from there