Populate the requested for catalog item variable

Aditya37
Tera Contributor

Hello Community,

I would like assistance with populating the request.requested_for field using the custom variable named requested_for.

In the catalog item, we have created a custom variable named requested_for. When we submit the request, the "requested for" is correctly set in both the request and the RITM.

Now, we want to display the value of the requested_for in our custom variable.

Please refer to the below screen shot.

 

Aditya37_2-1701675328188.png

 

Thank you.

 

 

8 REPLIES 8

@Aditya37 

you can directly use Update Record action and set the field value

Table - sc_request

Field:

Requested For ->

AnkurBawiskar_0-1701685596997.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

@Ankur Bawiskar 

We have checked using the above step but it still its not working. We check request level Flows, BR, Scripts also.

 

Is it good way to write BR in RITM table?

Thanks!

@Aditya37 

It should work ideally using Flow. please share step screenshot

OR

you can use after insert BR on RITM table

Condition: current.cat_item.name == 'Your Catalog Item Name Here'

Script:

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

	// Add your code here
	var req = current.request.getRefRecord();
	req.requested_for = current.variables.requested_for;
	req.update();

})(current, previous);

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

Dr Atul G- LNG
Tera Patron
Tera Patron

Hi @Aditya37 

 

As suggested by expert @Ankur Bawiskar  OOTB requested for set as logged in user and in case you want to populate the  custom requested for, you need to write the code. 

*************************************************************************************************************
If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.

Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/atul_grover_lng [ Connect for 1-1 Session]

****************************************************************************************************************