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

Not null check in update account JSON

Abdul_Gaffar
New Contributor II
New Contributor II

Hi ,

We are trying to ensure the not null check in the update account json like the account should get updated if the attributes got updated with not null values 

However , even after ensuring the not null check the attributes are getting updated with null values 

PFB the json being leveraged

{
"co": "${if(user.customproperty32!=null){user.customproperty32}}",
"c": "${if(user.country!=null){user.country}}",
"title": "${if(user.title!=null){user.title}}",
"st": "${if(user.state!=null){user.state}}",
"division": "${if(user.customproperty16!=null){user.customproperty16}}",
"physicalDeliveryOfficeName": "${if(user.locationdesc!=null){user.locationdesc}}",
"streetAddress": "${if(user.street!=null){user.street}}",
"department": "${if(user.departmentname!=null){user.departmentname}}",
"countryCode": "${if(user.customproperty33!=null){user.customproperty33}}",
"company": "${if(user.customproperty17!=null){user.customproperty17}}",
"extensionAttribute13": "${if(user.locationnumber!=null){user.locationnumber}}",
"extensionAttribute14": "${if(user.customproperty27!=null){user.customproperty27}}",
"extensionAttribute8": "${if(user.customproperty27!=null){user.customproperty27}}",
"extensionAttribute1": "${if(user.employeeid!=null){user.employeeid}}",
"manager": "${if(user.manager!=null){user.manager}}",
"employeeID": "${if(user.employeeid!=null){user.employeeid}}",
"manager": "${if(user.manager!=null){managerAccount?.comments}}",
"telephoneNumber": "${if(user.phonenumber!=null){user.phonenumber}}",
"extensionAttribute6": "${if(user.customproperty12!=null){user.customproperty12}}",
"l": "${if(user.city!=null){user.city}}",
"postalCode": "${if(user.customproperty13!=null){user.customproperty13}}",
"extensionAttribute4": "${user.leaveStatus =='LEAVE'? 'exclude':''}",
"extensionAttribute11": "${user.leaveStatus =='LEAVE'? 'exclude':''}",
"msExchExtensionAttribute24": "${user.country =='US'? 'US':'INTL'}",
"msExchExtensionAttribute23": "${user.employeeType =='Employee'? 'FTE':'NE'}",
}

please suggest what changes shall be made 

 

Thanks 

Abdul Gaffar

11 REPLIES 11

CR
Regular Contributor III
Regular Contributor III

@Abdul_Gaffar  can you try below condition also include

all same way

co": "${if(user.customproperty32!=null) &&(user.customproperty32!=""){user.customproperty32}}",


Thanks,
Raghu
If this reply answered your question, Please Accept As Solution and hit Kudos.

Abdul_Gaffar
New Contributor II
New Contributor II

Hi @CR ,

I did as you have suggested above except specifying '' insted of "" in the condition 

However , I am getting error as below:

Error while Update operation for account-ntestdev in AD - Failed to parse template script (your template may contain an error or be trying to use expressions not currently supported): startup failed: SimpleTemplateScript163.groovy: 2: unexpected token: && @ line 2, column 45. (user.customproperty32!=null) &&(user.cu ^ 1 error

can you please specify is it with single quotes or double quotes to be supported 

 

Regards

Abdul Gaffar

CR
Regular Contributor III
Regular Contributor III

I belive below one also you tried?

"${if(user.customproperty32!=null) &&(user.customproperty32!=''){user.customproperty32}}",


Thanks,
Raghu
If this reply answered your question, Please Accept As Solution and hit Kudos.

Abdul_Gaffar
New Contributor II
New Contributor II

Hi @CR ,

Yes I did 

"co": "${if(user.customproperty32!=null) &&(user.customproperty32!=''){user.customproperty32}}"

Then getting error like " Failed to parse template script (your template may contain an error or be trying to use expressions not currently supported): startup failed: SimpleTemplateScript163.groovy: 2: unexpected token: && @ line 2, column 45. (user.customproperty32!=null) &&(user.cu ^ 1 error"

 

Regards

Abdul Gaffar

CR
Regular Contributor III
Regular Contributor III

added now all '?'

try it

{
"co": "${if(user?.customproperty32!=null){user?.customproperty32}}",
"c": "${if(user?.country!=null){user?.country}}",
"title": "${if(user?.title!=null){user?.title}}",
"st": "${if(user?.state!=null){user?.state}}",
"division": "${if(user?.customproperty16!=null){user?.customproperty16}}",
"physicalDeliveryOfficeName": "${if(user?.locationdesc!=null){user?.locationdesc}}",
"streetAddress": "${if(user?.street!=null){user?.street}}",
"department": "${if(user?.departmentname!=null){user?.departmentname}}",
"countryCode": "${if(user?.customproperty33!=null){user?.customproperty33}}",
"company": "${if(user?.customproperty17!=null){user?.customproperty17}}",
"extensionAttribute13": "${if(user?.locationnumber!=null){user?.locationnumber}}",
"extensionAttribute14": "${if(user?.customproperty27!=null){user?.customproperty27}}",
"extensionAttribute8": "${if(user?.customproperty27!=null){user?.customproperty27}}",
"extensionAttribute1": "${if(user?.employeeid!=null){user?.employeeid}}",
"manager": "${if(user?.manager!=null){user?.manager}}",
"employeeID": "${if(user?.employeeid!=null){user?.employeeid}}",
"manager": "${if(user?.manager!=null){managerAccount?.comments}}",
"telephoneNumber": "${if(user?.phonenumber!=null){user?.phonenumber}}",
"extensionAttribute6": "${if(user?.customproperty12!=null){user?.customproperty12}}",
"l": "${if(user?.city!=null){user?.city}}",
"postalCode": "${if(user?.customproperty13!=null){user?.customproperty13}}",
"extensionAttribute4": "${user?.leaveStatus =='LEAVE'? 'exclude':''}",
"extensionAttribute11": "${user?.leaveStatus =='LEAVE'? 'exclude':''}",
"msExchExtensionAttribute24": "${user?.country =='US'? 'US':'INTL'}",
"msExchExtensionAttribute23": "${user?.employeeType =='Employee'? 'FTE':'NE'}",
}


Thanks,
Raghu
If this reply answered your question, Please Accept As Solution and hit Kudos.

Abdul_Gaffar
New Contributor II
New Contributor II

Hi @CR ,

I tried this suggestion , however the attributes are still getting updated with null values 

If there is any other way to ensure that no null values are getting updated at target level

 

Thanks 

Abdul Gaffar

AmitM
Valued Contributor
Valued Contributor

Hi @Abdul_Gaffar , This should work.

"streetAddress": "${user.street!=null?user.street:''}"

Thanks,

Amit

If this answers your query, Please ACCEPT SOLUTION and give KUDOS.

Thanks,

Amit

Abdul_Gaffar
New Contributor II
New Contributor II

Hi @AmitM ,

The update to null is what we are trying to omit as in if source sends a null value it shouldnt get updated

for instance "streetAddress": "${user.street!=null?user.street:''}" if street is null then the account gets updated with a null value , which is what we are trying to avoid here.

 

Regards

Abdul Gaffar

AmitM
Valued Contributor
Valued Contributor

Okay , In this doc search HashMap and use the Json Builder method for Update account Json -https://docs.saviyntcloud.com/bundle/AD-v24x/page/Content/Configuring-the-Integration-for-Provisioni...

If the attribute is null don't add it to map. Don't write this line else map1.put('birthdate','');

Thanks,

Amit

If this answers your query, Please ACCEPT SOLUTION and give KUDOS.

rushikeshvartak
All-Star
All-Star

{
"co": "${user.customproperty32 != null ? user.customproperty32 : ''}",
"c": "${user.country != null ? user.country : ''}",
"title": "${user.title != null ? user.title : ''}",
"st": "${user.state != null ? user.state : ''}",
"division": "${user.customproperty16 != null ? user.customproperty16 : ''}",
"physicalDeliveryOfficeName": "${user.locationdesc != null ? user.locationdesc : ''}",
"streetAddress": "${user.street != null ? user.street : ''}",
"department": "${user.departmentname != null ? user.departmentname : ''}",
"countryCode": "${user.customproperty33 != null ? user.customproperty33 : ''}",
"company": "${user.customproperty17 != null ? user.customproperty17 : ''}",
"extensionAttribute13": "${user.locationnumber != null ? user.locationnumber : ''}",
"extensionAttribute14": "${user.customproperty27 != null ? user.customproperty27 : ''}",
"extensionAttribute8": "${user.customproperty27 != null ? user.customproperty27 : ''}",
"extensionAttribute1": "${user.employeeid != null ? user.employeeid : ''}",
"manager": "${user.manager != null ? user.manager : ''}",
"employeeID": "${user.employeeid != null ? user.employeeid : ''}",
"manager": "${user.manager != null ? managerAccount.comments : ''}",
"telephoneNumber": "${user.phonenumber != null ? user.phonenumber : ''}",
"extensionAttribute6": "${user.customproperty12 != null ? user.customproperty12 : ''}",
"l": "${user.city != null ? user.city : ''}",
"postalCode": "${user.customproperty13 != null ? user.customproperty13 : ''}",
"extensionAttribute4": "${user.leaveStatus == 'LEAVE' ? 'exclude' : ''}",
"extensionAttribute11": "${user.leaveStatus == 'LEAVE' ? 'exclude' : ''}",
"msExchExtensionAttribute24": "${user.country == 'US' ? 'US' : 'INTL'}",
"msExchExtensionAttribute23": "${user.employeeType == 'Employee' ? 'FTE' : 'NE'}"
}


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

Abdul_Gaffar
New Contributor II
New Contributor II

Hi @rushikeshvartak ,

I tried as per your suggestion above 

However we are getting the null values getting updated at target

To ensure this SUPPORTEMPTYSTRING field is also set to false

However , the null values are still getting updated on the target accounts

 

Thanks & regards

Abdul Gaffar