addEncodedQuery does not work in business rule..
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-03-2015 02:18 AM
I wanted to change risk from 'none' or 'empty' to 'Low' in change request module.I did it with this code for background script..
var querystring = "risk=5^ORrisk=";
var gr = new GlideRecord('change_request');
gr.addEncodedQuery(querystring);
gr.query();
while(gr.next())
{
gr.setWorkflow(false);
gr.setDisplayValue('risk','4');
gr.update();
}
and it worked..
now while writing it in business rule with when to run option selected as 'before insert or update' and in script I wrote
var querystring = "risk=5^ORrisk=";
var gr = new GlideRecord('change_request');
gr.addEncodedQuery(querystring);
gr.query();
while(gr.next())
{
gr.setDisplayValue('risk','4');
gr.update();
}
but it didn't work out..however I kept it simple and wrote..
if(current.risk == '5' || current.risk =='')
current.risk=4;
and it worked...
Does addEncodedQuery work in business rule or not?????

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-04-2015 02:28 AM
If that helped you then please mark the answer as correct
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-03-2015 03:06 AM
Change the while from:
while(gr.next())
{
gr.setDisplayValue('risk','4');
gr.update();
}
to:
while(gr.next())
{
gr.risk = 4;
gr.update();
}
Regards,
Sergiu
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-04-2015 02:22 AM
Hi Sergiu,
Thank you..