Announcing the SAVIYNT KNOWLEDGE EXCHANGE unifying the Saviynt forums, documentation, training, and more in a single search tool across platforms. Click HERE to read the Announcement.

Assignment of constant values in variable colsToPropsMap of rest connector

sampath18
Regular Contributor II
Regular Contributor II

Hi All,

I wanted to check that in rest connector while importing accounts into EIC we would map the required attributes from EIC to Target Application attribbutes. but we have one use case where we are doing multi calls for servicenow import accounts.  there are two calls call 1 and call2.

In call1 we are getting users details which includes username and accountid, but in call2 we do not get username and accountid in the response, so how to use call1 response attributes in call2  for the variable colsToPropsMap . in call2 we have extra user information which we need to map to same account object in EIC

Another thing in colsToPropsMap , can we assign constant value to EIC attribute 

E.g:

"colsToPropsMap" :{

EICAttribte : X value(constant)

}

 

 

25 REPLIES 25

rushikeshvartak
All-Star
All-Star

#CONST is used for constant 

 

  "sox_critical": "#CONST#4~#~char",

rushikeshvartak_0-1681991256439.png

 


Regards,
Rushikesh Vartak
If you find the response useful, kindly consider selecting Accept As Solution and clicking on the kudos button.

rushikeshvartak
All-Star
All-Star

For response in call2

call1.response.id


Regards,
Rushikesh Vartak
If you find the response useful, kindly consider selecting Accept As Solution and clicking on the kudos button.

sampath18
Regular Contributor II
Regular Contributor II

Thanks @marc_rushi 

is it possible to use call1 responses in call 2 colsTopropsMap like below.

"colsToPropsMap":{
"accountID":"${call1.response.sys_id}~#~char",
"CUSTOMPROPERTY8":"asset_tag~#~char"

}

can you tell me is there a synatx we need to follow for this. because above way it is not working.

So keen to know if there is a way to do it.

Thanks
Sampath

sampath18
Regular Contributor II
Regular Contributor II

Hi @rushikeshvartak 

call1 response in not getting passed to call2  when with below response paths.

${response.call1.message.result.sys_id}

${response.call1.message.sys_id}

${call1.response.sys_id}

It is giving error as NullResponseFromTarget . But at the same hardcoded value is working. So can you assist what is going wrong here.

 

"http":{
"url":"https://dev.service-now.com/api/now/table/alm_hardware?sysparm_query=install_status%3D1%5Eassigned_t...}",
"httpMethod":"GET",
"httpParams":"{\"sysparm_display_value\":\"true\",\"sysparm_fields\":\"serial_number%2Casset_tag%2Cmodel%2Cinstall_status%2Cassigned_to\"}",
"httpHeaders":{
"Authorization":"Basic ########"
"Accept":"application/json"
},

 

Also pasting the full JSOn for reference.

{
"accountParams":{
"connection":"userAuth",
"processingType":"SequentialAndIterative",
"call":{
"call1":{
"callOrder":0,
"stageNumber":0,
"http":{
"url":"https://odev.service-now.com/api/now/table/sys_user?user_name=56607&sysparm_fields=first_name,last_n...",
"httpMethod":"GET",
"httpParams":"{\"sysparm_display_value\":\"true\"}",
"httpHeaders":{
"Authorization":"Basic #######"
},
"httpContentType":"application/json"
},
"statusConfig":{
"active":"true",
"inactive":"false"
},
"listField":"result",
"keyField":"accountID",
"colsToPropsMap":{
"customproperty1":"employee_number~#~char",
"CUSTOMPROPERTY2":"last_name~#~char",
"customproperty3":"name~#~char",
"CUSTOMPROPERTY4":"first_name~#~char",
"CUSTOMPROPERTY7":"email~#~char",
"name":"user_name~#~char",
"accountID":"sys_id~#~char"
},
"pagination":{
"nextUrl":{
"nextUrlPath":"${headers?.Link?.split(';')?.size()==5?headers?.Link?.split(';')[2]?.replace('rel=\"prev\",<', '')?.replace('>','')?.trim():headers?.Link?.split(';')?.size()==4 && headers?.Link?.split(';')[2].contains('rel=\"next\",<')?headers?.Link?.split(';')[1]?.replace('rel=\"first\",<', '')?.replace('>','')?.trim():null}"
}
}
},
"call2":{
"callOrder":1,
"stageNumber":1,
"connection":"userAuth",
"http":{
"url":"https://dev.service-now.com/api/now/table/alm_hardware?sysparm_query=install_status%3D1%5Eassigned_t...}",
"httpMethod":"GET",
"httpParams":"{\"sysparm_display_value\":\"true\",\"sysparm_fields\":\"serial_number%2Casset_tag%2Cmodel%2Cinstall_status%2Cassigned_to\"}",
"httpHeaders":{
"Authorization":"Basic ########",
"Accept":"application/json"
},
"httpContentType":"application/json"
},
"inputParams":{
"dependentCall":true
},
"listField":"result",
"keyField":"accountID",
"nextApiKeyField":"accountID",
"colsToPropsMap":{
"name": "${call1.response.user_name}~#~char",
"accountID":"${call1.response.sys_id}~#~char",
"CUSTOMPROPERTY8":"asset_tag~#~char"
}
}
}
}
}

Thanks

SB
Saviynt Employee
Saviynt Employee

The colsToPropsMap is used to map the target application attributes with Saviynt. Since you have already mapped name and accountID in your Call1, you would not need to map them again. The value for these attributes will be saved in Saviynt as part of Call1.


Regards,
Sahil

sampath18
Regular Contributor II
Regular Contributor II

Hi @SB  Yes, we have mapped name and accountID attributes in call1. But in call2 we have few more attributes to map to complete the usecase. So how to achieve mapping of call2 additional attributes to same accountID in saviynt. This is where it is not clear.

In our usecase we are importing accounts from service now but while importing we have to look for additional attributes and we are getting them in call2. So end result should be all attributes from call1 and call2 assigned into Account in EIC.

Hope i am clear with my requirement.

Thanks

Sampath

SB
Saviynt Employee
Saviynt Employee

The logic for mapping of 2nd call will also work similar to Call1. There needs to be a unique identifier (sys_id) in the call2 response to configure listfield and keyfield value. Based on these value you can map the additional attributes.

 


Regards,
Sahil

sampath18
Regular Contributor II
Regular Contributor II

But unfortunately the call2 is not returning the same sys_id of call1. That's where the complexity.

So the call2 is returning other unique fields which are not present in call1. Hence i wanted to check if there is a way to use call1 returned attributes in call2 colsTopropMap.

Thanks

SB
Saviynt Employee
Saviynt Employee

Is there any unique identifier common between call1 and call2. I believe there should be else there would not be a way to know which values belong to which account. So using response from call1 will not work as an identifier to know which value belongs to which account.


Regards,
Sahil

sampath18
Regular Contributor II
Regular Contributor II

yes, there is no direct common attributes between call1 and call2. But in call2 we get a link attribute which contains the sys_id in it , but unable to use that in colsToPropMap.

Below are the call1 and call2 responses

call1 
 
{
    "result": [
        {
            "sys_id""809b4d651bb27c5082f7a686624bcb3e",
            "user_name""56***",
            "last_name""aaddakb",
            "first_name""addxdad",
            "email""user@domain.com"
        }
    ]
}
using call 1 returned sys_id call 2 is invoked
{
    "result": [
        {
            "asset_tag""B$$$$$",
            "install_status""In use",
            "serial_number""R$$$N5",
            "model": {
                "display_value""Lenovo ThinkPad X1 Yoga 3rd",
            },
            "assigned_to": {
                "display_value""ajaf ahduahf",
                "link""https://dev.service-now.com/api/now/table/sys_user/809b4d651bb27c5082f7a686624bcb3e"
            }
        }
    ]
}

SB
Saviynt Employee
Saviynt Employee

Does this mean that call2 will be executed for each user individually?


Regards,
Sahil

sampath18
Regular Contributor II
Regular Contributor II

Hi @SB  yes, call2 is dependent call for call1. so it has to execute for each user based on call1 response.

 

SB
Saviynt Employee
Saviynt Employee

@sampath18 Can you try with the below colsToPropsMap for call2 and see if it works.

"colsToPropsMap":{
"accountID": "#CONST#${String acctId = assigned_to.link; acctId = acctId.replace('https://dev.service-now.com/api/now/table/sys_user/', ''); return acctId}~#~char",
"CUSTOMPROPERTY8":"asset_tag~#~char"

Please also update ConfigJSON param in the REST connection with value {"showLogs":true} if not done already before running the job. I would recommend if you could run the import for only 1 user so we have less data in logs to troubleshoot further; if needed.


Regards,
Sahil

sampath18
Regular Contributor II
Regular Contributor II

Hi @SB 

Above solution did not work. when executed with above logic it created new account with accountID attribute as "${String acctId = assigned_to.link; acctId = acctId.replace('https://dev.service-now.com/api/now/table/sys_user/', ''); return acctId}"

This what i tried earlier also, but saviynt not resolving the code under colstoPropsMap. is there any syntax we need to be following? when we do not have direct attribute data coming from target application. Like in this case.

Thanks

sampath18
Regular Contributor II
Regular Contributor II

Please find the logs for the same.

sampath18
Regular Contributor II
Regular Contributor II

Hi @SB & @rushikeshvartak 

can you guys help in how to pass the call1 response to call2. i have to pass sys_id of call1 response to call2 url

"url":"https://baincodev.service-now.com/api/now/table/alm_hardware?sysparm_query=install_status%3D1%5Eassi...}"

i have tried follow response paths but none of them are working

${response.call1.message.result.sys_id}

${response.call1.message.sys_id}

${call1.response.sys_id}

${call1.result.sys_id}

Any help would be greatly appreciated.

Thanks
Sampath

 

 

SB
Saviynt Employee
Saviynt Employee

You need to use dependent call variable when the call2 is dependent on call1. You can refer to the below REST connector guide for JSON reference of the same (Common features -> Support for Multiple API Call). 

https://docs.saviyntcloud.com/bundle/REST-v23x/page/Content/Developers-Handbook.htm


Regards,
Sahil

sampath18
Regular Contributor II
Regular Contributor II

@SB  I was exactly referring to same document. I have already included dependent call variable. Please check below JSON.

I have tried with binding Variables ${accountID) and ${accountName} but still no change in error. It still says Nullresponse from Target.

{
"accountParams":{
"connection":"userAuth",
"processingType":"SequentialAndIterative",
"call":{
"call1":{
"callOrder":0,
"stageNumber":0,
"http":{
"url":"https://dev.service-now.com/api/now/table/sys_user?user_name=56607&sysparm_fields=first_name,last_na...",
"httpMethod":"GET",
"httpParams":"{\"sysparm_display_value\":\"true\"}",
"httpHeaders":{
"Authorization":"Basic ######"
},
"httpContentType":"application/json"
},
"statusConfig":{
"active":"true",
"inactive":"false"
},
"listField":"result",
"keyField":"accountID",
"accountIdPath":"result.sys_id",
"colsToPropsMap":{
"customproperty1":"employee_number~#~char",
"CUSTOMPROPERTY2":"last_name~#~char",
"customproperty3":"name~#~char",
"CUSTOMPROPERTY4":"first_name~#~char",
"CUSTOMPROPERTY7":"email~#~char",
"name":"user_name~#~char",
"accountID":"sys_id~#~char"
},
"pagination":{
"nextUrl":{
"nextUrlPath":"${headers?.Link?.split(';')?.size()==5?headers?.Link?.split(';')[2]?.replace('rel=\"prev\",<', '')?.replace('>','')?.trim():headers?.Link?.split(';')?.size()==4 && headers?.Link?.split(';')[2].contains('rel=\"next\",<')?headers?.Link?.split(';')[1]?.replace('rel=\"first\",<', '')?.replace('>','')?.trim():null}"
}
}
},
"call2":{
"callOrder":1,
"stageNumber":3,
"connection":"userAuth",
"http":{
"url":"https://dev.service-now.com/api/now/table/alm_hardware?sysparm_query=install_status%3D1%5Eassigned_t...}",
"httpMethod":"GET",
"httpParams":"{\"sysparm_display_value\":\"true\"}",
"httpHeaders":{
"Authorization":"Basic #########",
"Accept":"application/json"
},
"httpContentType":"application/json"
},
"inputParams": {
"dependentCall": true
},
"listField":"result",
"keyField":"accountID",
"nextApiKeyField":"accountID",
"colsToPropsMap":{
"accountID":"assigned_to.value~#~char",
"CUSTOMPROPERTY8":"asset_tag~#~char"
}
}
}
}
}

 

Thanks,
Sampath

SB
Saviynt Employee
Saviynt Employee

Can you share the Call2 url value you are passing. In the above jsons the value is getting truncated. You can mask the domain name in url to shorten it. I basically need to check the url after sysparm_query.

Also, can you check in the logs for Calling Webservice Url to see if it is resolving the value for the DA used.


Regards,
Sahil

sampath18
Regular Contributor II
Regular Contributor II

@SB Please find attached file with full json

SB
Saviynt Employee
Saviynt Employee

can you check in the logs for Calling Webservice Url for 2nd call to see if it is resolving the value for the DA used.


Regards,
Sahil

SB
Saviynt Employee
Saviynt Employee

@sampath18  Also please use ${account.accountID} and see if it works.


Regards,
Sahil

sampath18
Regular Contributor II
Regular Contributor II

Hi @SB 

Thank you very much!! it is getting resolved. it seems issue was different. there were some invalid accounIDs hence it was throwing nulls reponse.

Thanks
Sampath

SB
Saviynt Employee
Saviynt Employee

Can you confirm if you used ${account.accountID} or ${accountID} in the url of call2.


Regards,
Sahil

sampath18
Regular Contributor II
Regular Contributor II

${account.accountID}  is working. I think the document also needs correction. 

Thanks once again.