Announcing the Saviynt Knowledge Exchange unifying the Saviynt forums, documentation, training,
and more in a single search tool across platforms. Read the announcement here.

Dynamic Attribute if else condition for Rest Connector

GeSaviynt
New Contributor II
New Contributor II

Hi ,

I am trying to update the account on the value of dynamic attribute. If dynamic attribute 'sqlquery' contains 'write' then pass empty string else the value of dynamic attribute.

Sample : 

${if(requestAccessAttributes.get('sqlQuery').contains('Write')) {\"\"} else \"{requestAccessAttributes.get('sqlQuery')}\"}

It's throwing error for unrecognized $.

let me know where I am doing wrong.

 

Thanks

Geeta

7 REPLIES 7

Darshanjain
Saviynt Employee
Saviynt Employee

Hi @GeSaviynt 

The syntax looks correct, you can try with the below as well

${if(requestAccessAttributes.get('sqlQuery').contains('Write')) {\"\"} else \"{requestAccessAttributes.get('sqlQuery')}\"}

If this doesn't work , give me the exact json for which field you are using in which connector and may be a snippet of error logs as well

 

Thanks

Darshan

Hi Darshanjain,

Thanks for reply. But it's not working.

JSON :

{
"accountIdPath": "accountname",
"dateFormat": "yyyy-MM-dd'T'HH:mm:ssXXX",
"responseColsToPropsMap": {},
"call": [{
"name": "call1",
"connection": "userAuth",
"url": "https://abc.com/user/v9/acces",
"httpMethod": "POST",
"httpParams": "{\"AdvancedAccessRequest\": {\"adsId\": \"${user.systemUserName}\",\"service\":\"${requestAccessAttributes.get('Services')}\",\"advanced\":{\"clearCardAccessTo\":\"${requestAccessAttributes.get('clearcardaccessto')} ${requestAccessAttributes.get('Hour')}:${requestAccessAttributes.get('Min')}:${requestAccessAttributes.get('Sec')}\",\"sqlQuery\":${if(requestAccessAttributes.get('sqlQuery').contains('Write')) {\"\"} else \"{requestAccessAttributes.get('sqlQuery')}\"}}}}",
"httpHeaders": {
"Authorization": "${access_token}",
"Content-Type": "application/json"
},
"httpContentType": "application/json",
"successResponses": {
"AccessRequest.result": "Success"
}
}]
}

error : I can see in log for null object.

ssto')} ${requestAccessAttributes.get('Hour')}:${requestAccessAttributes.get('Min')}:${requestAccessAttributes.get('Sec')}","sqlQuery":"${requestAccessAttributes.get('sqlQuery')}"}}}, httpHeaders:[Authorization:${access_token}, Content-Type:application/json], httpContentType:application/json, successResponses:[AdvancedAccessRequest.result:Success]]]]
2023-03-29 14:57:46,631 [quartzScheduler_Worker-1] DEBUG rest.RestProvisioningService - Completing task - 58427
2023-03-29 14:57:46,632 [quartzScheduler_Worker-1] ERROR rest.RestProvisioningService - *****ERROR******
java.lang.NullPointerException: Cannot invoke method size() on null object
at com.saviynt.provisoning.rest.RestProvisioningService$_removeAccount_closure45.doCall(RestProvisioningService.groovy:8216)
at com.saviynt.provisoning.rest.RestProvisioningService.removeAccount(RestProvisioningService.groovy:8202)
at com.saviynt.ecm.services.ArsTaskService.removeAccountTarget(ArsTaskService.groovy:10473)

 

Thanks

Geeta

 

Hi @GeSaviynt 

Can you confirm you are getting null object only when you use the above condition, once you remove this and pass others json is it working fine ?

 

Thanks

Darshan

Hi @Darshanjain ,

Yes, it's working. Json with out condition:

{
"accountIdPath": "accountname",
"dateFormat": "yyyy-MM-dd'T'HH:mm:ssXXX",
"responseColsToPropsMap": {},
"call": [{
"name": "call1",
"connection": "userAuth",
"url": "https://abc.com/user/access/v1/advancedAccess",
"httpMethod": "POST",
"httpParams": "{\"AdvancedAccessRequest\": {\"adsId\": \"${user.systemUserName}\",\"service\":\"${requestAccessAttributes.get('Services')}\",\"advanced\":{\"clearCardAccessTo\":\"${requestAccessAttributes.get('clearcardaccessto')} ${requestAccessAttributes.get('Hour')}:${requestAccessAttributes.get('Min')}:${requestAccessAttributes.get('Sec')}\",\"sqlQuery\":${if(requestAccessAttributes.get('sqlQuery').contains('Write')) {\"\"} else \"{requestAccessAttributes.get('sqlQuery')}\"}}}}",
"httpHeaders": {
"Authorization": "${access_token}",
"Content-Type": "application/json"
},
"httpContentType": "application/json",
"successResponses": {
"AdvancedAccessRequest.result": "Success"
}
}]
}

Thanks

Geeta

Hi,

Now, it's a working.

 

Thanks

Geeta

Hi,

Issue was for syntax.

Thanks

Geeta

 

 

 

 

 

 

 

Hi @GeSaviynt 

Good to hear that the issue has been resolved.

If you can share the working json as well so that others referring this can make use of it.

Thanks

Darshan