Update RITM watch list from catalog item variable

rachelconstanti
Mega Sage

Looking for help on how to update the the RITM watch list from values from 2 variables on that Catalog Item.

How best to accomplish this?

Thank you.

Rachel

1 ACCEPTED SOLUTION

@rachelconstanti 

then combine both the scripts in your 1 business rule and delete the other one

updated script for both

(function executeRule(current, previous) {

    var list = [];
	
    if (current.variables.primary_program_poc)
        list.push(current.variables.primary_program_poc.toString());

    if (current.variables.secondary_program_poc)
        list.push(current.variables.secondary_program_poc.toString());

    if (current.variables.requested_for)
        list.push(current.variables.requested_for.toString());

    if (list.length > 0) {
        current.watch_list = list.join(',');
        current.setWorkflow(false);
        current.update();
    }

})(current, previous);

💡 If my response helped, please mark it as correct and close the thread 🔒— this helps future readers find the solution faster! 🙏

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

View solution in original post

16 REPLIES 16

SailakshmiR
Tera Contributor

Hi Rachana, 

 

Can you be more specific on the use ?

 

We have a need to update the watch list on one catalog item based on the values of two variables on that catalog item once it has been submitted.

The two variables are a Primary POC and a Secondary POC.  We need these folks to receive all the notifications on that RITM - watch list seems to be the best option for this.  

Just trying to automate the process for the folks working on this request.

aruncr0122
Mega Guru

Hi @rachelconstanti ,

 

You can update the RITM watch list from catalog item variables using a Flow Designer action or Business Rule on the Requested Item (sc_req_item) table.

Option 1: Flow Designer (no-code)

Create a Flow with trigger: Service Catalog → Requested Item → Created.

Add an Action → Update Record (sc_req_item).

Set Watch list to include the variables.

Option 2: Business Rule (scripted)

Create an After Insert BR on sc_req_item:

(function executeRule(current, previous) {
var list = [];
if (current.variables.var1)
list.push(current.variables.var1);
if (current.variables.var2)
list.push(current.variables.var2);

if (list.length > 0)
current.watch_list = list.join(',');
})(current, previous);

 

Thanks

Thank you for the business rule however this is not working

This is the advanced script:

 

(function executeRule(current, previous) {
var list = [];
if (current.variables.primary_program_poc)
list.push(current.primary_program_poc);
if (current.variables.secondary_program_poc)
list.push(current.secondary_program_poc);
if (list.length > 0)
current.watch_list = list.join(',');
})(current, previous);