How to update specific RITM field with value from catalog item

Susan Goh
Tera Contributor

Hi, 

 

I have created a new catalog item where one of the variable items is mandatory (Select CI - referencing from cmdb_ci) whenever a user is raising the catalog.

 

When the catalog is submitted, I would require the field "Affected CI" in the RITM to be updated as per the value selected when submitted, i.e Select CI and subsequently the same value also to be updated in the same field value "Affected CI" available in the catalog task.

 

I have created two Business rules indicating the above requirements but after testing the value for the Affected CI field (in both RITM and Catalog Task) are still showing up as empty. Not too sure if anything wrong in the business rules script. 

 

This is my Business Rules for both update of Affected CI in RITM and Catalog Task:

RITM Insert

SusanGoh_0-1748228323518.png

Catalog Task:

SusanGoh_1-1748229024743.png

 

 

These are the value i need updated to my RITM and Catalog Task "Affected CI" fields respectively.

 

SusanGoh_2-1748229065068.png

 

SusanGoh_3-1748229096584.pngSusanGoh_4-1748229162227.png

 

Appreciate your kind inputs. Thank you

3 ACCEPTED SOLUTIONS

Swapna Abburi
Mega Sage
Mega Sage

Hi @Susan Goh 

Are these scripts written in business rules? Usually if it is an insert business rule, the function block should look as below.

(function executeRule(current, previous /*null when async*/) {

    // Add your code here

})(current, previous);

View solution in original post

Ankur Bawiskar
Tera Patron
Tera Patron

@Susan Goh 

are you using flow for your catalog item?

Then it's very easy

1) use "Get Catalog Variables" Flow action

2) then use "Update Record" flow action and update the field by selecting the correct variable from data pill

AnkurBawiskar_0-1748230995698.png

 

3) Then while creating catalog task use Set Field Values and set the value

AnkurBawiskar_1-1748231027426.png

 

If my response helped please mark it correct and close the thread so that it benefits future readers.

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

View solution in original post

Robert H
Mega Sage

Hello @Susan Goh ,

 

Do you require this logic for all existing Catalog Items? If not then a Business Rule is not the appropriate solution.

Instead, populate the Configuration Item field using the Workflow or Flow that is associated with this particular Catalog Item.

 

If using a Workflow you just need to add a "Run Script" activity at the beginning, with the following line:

current.configuration_item = current.variables.select_CI;

 

And for the task you would add this script to the "Catalog Task" activity:

task.cmdb_ci = current.configuration_item;

 

If you are using a Flow then use the steps mentioned by @Ankur Bawiskar .

 

Please also make sure you are looking at the correct field, since a RITM has two CMDB reference fields (configuration_item, cmdb_ci), and it's the former that is shown on the RITM form by default, while your BR is populating the latter. I used configuration_item in the above scripts.

 

If you really need Business Rules then update the function surrounding your script to this:

(function executeRule(current, previous /*null when async*/) {

	// Add your code here

})(current, previous);

The functions in your current scripts has an invalid signature, especially the latter which rather looks like something used in a Flow Designer Script step.

Please also make sure it's a "before insert" Business Rule, and do not use "current.update()".

 

Regards,

Robert

View solution in original post

6 REPLIES 6

Swapna Abburi
Mega Sage
Mega Sage

Hi @Susan Goh 

Are these scripts written in business rules? Usually if it is an insert business rule, the function block should look as below.

(function executeRule(current, previous /*null when async*/) {

    // Add your code here

})(current, previous);

Ahh... no wonder, how silly of me. overlooked that portion. Have managed to get it sorted and its reflecting correctly now. Thanks alot for the insight and enlightenment.

Ankur Bawiskar
Tera Patron
Tera Patron

@Susan Goh 

are you using flow for your catalog item?

Then it's very easy

1) use "Get Catalog Variables" Flow action

2) then use "Update Record" flow action and update the field by selecting the correct variable from data pill

AnkurBawiskar_0-1748230995698.png

 

3) Then while creating catalog task use Set Field Values and set the value

AnkurBawiskar_1-1748231027426.png

 

If my response helped please mark it correct and close the thread so that it benefits future readers.

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

Thanks Ankur for the suggestion. Unfortunately was advised against doing any kind of amendment on the existing flow design for our orgs catalog using flow designer or action in anyway. Hence, opted for the Business Rules script option. But will definitely keep this suggestion in mind for future. I learnt something new as well. Thank you so much. My current issue has been sorted.