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

Kumar4999
Tera Contributor

Hi @Ankur Bawiskar,

 

Could youy please clarify this doubte if possible.

Ankur Bawiskar
Tera Patron
Tera Patron

@Kumar4999 

should work when you include this parameter in the URL i.e. REST endpoint.

sysparm_display_value=true

AnkurBawiskar_0-1669647853188.png

 

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

@Ankur Bawiskar ,

Thank you for quick response,

But my doubte is, Is there a way we can pass Display name as variable value in Payload for reference fields?

Currently it only accepting sys_id.

 

Example: 

Currently this is working - 

{
"sysparm_quantity""1",
"sysparm_requested_for":"userid",
"sysparm_no_validation""true",
"variables":
{
"test_user":"edscksacsaksaijd334b1cvdsavgasi"
}
}
 
Is there a way we can pass the Display value like below for reference fields?
 
{
"sysparm_quantity""1",
"sysparm_requested_for":"userid",
"sysparm_no_validation""true",
"variables":
{
"test_user":"Kumar 4999"
}
}

@Kumar4999 

I already told it's possible.

just include the sysparm_display=true in query parameter when you hit the endpoint

screenshot I already shared

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 ,

 

Tried that but value not inserting even after using "sysparm_display_value=true"

Kumar4999_0-1669702514266.png

Request created but user reference value not get inserted

Kumar4999_1-1669702593459.png

 

Could you please suggest any other approach or am I doing it wrongly..

 

Regards,

Kumar