scripted condition Business rule

dev_K
Tera Contributor

Hi all,

 

 

I would like to create a scripted condition that will trigger the BR when;

 

-> sc_task state changes to closed complete

and when

-> the related RITM 'item' field is 'catalog item name' (I want this BR to be triggered only for a specific catalog item)

dev_K_0-1722934431054.png

 

is this possible?

5 REPLIES 5

Jake Sadler
Kilo Sage

@dev_K this can be achieved in the condition builder.

 

JakeSadler_0-1722935646980.png

 

SN_Learn
Kilo Patron
Kilo Patron

Hi @dev_K ,

 

Yes, you can use condition builder in when to run and achieve without any code 'OR'

you can use the 'condition' field and call script include over there. In the script include you can define your conditions such as GlideRecord in the RITM table and check for item field.

 

----------------------------------------------------------------
Mark this as Helpful / Accept the Solution if this helps.

Robbie
Kilo Patron
Kilo Patron

Hi @dev_K,

 

See the below script and screen shots to achieve this.

Just holler if you need any help.

 

Tips: Change the 'Item' field to point at the Request Item you want this to apply against in the 'When to run' tab and also update the field you wish to update on line 6 of the 'Advanced' tab view and script.

 

Screenshot 2024-08-06 at 10.54.26.pngScreenshot 2024-08-06 at 10.54.34.png

 

 

(function executeRule(current, previous /*null when async*/ ) {
    var requestItem = current.getValue("request_item");
    if (JSUtil.notNil(requestItem)) {
        var parentReqItem = new GlideRecord('sc_req_item')
        if (parentReqItem.get(requestItem)) {
            parentReqItem.setValue('assigned_to', current.assigned_to); //change the parameters - fields you want to update as required. I've simply demo'ed using assigned_to
            parentReqItem.update();
        }
    }
})(current, previous);

 

 

To help others (or for me to help you more directly), please mark this response correct by clicking on Accept as Solution and/or Kudos.



Thanks, Robbie

Anand Kumar P
Giga Patron
Giga Patron

Hi @dev_K ,

 

You can use the filter condition like below.

AnandKumarP_0-1722938650281.png


Mark it as helpful and solution proposed if it serves your purpose.
Thanks,
Anand