How to get sys_id of request item created from catalog item in an onsubmit catalog client script

ritaaudi
Tera Contributor

Hi: Anyone know how to get the sys_id of the request item created in an onSubmit catalog client script?

I tried :g_form.getUniqueValue();

but that gives me the sys_id of the catalog item not request item created from it.

Thank you!

7 REPLIES 7

Hi ritaaudi

 

May I know what are you trying to achieve? You won't be able to get this using catalog client script as you do not have the created request at this level. You could however access the sys_id via a business rule, set a scratch pad and access the scratch pad at the record level using client script. The below article should help:

 

https://docs.servicenow.com/bundle/london-application-development/page/script/business-rules/concept...

ritaaudi
Tera Contributor

OK, here's my problem: I have a business rule that updates the request.requested_for with the current.variables.requested_for on the request item upon insert and update. The problem is that there is something that is updating the request.requested_for to the opened by. So when I submit my catalog item, the request item form that loads displays the requested for as the opened by and the user has to refresh to see the right value from my business rule. How can I get the request.requested upon insert to have the current.variables.requested_for value?

Thank you again.

reginabautista
Kilo Sage

You would need to find the code that is overriding your BR. In the BR table, try to bring out the "script" column then search for the opened_by field. Search for your table also to further narrow down the result. Once you see the record, review the code and comment out the line that is setting the requested for to opened_by

find_real_file.png