- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-26-2023 09:42 AM - edited 07-26-2023 09:43 AM
Hello Community,
We are just creating incident from one developer instance to other developer instance through rest API post method and we are looking for the logic to check if source instance caller is available or not in the target instance if available caller should go to target instance caller field else it should be guest user.it would be great if anyone provide solution for this??
Thanks,
Learner
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-01-2023 05:55 AM
update the function as this
checkCaller: function() {
var request1 = new sn_ws.RESTMessageV2();
request1.setEndpoint('sysuser table endpoint' + current.caller_id);
request1.setHttpMethod('GET');
//Eg. UserName="admin", Password="admin" for this code sample.
var user = 'admin';
var password = 'admin';
request.setBasicAuth(user, password);
request.setRequestHeader("Accept", "application/json");
var response = request1.execute();
gs.log(response.getBody());
var httpCode = response.getStatusCode();
if(httpCode == 200)
return current.caller_id;
else
return '';
},
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-03-2023 09:52 PM - edited 08-03-2023 09:53 PM
Hello Ankur,
We had one issue identified. If the sys_id matches between the instances and it's populating the caller information from one developer instance to other instance successfully if not it's not populating anything do we have any other way to compare the source instance caller_id.name in target instance instead of sys_id ?
Let us know in case of separate post need to be post to help on this?
Thanks,
Learner
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-03-2023 10:45 PM
you need to decide which caller you need to populate if record not found.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-03-2023 11:32 PM
Do we have any solution to compare the users between the instance using user name instead of sys_id??
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-04-2023 12:00 AM
you can use user_name in GET instead of sys_id and you need to use sysparm_query
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-04-2023 02:21 AM
we have tried to build the end point but in the rest API explorer it's asking the sys_id also could you please help with the end point syntax that would be very helpful