- 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
07-26-2023 08:40 PM
so before consuming the actual endpoint you can search in the target instance with that user name in sys_user table
Based on response of that API you can handle your next part.
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-31-2023 05:37 AM
We awere able to verify the user through get method and facing issue to pass that value in target instance.Could you please let me know how to pass that value in the record
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-31-2023 05:39 AM
you can send sysId of that user
What's the challenge?
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-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