Interested in a ServiceNow event built for developers? Registration for now[dev]26 is officially open!

Mapping variables from catalog item to Requested item

FaizDev101
Tera Expert
  1. Created a variable named "priority" in catalog item as type (Select box)
  2. Added choices as High, medium and low with values 1, 2 and 3.

 

When submit the catalog item form with  priority choice according the value, Requested item (sc_req_item) "priority" field should change. How can I implement that ?

 

(Catalog item priority field)

FaizDev101_3-1681723013850.png

 

(Requested item priority field)

FaizDev101_0-1681722886906.png

 

 

(Note: The "priority" field in Requested item (sc_req_item) is not read only)

1 ACCEPTED SOLUTION

Upsilon
Giga Guru

Hello, 

You can use a BR (On create) to update and map cat_item priorities with sc_requested_item. Idealy you can use the same values for both and hide options that you don't need

Upsilon_0-1681724002250.png

 

(function executeRule(current, previous /*null when async*/ ) {
	// If cat_item choices == sc_req_item choices
current.priority= current.variables.priority;
	//else If cat_item choices != sc_req_item choices
var	priority_map={"high": 1,"low": 5};
	
	current.priority= priority_map[current.variables.priority];
		

})(current, previous);

 

Regards,

 

View solution in original post

6 REPLIES 6

@FaizDev101 

Thank you for marking my response as helpful.

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

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

@FaizDev101 

I believe I too answered your question by sharing multiple approaches.

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

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