How to check user is available or not in another developer instance

Learner10
Mega Guru

@Ankur Bawiskar 

 

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

1 ACCEPTED SOLUTION

@Learner10 

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 '';
	},

View solution in original post

10 REPLIES 10

Mark Roethof
Tera Patron

Hi there,

 

You can simply perform a GET against the sys_user table to see if the user exists What's the issue you are running into?