Can we pass display value for reference variable while submitting request via OOB API

Kumar4999
Tera Contributor

Currently while submitting the service catalog request using OOB API, When I am passing the sys_id in Reference type of variable the value is taking in the requst as expected.

But if we pass the display value reference field is taking as empty, is there a way we can use Display value in Reference type of variable while submitting the Service Catalog Request via SR OOb API?

 

API: /api/sn_sc/servicecatalog/items/{sys_id}/order_now

 

Example: If I like to select a user in reference filed which referred to User table. Is there a way I can pass the user id or Display name instead of user sys_id while ordering the catalog item similar to table APIs?

 

{
"sysparm_quantity""1",
"sysparm_requested_for":"userid",
"sysparm_no_validation""true",
"variables":
{
"test_user":"edscksacsaksaijd334b1cvdsavgasi"
}
}
12 REPLIES 12

RaghavSh
Kilo Patron

Reference fields accepts the sys_id of the table they refer to? what use case do you have where you want to pass the

display value? Also display value of user table is name and two users can have same name, that would be confusing for the system.

 

Foe userid, there doesnt seems to be a way to pass the userid in the reference field. When we try to select user manually, we do have an option to search via userid using variable attributes, but not through REST.
Please mark the answer correct/helpful accordingly. 


Raghav
MVP 2023

Hi @RaghavSh,

 

Thank you for your reply,

 

I am not specific to user table, I mean for any Reference type of field.

 

For Table APIs I am able to insert the value by passing Display value of the Reference value I need to select. Sys_id is anyway we can use it.

 

But here my consern is - I want to use Display value in the reference variables while submitting service catalog request - which is not a Table API but a scripted API by default in Servicenow.

Currently the values are getting inserted in Service Request only if I pass sys_id of reference value but not the display value like Table APIs.

Table APIs give us that option OOB, I dont think we have that option in other scripted APIs


Raghav
MVP 2023

This API : API: /api/sn_sc/servicecatalog/items/{sys_id}/order_now

it is also OOB but not just taking the Display value for reference fields.

 

Need to know if there is a way.