Conditional provisioning JSOn - Create/Update

ejeong
All-Star
All-Star

Hi all,

I am wondering if we an implment "if-else" condition to use different JSON based on users.employeeType

 

if employeeType is Regular Then take this JSON

else take this JSON.

Is it feasible? if so, can anyone share me sample JSON for this?

8 REPLIES 8

rushikeshvartak
All-Star
All-Star

This is feasible 

DA_PROFILE,ACCOUNTTYPE - is Dynamic attribute name

{ "CreateAccountQry": [ "${if(ACCOUNTTYPE.isEmpty()) { 'CREATE USER '+accountName+' FOR LOGIN ['+accountName+'] ' } }" ] }

 

{"UpdateAccountQry": ["${if((ACCOUNTTYPE.isEmpty())){'ALTER USER '+accountName+' PROFILE  '+DA_PROFILE+''} else {'ALTER USER '+accountName+' PROFILE  '+DA_PROFILE+''}}"]}

Hi 

Could you please confirm if this is feasible for REST connection?

We want to use entire different attribute to be pased based on employeeType

Yes 

\"TargetAttribute\":\"${if{reqAttrs.customproperty5=='Sales'}{'Yes'} else {'NA'}}\"

Customproperty5 is account column for dynamic attribute

Thanks for reply again.

What i want is

If employeeType == full time

{Attribute1 : abc,

Attribute2: abc}

Else if employeeType == contractor

{Attribute1 : dfg,

Attribute2: dgf}

Can i do like this? Not only one attribute.

You can join two values using + operator 

 

KirtiAjrot
Saviynt Employee
Saviynt Employee

Instead of if -else , you could also make use of the ternary operator in the REST Jsons 

see below - we can use condition in URL too.. 

"url": "${(arsTasks.source.equalsIgnoreCase('PROVRULE'))?'https://iam22.ssmcloud.net/ECM/api/v5/completetask':'https://api.test.it.abc.com/provisoning'}",
"httpMethod": "POST",
"httpParams": "${arsTasks.source.equalsIgnoreCase('PROVRULE')? '{\"taskid\":\"'+arsTasks.id+'\",\"provisioning\": \"true\"}' : '{\"requestId\":\"\",\"taskId\":\"'+arsTasks.id+'\",\"requestType\":\"REMOVE\",\"provisionedDate\":\"'+new Date().toInstant()+'\",\"approveDate\":\"'+new Date().toInstant()+'\",\"firstName\":\"'+user.firstname+'\",\"lastName\":\"'+user.lastname+'\",\"alias\":\"'+user.systemUserName+'\",\"email\":\"'+user.email+'\",\"gin\":\"'+user.username+'\",\"requestorAlias\":\"\",\"accessType\":\"Automated\"}'}"

KA

Thanks. Its helpful

Is it possible to apply condition on the left side attributes?

Example:

"${(userId.equals(username))? '' : {systemUserName}}" : "${(userId.equals(username))? '' :{username~#~char}}",