We are delighted to share our new EIC Delivery Methodology for efficiently managing Saviynt Implementations and delivering quick time to value. CLICK HERE.

can we use if-else condition or ternary operator inside ImportAccountEntJSON configuration

GauravJain
Regular Contributor
Regular Contributor

In GET API call for entitlements we are getting entitlement owner's (support owner and development owner) and environment(QA/STAGE/PROD etc..) information with other details. Based on the environment we wanted to choose one of the owners inside entOwnerMappings. for ex if environment=='PROD' then map support owner as entitlement owner else use development owner.

Sample API response

{
"result": [
{
"id": "id1"
"name": "xyz",
"environment": "PROD",
"development_owner.user_name": "username",
"support_owner.user_name": "username"
}
]
}

15 REPLIES 15

rushikeshvartak
All-Star
All-Star

You can use #const followed by your logic


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

tried this inside entOwnerMappings but didnt work

"idPath": "#CONST#${if(environment~dot#name=='DEV') {return \"development_owner~dot#user_name\"} else {return \"support_owner~dot#user_name\"}}"

entilement import job is in success state, not giving any error / exception as well

GauravJain
Regular Contributor
Regular Contributor

tried ternary operator as well but no luck

"idPath": "${environment~dot#name == \"DEV\" ? \"development_owner~dot#user_name\" : environment~dot#name == \"PROD\" ? \"support_owner~dot#user_name\" : \"xyz\"}",

@rushikeshvartak any other suggestion you have to try out?

Can you try this

"idPath": "environment.equalsIgnoreCase('PROD')?support_owner.user_name:development_owner.user_name"


Regards,
Saathvik
If this reply answered your question, please Accept As Solution and give Kudos to help others facing similar issue.

You need to use #CONST also


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

GauravJain
Regular Contributor
Regular Contributor

Thanks @sk and @rushikeshvartak for your revert. i have tried both the suggestions with different permutation combination but no luck. Here are the details i tried out for your reference:

Sample API response

{
"result": [
{
"id": "id1"
"name": "xyz",
"u_legacy_id": "1",
"sys_class_name": "Test",
"u_environment.name": "PROD",
"u_development_owner.user_name": "username",
"u_support_owner.user_name": "username"
}
]
}

1) "idPath": "u_environment~dot#name.equalsIgnoreCase('PROD')?u_support_owner~dot#user_name:u_development_owner~dot#user_name",


2) "idPath": "#CONST#${u_environment~dot#name.equalsIgnoreCase('PROD')?u_support_owner~dot#user_name:u_development_owner~dot#user_name}",

3) "idPath": "u_environment.name.equalsIgnoreCase('PROD')?u_support_owner.user_name:u_development_owner.user_name",

Few observations:

1) inside colsToPropsMap in entitlementParams, i tried to concatenate two parameters sys_class_name and legacy id which worked fine using this format

"customproperty30": "#CONST#${return response.sys_class_name+ \" \" + response.u_legacy_id}~#~char", 

but if i try same thing for attributes where we have dot (which i replaced with ~dot#) in attribute name it doesnt work. for ex

"customproperty30": "#CONST#${return response.u_development_owner~dot#user_name+ \" \" + response.u_development_owner~dot#user_name}~#~char",

2) i think i am sure we can't use if-else condition or ternary operator in colsToPropsMap because i tried it with above working example like this

"customproperty30": "#CONST#${String dev1 = response.sys_class_name; String sup1 = response.u_legacy_id; if (sup1 == '1'){ret = dev1} else(ret = dev1 + \" \" + sup1) return ret}~#~char",

3) i somehow believe that the problem is with dot in attribute name. so any idea how to tackle it (tried replacing it with ~dot# as per FD but no luck)

Any suggestions or follow up questions would help to take this problem towards resolution. thanks

No it should not be issue with dot 

if you think dot issue then

Resolution: To resolve this issue, specify the field name with the separator ~dot#. For example, replace manager.user_name with manager~dot#user_name


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

Hi @rushikeshvartak - from above given examples, can you share one example with your changes to try. because i have tried many combinations with (.) and without dot (using ~dot#) but it doenst work. or refer following options i have tried so far

"idPath": "u_environment~dot#name.equalsIgnoreCase('PROD')?u_support_owner~dot#user_name:u_development_owner~dot#user_name",


"idPath": "#CONST#${u_environment~dot#name.equalsIgnoreCase('PROD')?u_support_owner~dot#user_name:u_development_owner~dot#user_name}",


"idPath": "u_environment.name.equalsIgnoreCase('PROD')?u_support_owner.user_name:u_development_owner.user_name",

"idPath": "#CONST#${response.u_environment~dot#name.equalsIgnoreCase('PROD')?response.u_support_owner~dot#user_name:response.u_development_owner~dot#user_name}",

"idPath": "#CONST#${String en1 = response.u_environment~dot#name; String devow1 = response.u_development_owner~dot#user_name; String supow1 = response.u_support_owner~dot#user_name; en1.equalsIgnoreCase('PROD')?supow1:devow1}",

"idPath": "response.u_environment.name.equalsIgnoreCase('PROD')?response.u_support_owner.user_name:response.u_development_owner.user_name",

"idPath": "${if(u_environment~dot#name=='DEV') {return \"u_development_owner~dot#user_name\"} else {return \"u_support_owner~dot#user_name\"}}",

"idPath": "${if(\"u_environment~dot#name\"=='DEV') {return \"u_development_owner~dot#user_name\"} else {return \"u_support_owner~dot#user_name\"}}",

"idPath": "${if(\"u_environment.name\"=='DEV') {return \"u_development_owner~dot#user_name\"} else {return \"u_support_owner~dot#user_name\"}}",

"idPath": "#CONST#${if(u_environment~dot#name=='DEV') {return \"u_development_owner~dot#user_name\"} else {return \"u_support_owner~dot#user_name\"}}",

"idPath": "#CONST#${if(\"u_environment~dot#name\"=='DEV') {return \"u_development_owner~dot#user_name\"} else {return \"u_support_owner~dot#user_name\"}}",

"idPath": "#CONST#${if(\"u_environment.name\"=='DEV') {return \"u_development_owner~dot#user_name\"} else {return \"u_support_owner~dot#user_name\"}}",

 

"idPath": "${u_environment~dot#name == \"DEV\" ? \"u_development_owner~dot#user_name\" : u_environment~dot#name == \"PROD\" ? \"u_support_owner~dot#user_name\" : \"xyz\"}",

"idPath": "#CONST#${\"u_environment~dot#name\" == \"DEV\" ? \"u_development_owner~dot#user_name\" : \"u_environment~dot#name\" == \"PROD\" ? \"u_support_owner~dot#user_name\" : \"gaujain\"}",

"idPath": "#CONST#${\"u_environment.name\" == \"DEV\" ? \"u_development_owner~dot#user_name\" : \"u_environment.name\" == \"PROD\" ? \"u_support_owner~dot#user_name\" : \"gaujain\"}",

"idPath": "#CONST#${String en1 = response.u_environment~dot#name; String devow1 = response.u_development_owner~dot#user_name; String supow1 = response.u_support_owner~dot#user_name; if (en1 == \"DEV\") {retrun devow1} else {return supow1}}",

 

Try to store value in customproperty


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

Yes @rushikeshvartak , i have done that already but just looking at a work around if possible. thanks

Hi @rushikeshvartak not sure if i understood your response properly, hence writing again. Are you asking to store in customproperty and then use it inside idPath? if yes, then please share syntax to try. thanks

what is working syntax there


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

Hi @rushikeshvartak for my usecase i had to split one entitlement into two (prod and non-prod) because if-else condition doesnt work in idPath configuration. So, working solution for my api response is

"idPath": "u_development_owner~dot#user_name"

@Sivagami FYI

Sivagami
Valued Contributor
Valued Contributor

@GauravJain - I ran into a similar issue and found that string operation is not supported in idpath

https://forums.saviynt.com/t5/identity-governance/rest-connector-string-operation-in-idpath/m-p/1490... 

Logged an enhancement request in idea's portal - https://ideas.saviynt.com/ideas/EIC-I-3803. Vote the idea to get traction from Saviynt team. 

-Siva

GauravJain
Regular Contributor
Regular Contributor

Hi @Sivagami 

i could be wrong here in my interpretation of your use case but what i observed in your solution is - you are mentioing entitlement value in idPath which is incorrect. idPath should only contain json path (similar to listPath in your example) which gives entitlement value. in your case there are two different paths 1) response.name 2) response.resource. 

 

so, your idea is partially related to my problem where i am not able to decide a path based on some condition. in your case, you wanted to merge two different paths because entitlement value is spread across two paths 1) response.name 2) response.resource. 

if above explanation looks reasonable then you will have to log another idea for this problem.

Please revert with your understanding on this.