Saviynt unveils its cutting-edge Intelligence Suite products to revolutionize Identity Security!
Click HERE to see how Saviynt Intelligence is transforming the industry.
Saviynt Copilot Icon

Is it possible to pass JSON key value pair with if else in SAP Connector?

rituparna_pwc
Regular Contributor
Regular Contributor

In SAP Connector we have Create, Update account json where we are currently using if else as below:

{"LOGONDATA":{

"USTYP":"A","GLTGV": "${user.startdate}","GLTGB": "${(user.enddate!=null)?({new java.text.SimpleDateFormat('yyyyMMdd').format(user.enddate)}):99991231}"

}}

Is it possible if we can have something like below

if user.statuskey=1 then send ustyp on the json else do not send ustype key value pair on the json

for eg

if user.statuskey==1?""USTYP":"A","GLTGV": "${user.startdate}","GLTGB": "${(user.enddate!=null)?({new java.text.SimpleDateFormat('yyyyMMdd').format(user.enddate)}):99991231}" : ""

2 REPLIES 2

nimitdave
Saviynt Employee
Saviynt Employee

@rituparna_pwc , I assume that you want to pass values to LOGONDATA ,only is user is active. Otherwise you want to send empty LOGONDATA?

Does it make a difference then sending as below:

"LOGONDATA":{
"GLTGB": "",
"USTYP": "",
"GLTGV:""
},

 

Alternatively try below also:

"LOGONDATA":"${
Map map1 = new HashMap();
if(user.statuskey==1)map1.put("USTYP",'A');
else map1.put("USTYP",'');
if(user.statuskey==1)map1.put("GLTGV",user.startdate);
else map1.put("GLTGV",'');
if(user.statuskey==1)map1.put("GLTGB",(user.enddate!=null)?({new java.text.SimpleDateFormat('yyyyMMdd').format(user.enddate)}):99991231);
else map1.put("GLTGB",'');
jsonBuilder = new groovy.json.JsonBuilder(map1);
return jsonBuilder.toString();
}"

Hi,

No, I do not want to send USTYP at all if statuskey is not equal to 1. I do not want to send USTYP:"" . I want to omit this key value pair all together