Business Rule Script help, Please

Gemma4
Mega Sage

Hello,

The good news is I have everything almost working but I am having trouble with my business rule script. Here is a summary of my progress and the script details. 

I created a configuration item called ProjectManagement

I created a variable called configuration item and set the default value to the sys id

This part enabled the configuration to be added(hidden)on the catalog item

I then created a business rule to copy the variable configuration to the Request field called configuration item. So far all of the above has worked as expected. 

Then I created a business rule to set the request state to New if the configuration item is Project management. This last  part isn't working and changing the state. I set the table to Request, when to run is after, filter confidition is Configuration item changes to ProjectManagement. 

 

Anyone have any ideas why? 

 

 

//(function executeRule(current, previous /*null when async*/) {
 
// Add your code here
//var gr= new GlideRecord("sc_req_item");
//gr.addQuery('request', current.sys_id);
////gr.addQuery('cat_item','52a1fd631b47215053545243604bcb35');
// //gr.addQuery('cat_item','7c3fbb0b97c321102ab77d100153af5b'); project catalog
// gr.addQuery('cmdb_ci','98ebee741ba4711053545243604bcb74'); //project cmdb value
gr.query();
//if(gr.next()){
//current.request_state= 'New';
//// grRequestItems.state = 10; // "Stopped" state change if required
// }
 
 
//})(current, previous);
 
 
 
(function executeRule(current, previous /*null when async*/) {
 
var req = new GlideRcord('sc_request');
req.addQuery('sys_id', current.request);
req.query();
while (req.next()) {
req.request_state = 'New';
req.update();
}
})(current, previous);
6 REPLIES 6

Abhay Kumar1
Giga Sage

@Gemma4 I can guide you to check whether your BR script works or not.

Take a record and use background script to change a state and  first checke if it works there.

If working then verify if any other BR rules with diffrent order interrupt.

Hope this will help you.

Hi @Abhay Kumar1 

That sounds like a good idea. Do you have an example of what I should include in that background script? 

Aman Kumar S
Kilo Patron

Hi @Gemma4 ,

Can you show the filter condition how is it set?

Also, I believe OOB you don't have New state for Request table, check if you have created one.

 

 

Best Regards
Aman Kumar

Hi everyone,

 I corrected the typo @Chetan Mahajan suggested but unfortunately still no luck. That was a good catch though, thanks. 

Attached is the when to run and filter condition. Thanks so much for all the feedback!! Please let me know if you have any other recommendations, I need to provide an update this morning to the business. 😩

BRScript.pngbr when.png