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

How to avoid pushing null values to AD

dubeank
New Contributor III
New Contributor III

Hi All,

We are trying to push "phonenumber" to AD if available in Saviynt and if it is not available, it should not be pushed. We are using the below configuration/code in CREATEACCOUNTJSON and UPDATEACCOUNTJSON to achieve the same:

"telephoneNumber": "${if(user.phonenumber != null){user.phonenumber}}",

the issue here is that in case of update Account tasks, if the phone number is null in Saviynt, it removes the existing phone number value in AD as we are not handling else case in the above code.

We have tried below conditions as well but it did not work:
"telephoneNumber": "${if(user.phonenumber != null){user.phonenumber} else {SAVIYNTNOTCHANGED}}",

"telephoneNumber": "${if(user.phonenumber != null){user.phonenumber} else {undefined}}",
Getting below error when using above logic:
Error while Update operation for account-XYZ in AD - No such property: SAVIYNTNOTCHANGED for class: SimpleTemplateScript9486

Can you please help here to handle this scenario?
Ideally, It should update phone number in AD if available in Saviynt. however, it should not change/clear existing phone number in AD, if phone number is not available in Saviynt.

Regards
Ankit

14 REPLIES 14

Saathvik
All-Star
All-Star

@dubeank : Try below assuming you have other mappings before and after this mapping hence added comma(,) at start and end. If not accordingly change it.

"${if(user.phonenumber != null){',"telephoneNumber": ' + user.phonenumber +','}}"

 


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

dubeank
New Contributor III
New Contributor III

@Saathvik : Thank you so much for your quick response. 
I have tried the above logic and I am getting a JSON Parse error. Please find below the UpdateAccountJSON  code:


{
"cn": "${task.accountName}",
"userAccountControl": "512",
"name": "${task.accountName}",
"sn": "${user.lastname}${if(user.employeeType.equals('External')){'(EXT)'} else {''}}",
"givenName": "${if(user.customproperty11 != null) {user.customproperty11} else {user.firstname}}",
"displayName": "${if(user.customproperty11 != null) {user.customproperty11} else{user.firstname}} ${user.lastname} ${if(user.employeeType.equals('External')){'(EXT)'} else{''}}",
"objectClass": [
"top",
"person",
"organizationalPerson",
"user"
],
"samaccountname": "${task.accountName}",
"manager": "${if(user.manager != null && managerAccount != null && managerAccount.accountID != null){managerAccount.customproperty26 }}",
"${if(user.phonenumber != null){',"telephoneNumber": ' + user.phonenumber +','}}",
"c": "${if(user.customproperty6 != null){user.customproperty6}}",
"co": "${if(user.country != null){user.country}}",
"title": "${if(user.job_function != null){user.job_function}}",
"department": "${user.departmentname}",
"departmentNumber": "${user.departmentNumber}",
"extensionAttribute1": "${if(user.costcenter != null){user.costcenter}}",
"extensionAttribute2": "${if(user.customproperty16 != null){user.customproperty16}}",
"st": "${if(user.state != null){user.state}}",
"l": "${if(user.location != null){user.location}}",
"company": "${if(user.companyname!= null){user.companyname}}",
"countrycode": "${if(user.customproperty8 != null){user.customproperty8}}",
"postalCode": "${if(user.customproperty5 != null){user.customproperty5}}",
"streetAddress": "${if(user.street != null){user.street}}",
"scriptPath": "LogonScripts\\gls_logonscript_universal.vbs",
"employeeID": "${user.customproperty14}",
"physicalDeliveryOfficeName": "${if(user.employeeType.equals('External')){'External'} else if(user.customproperty7 != null){user.customproperty7}}"
}

I have also tried :

"${if(user.phonenumber != null){"telephoneNumber":user.phonenumber}}",

 but getting JSON Parsing error.
 Could you please help me to fix the parsing error.

Regards
Ankit

@dubeank Could you please try with below mappings

"telephoneNumber": "${if(user.phonenumber != null){user.phonenumber} else {'SAVIYNTNOTCHANGED'}}",


"telephoneNumber": "${if(user.phonenumber != null?user.phonenumber:'SAVIYNTNOTCHANGED'}",

Regards,
Sumathi Somala

If this reply answered your question, please Accept As Solution and give Kudos.

@SumathiSomala : Thanks for your suggestion.
We tried the mapping mentioned above and if "phonenumber" is null then it's Pushing 'SAVIYNTNOTCHANGED' value to AD as we are passing it as String.
It seems that this option does not work for AD and we have to pass SAVIYNTNOTCHANGED without ''.
Ref: https://forums.saviynt.com/t5/identity-governance/dont-provision-a-specific-attribute-if-dynamic-att...

Regards
Ankit

@dubeank : Try below

 

{
"cn": "${task.accountName}",
"userAccountControl": "512",
"name": "${task.accountName}",
"sn": "${user.lastname}${if(user.employeeType.equals('External')){'(EXT)'} else {''}}",
"givenName": "${if(user.customproperty11 != null) {user.customproperty11} else {user.firstname}}",
"displayName": "${if(user.customproperty11 != null) {user.customproperty11} else{user.firstname}} ${user.lastname} ${if(user.employeeType.equals('External')){'(EXT)'} else{''}}",
"objectClass": [
"top",
"person",
"organizationalPerson",
"user"
],
"samaccountname": "${task.accountName}",
"manager": "${if(user.manager != null && managerAccount != null && managerAccount.accountID != null){managerAccount.customproperty26 }}",
"c": "${if(user.customproperty6 != null){user.customproperty6}}",
"co": "${if(user.country != null){user.country}}",
"title": "${if(user.job_function != null){user.job_function}}",
"department": "${user.departmentname}",
"departmentNumber": "${user.departmentNumber}",
"extensionAttribute1": "${if(user.costcenter != null){user.costcenter}}",
"extensionAttribute2": "${if(user.customproperty16 != null){user.customproperty16}}",
"st": "${if(user.state != null){user.state}}",
"l": "${if(user.location != null){user.location}}",
"company": "${if(user.companyname!= null){user.companyname}}",
"countrycode": "${if(user.customproperty8 != null){user.customproperty8}}",
"postalCode": "${if(user.customproperty5 != null){user.customproperty5}}",
"streetAddress": "${if(user.street != null){user.street}}",
"scriptPath": "LogonScripts\\gls_logonscript_universal.vbs",
"employeeID": "${user.customproperty14}",
"physicalDeliveryOfficeName": "${if(user.employeeType.equals('External')){'External'} else if(user.customproperty7 != null){user.customproperty7}}"
"${if(user.phonenumber != null){',\"telephoneNumber\": ' + user.phonenumber}}"
}

 


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

dubeank
New Contributor III
New Contributor III

@Saathvik : Hi SK,

I have tried the above and getting again JSON Parse error.
I have checked the logs and it's showing below error:

dubeank_0-1696941966432.png

The attribute key name ' "telephoneNumber" : ' is missing and just the attribute value is showing as null.
Thanks in advance for your help.

Regards
Ankit

@dubeank : Cool that logs help, Try below

{
"cn": "${task.accountName}",
"userAccountControl": "512",
"name": "${task.accountName}",
"sn": "${user.lastname}${if(user.employeeType.equals('External')){'(EXT)'} else {''}}",
"givenName": "${if(user.customproperty11 != null) {user.customproperty11} else {user.firstname}}",
"displayName": "${if(user.customproperty11 != null) {user.customproperty11} else{user.firstname}} ${user.lastname} ${if(user.employeeType.equals('External')){'(EXT)'} else{''}}",
"objectClass": [
"top",
"person",
"organizationalPerson",
"user"
],
"samaccountname": "${task.accountName}",
"manager": "${if(user.manager != null && managerAccount != null && managerAccount.accountID != null){managerAccount.customproperty26 }}",
"c": "${if(user.customproperty6 != null){user.customproperty6}}",
"co": "${if(user.country != null){user.country}}",
"title": "${if(user.job_function != null){user.job_function}}",
"department": "${user.departmentname}",
"departmentNumber": "${user.departmentNumber}",
"extensionAttribute1": "${if(user.costcenter != null){user.costcenter}}",
"extensionAttribute2": "${if(user.customproperty16 != null){user.customproperty16}}",
"st": "${if(user.state != null){user.state}}",
"l": "${if(user.location != null){user.location}}",
"company": "${if(user.companyname!= null){user.companyname}}",
"countrycode": "${if(user.customproperty8 != null){user.customproperty8}}",
"postalCode": "${if(user.customproperty5 != null){user.customproperty5}}",
"streetAddress": "${if(user.street != null){user.street}}",
"scriptPath": "LogonScripts\\gls_logonscript_universal.vbs",
"employeeID": "${user.customproperty14}",
"physicalDeliveryOfficeName": "${if(user.employeeType.equals('External')){'External'} else if(user.customproperty7 != null){user.customproperty7}}"
"${if(user.phonenumber != null){',\"telephoneNumber\": ' + user.phonenumber} else{''}}"
}

 


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

dubeank
New Contributor III
New Contributor III

@Saathvik : Thank you so much for your help.

I used the above configuration but it did not work.
When i am passing null value for phone number, it's giving below error:

dubeank_0-1697111128092.png

and when passsing some value for phonenumber, getting below error:

dubeank_1-1697111229993.png

I have also tried online json formatter and validator and it's showing error.
can you please check once again and help here to resolve the issue.
your help is highly appreciated.

Regards
Ankit

@dubeank Could you please try below JSON

{
"cn": "${task.accountName}",
"userAccountControl": "512",
"name": "${task.accountName}",
"sn": "${user.lastname}${if(user.employeeType.equals('External')){'(EXT)'} else {''}}",
"givenName": "${if(user.customproperty11 != null) {user.customproperty11} else {user.firstname}}",
"displayName": "${if(user.customproperty11 != null) {user.customproperty11} else{user.firstname}} ${user.lastname} ${if(user.employeeType.equals('External')){'(EXT)'} else{''}}",
"objectClass": [
"top",
"person",
"organizationalPerson",
"user"
],
"samaccountname": "${task.accountName}",
"manager": "${if(user.manager != null && managerAccount != null && managerAccount.accountID != null){managerAccount.customproperty26 }}",
"c": "${if(user.customproperty6 != null){user.customproperty6}}",
"co": "${if(user.country != null){user.country}}",
"title": "${if(user.job_function != null){user.job_function}}",
"department": "${user.departmentname}",
"departmentNumber": "${user.departmentNumber}",
"extensionAttribute1": "${if(user.costcenter != null){user.costcenter}}",
"extensionAttribute2": "${if(user.customproperty16 != null){user.customproperty16}}",
"st": "${if(user.state != null){user.state}}",
"l": "${if(user.location != null){user.location}}",
"company": "${if(user.companyname!= null){user.companyname}}",
"countrycode": "${if(user.customproperty8 != null){user.customproperty8}}",
"postalCode": "${if(user.customproperty5 != null){user.customproperty5}}",
"streetAddress": "${if(user.street != null){user.street}}",
"scriptPath": "LogonScripts\\gls_logonscript_universal.vbs",
"employeeID": "${user.customproperty14}",
"physicalDeliveryOfficeName": "${if(user.employeeType.equals('External')){'External'} else if(user.customproperty7 != null){user.customproperty7}}",
"telephoneNumber": "${if(user.phonenumber!=null){user.phonenumber} else{''}}"
}

Regards,
Sumathi Somala

If this reply answered your question, please Accept As Solution and give Kudos.

@SumathiSomala : Hi Somathi,

When I am using the code you provided, I am not getting a parsing error. the task is getting completed sucessfully. however, if the phone number value is null in Saviynt. it's deleting existing phone number value from AD. which we don't want.

Thanks
Ankit

@dubeank Could you please check the below config in AD connection parameters

SumathiSomala_0-1697114393668.png

 

 

SumathiSomala_1-1697115289178.png

 

 

Now try below sample mappings

"telephoneNumber": "${user.phonenumber}"
"telephoneNumber": "${if(user.phonenumber!=null){user.phonenumber} else{''}}"

Let me know if it helps.

If this reply answered your question, please Accept it As Solution to help others who may have a similar problem.

Regards,
Sumathi Somala

If this reply answered your question, please Accept As Solution and give Kudos.

@dubeank Are you still facing the issue?

Regards,
Sumathi Somala

If this reply answered your question, please Accept As Solution and give Kudos.

dubeank
New Contributor III
New Contributor III

@SumathiSomala : Apologies for the delay in response.
I have checked it after setting SUPPORTEMPTYSTRING=TRUE and noticed that if we are setting this configuration then Saviynt is allowing to push NULL value to AD.

dubeank_0-1697446064638.png

AS you can see in the above screenshot, value of phone number is updated to NULL in AD.
I have also checked documentation portal and i found below:

dubeank_1-1697446154818.png

and it seems that it is working in opposite way.
Unfortunatly, this did not resolve my use case.
I want to push to AD if and only if some value is there and if phone number is null it should not be pushed.
can you suggest if we can push value based on some other condition. like: if country=NL then only phone number attribute should be passed to AD else it should not be included into create account/Update Account JSON.

Regards
Ankit



dubeank
New Contributor III
New Contributor III

@rushikeshvartak , @dgandhi , @pmahalle :
can you please check if we can handle this use case in any way?

Regards
Ankit