How to trigger a business rule when any variable within a multi row variable set changes?

Charlie Hudson
Tera Contributor

I'm trying to trigger a business rule on the sc_req_item table on the condition when any variable within a multi-row variable set changes. current.variables.changes() works fine for variables outside of MRVS but not variables inside.

I've also tried current.variables.*variablesetname*.changes() but that gives an error

Any suggestions? Thanks

1 ACCEPTED SOLUTION

@Charlie Hudson 

you cannot determine if MRVS got changed or not

you will have to take another approach

1) Create a hidden variable on your catalog item of type string

2) Set this with the value from MRVS using run script of workflow

Run script in workflow:

current.variables.<hiddenVariable> = current.variables.product_model;

current.setWorkflow(false);

current.update();

3) then use after update BR

Condition: current.variables.changes()

Script:

1) get the current value of MRVS

2) you already have the original value of MRVS in the hidden variable

3) compare both the json array and then determine if anything changed

Refer below link on how to compare 2 json array of strings

Comparing two json arrays

How to check if JSON array is equal to

Regards
Ankur

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

View solution in original post

5 REPLIES 5

Bhavana Reddy
Mega Guru

Hi,

 

Do you have the script sample for this, If so can you please share the solution with us

 

Thank you!!