How to clear the user field through rest api
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-24-2023 01:21 AM - edited ‎07-24-2023 01:21 AM
Hello Community,
we are creating the incident record one instance to another instance with few details from instance a to instance b through rest api post method and we are facing one issue with caller.we required logic to check the caller in instance a is available or not in instance b if not caller field should be empty other wise instance a caller should copy from instance a to instance b.
Thanks,
Steve An

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-24-2023 01:27 AM
Hello @Steveanner ,
you can try as below
// Your code to create the incident record in Instance B using the REST API
................
// Assuming you have retrieved the caller information from Instance A and stored it in a variable
var callerInfoFromInstanceA = {
sys_id: "caller_sys_id_instance_a",
name: "John Doe",
email: "john.doe@example.com"
};
// Check if the caller exists in Instance B based on the unique identifier (here, using email as the identifier)
var callerEmailFromInstanceA = callerInfoFromInstanceA.email;
var callerSysIDFromInstanceB = ""; // Variable to store the sys_id of the caller from Instance B
// Query the user table in Instance B to find the caller using the unique identifier (email)
var userFromInstanceB = new GlideRecord('sys_user');
userFromInstanceB.addQuery('email', callerEmailFromInstanceA);
userFromInstanceB.query();
// If the caller exists in Instance B, set the caller_sys_id_from_instance_b variable
if (userFromInstanceB.next()) {
callerSysIDFromInstanceB = userFromInstanceB.sys_id;
}
// Now, create the incident record in Instance B using the callerSysIDFromInstanceB value
var incidentDataForInstanceB = {
short_description: "Incident created from Instance A",
description: "Description of the incident",
caller_id: callerSysIDFromInstanceB // Set the caller field to the sys_id from Instance B (if found) or an empty value (if not found)
};
// Your code to send the incidentDataForInstanceB using the REST API to create the incident record in Instance B
// ...
Kindly mark correct and helpful if Applicable
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-24-2023 02:43 AM - edited ‎07-24-2023 02:44 AM
We are not retrieving the data we are creating incident from one instance to other instance through rest api post method integration
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-24-2023 01:47 AM
Hi Steve,
Thanks for posting your query.
Before we answer with an effective solution, we need to know how are you creating the incident through this integration:
- Is it a transform map ?
- Scripted Rest ?
- Any other ?
Thanks,
Arnab
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-26-2023 05:33 AM
Hello Arnab,
Through rest api post method we are checking on this??
Thanks,
Steve An