Reference field is not working while inbound call called
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-27-2023 04:45 AM
Hi All,
I am working on one of the integration and it is inbound call from 3rd party to ServiceNow and RITM will create in ServiceNow.
This is payload I tested in post man and once the 3rd pary system update the data, RITM will create in the servicenow
{
"sysparm_quantity": 1,
"variables": {
"requested_for": "Vinuth",
"contact_phone_number": "9591655",
"please_select_priority_level": "P5",
"is_this_an_account_creation_request": "Yes",
"short_description": " Test f",
"please_provide_a_description_of_the_request_application_name_for_account_creation": "Apple iPhone",
"please_provide_a_list_of_users_that_require_an_account": "TEST"
}
}
Facing the issue : Here I am using requested_for as reference field, once the RITM created in the servicenow and requested for field is showing blank. If I use the single line text type for "requested_for" field then it's working fine.
Please any one suggest me, How to proceed using reference field.
Thanks in advanced,
Vinuth

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-27-2023 04:52 AM
@vinuth v requested_for is a reference field and it expects a 32 character sys_id (e.g. e005e481530020107d13ddeeff7b12e5). In your case you are passing it a string value for which the field may not find a match.
In order to populate the reference field, I recommend you use a glide record query as follows to get the sys_id of the user from the user table.
var userRec = new GlideRecord('sys_user');
var userSys_id='';
userRec.addEncodedQuery('nameSTARTSWITH'+requested_for);//replace with your requested for variable
userRec.query()
if(userRec.next()){
userSys_id=userRec.getValue('sys_id');
}
//Now you can use the userSys_id field to populate requested_for field on your record.
Hope this helps.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-27-2023 05:03 AM
Hi @Sandeep Rajput ,
Can you please suggest me exactly where I need to use this script.
Thanks,
Vinuth
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-27-2023 04:56 AM
Hello vinuth,
For reference field, you should use sys_id as string in the value when you are composing the payload, i've tested this on rest API explorer and worked:
{
"short_description" : "test API explorer",
"caller_id" : "46d44a23a9fe19810012d100cca80666"
}
With a PUT method, this will update short description and caller field, that sys_id it's from sys_user table.
☆ Community Rising Star 22, 23 & 24 ☆