Integration REST Message to match users

Peter Przenniac
Tera Expert

Trying to match user from instance 1 on instance 2 where unique field is email address, and capture sys_id of this user, so incident can be created on instance 2 with matched user:

try {
        var r = new sn_ws.RESTMessageV2('V1 Integration', 'Post Incident');
       
        var target = new GlideRecord('sys_user');
        target.addQuery('u_on_behalf_of.email', current.requested_for.email);
        target.query();
        if (target.next()) {
        current.requested_for = target.sys_id;
}
        var body = {
        "variables": {
            "u_on_behalf_of": current.requested_for,
            "category": "application",
            "subcategory": "data_incorrect",
            "cmdb_ci": "123454",
            "comments": current.getValue('description')
        }
    };
1 ACCEPTED SOLUTION

Peter Przenniac
Tera Expert

Found solution - I replaced user email address '@' with '%40' and added to URL endpoint (get method), so could query sys_user table to find user by email in Instance 2, in response body I captured user sys_id and parse in Instance 1, then I could create INC record from instance1 to instance2 with correct sys_id.

By steps:

1. create GET method - with api table to sys_user endpoint

2. create POST method with captured data to create INC's - with record producer endpoint

3. create PUT method to update INC's - with incident table endpoint

View solution in original post

6 REPLIES 6

Mathieu Lepoutr
Mega Guru

Hi Peter

 

To create an incident on the destination instance where some scripting logic is applied, I suggest looking Exalate, which is a decentralized integration solution, where you can granuarly decide which data will be send over.

 

You have to install it on both sides, but trust me, you will see the level of configuration you can do. Reach out to Exalate for a demonstration!

Peter Przenniac
Tera Expert

Found solution - I replaced user email address '@' with '%40' and added to URL endpoint (get method), so could query sys_user table to find user by email in Instance 2, in response body I captured user sys_id and parse in Instance 1, then I could create INC record from instance1 to instance2 with correct sys_id.

By steps:

1. create GET method - with api table to sys_user endpoint

2. create POST method with captured data to create INC's - with record producer endpoint

3. create PUT method to update INC's - with incident table endpoint