How to correctly put multiple layer of conditional logic for REST CreateAccountJSON configuration?

alc
New Contributor III
New Contributor III

Hello

I created an REST Connector based  security system which has two endpoints. When I configure CreateAccountJSON on the connection, I want to have different httpParams values:

if the endpoint is endpoint1, I will need use httpParams as below:
"httpParams": "${user.customproperty1=='Guest'?'{\"guestUserEmailAddress\":\"' + user.email + '\",\"guestUserDisplayName\":\"' + user.fullname + '\"}}"

if the endpoint is endpoint2, I will need use httpParams as below:
"httpParams": "${user.customproperty1=='Customer'?'{\"customerEmailAddress\":\"' + user.email + '\",\"customerUserDisplayName\":\"' + user.firstname + ' ' + user.lastname + '\"}}"

how can I configure this httpParams parameter value in this case? I tried to put endpoint conditional logic as external layer, then the internal conditional check on user.customproperty1 will not work. and I don't want to put two conditional check of endpoint and user.customproperty1 together because I will have many other customproperty conditions check for other account attribute values. this is just a simple example.

Any idea and example help me understand the correct syntax for httpParams conditional value setup?

Thanks

 

1 REPLY 1

adriencosson
Regular Contributor III
Regular Contributor III

Hi @alc ,

Is it the same underlying target application behind the REST connector ?

If yes, can you try to add null or empty values based on endpoint and user's customproperty1 values like below ?

{
	"guestUserEmailAddress" : "${endpoint.endpointname=='Endpoint1'?(user.customproperty1=='Guest'?user.email:''):''}",
	"guestUserDisplayName" : "${endpoint.endpointname=='Endpoint1'?(user.customproperty1=='Guest'?user.firstname + ' ' + user.lastname:''):''}",
	"customerEmailAddress" : "${endpoint.endpointname=='Endpoint2'?(user.customproperty1=='Customer'?user.email:''):''}",
	"customerUserDisplayName" : "${endpoint.endpointname=='Endpoint2'?(user.customproperty1=='Customer'?user.firstname + ' ' + user.lastname:''):''}"
}

...which would be converted as : 

{\"guestUserEmailAddress\" : \"${endpoint.endpointname=='Endpoint1'?(user.customproperty1=='Guest'?user.email:''):''}\",\"guestUserDisplayName\" : \"${endpoint.endpointname=='Endpoint1'?(user.customproperty1=='Guest'?user.firstname + ' ' + user.lastname:''):''}\",\"customerEmailAddress\" : \"${endpoint.endpointname=='Endpoint2'?(user.customproperty1=='Customer'?user.email:''):''}\",\"customerUserDisplayName\" : \"${endpoint.endpointname=='Endpoint2'?(user.customproperty1=='Customer'?user.firstname + ' ' + user.lastname:''):''}\"}

Also note that "user.fullname" does not exist.

Regards,
Adrien COSSON