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

Syntax for adding IF ELSE condition in REST connector

umang28
Regular Contributor
Regular Contributor

Hi,

Could you please help me correct how to execute the following if the condition is met call  MPCExchangeDisplay.ps1 else MPCExchangehide.ps1.

"httpParams": "{\"Script\":\"${if(user.customproperty58 == NULL) {Powershell.exe -File D:/test/MPCExchangeDisplay.ps1 {user.username} {connection.PS_Password}} else {Powershell.exe -File D:/test/MPCExchangehide.ps1 {user.username} {connection.PS_Password}}}\"}",

 

LOGS:

2023-06-30 16:06:20,413 [quartzScheduler_Worker-1] DEBUG rest.RestProvisioningService - Calling Webservice Url - https://zzzzz/SaviyntApp/PS/ExecutePSScript with httpParams - [Script:${if(user.customproperty58 == NULL) {Powershell.exe -File D:/test/MPCExchangeDisplay.ps1 {user.username} {connection.PS_Password}} else {Powershell.exe -File D:/test/MPCExchangeDisplay.ps1 {user.username} {connection.PS_Password}}}]

The task is getting completed but the script is not getting executed at all. 

Do we have to define the if else out side the script block? Or can we make two separate calls based on the condition?  

Alternatively if this not feasible is there a way to import exchange users based on the REST connector? I need to have exchange accounts in a deleted status if the user is re-hired for a create account to be triggered again. 

Thanks,

Umang 

 

3 REPLIES 3

umang28
Regular Contributor
Regular Contributor

I tried a couple of ways:

"httpParams": "${user.customproperty58.trim().equals('User Mailbox Triggered')?'{\"Script\":\"Powershell.exe -File D:\/test\/MPCExchangeProvisioning.ps1'+user.username+''+connection.PS_Password+'\"}' : '{\"Script\":\"Powershell.exe -File D:\/test\/MPCExchangeProvisioning.ps1'+user.username+''+connection.PS_Password+'\"}'}",

"httpParams": "${user.customproperty58 == 'User Mailbox Triggered' ? [{\"Script\":\"Powershell.exe -File D:\/test\/MPCExchangeProvisioning.ps1 '${user.username}' '${connection.PS_Password}' \"}] : [{\"Script\":\"Powershell.exe -File D:\/test\/MPCExchangeDisplay.ps1 '${user.username}' '${connection.PS_Password}' \"}]}",

 

But getting the following error:

2023-07-03 17:19:06,995 [quartzScheduler_Worker-4] ERROR rest.RestProvisioningService - Exception in creating original http params:com.fasterxml.jackson.core.JsonParseException: Unrecognized token '$': was expecting ('true', 'false' or 'null')
at [Source: ${user.customproperty58.trim().equals('User Mailbox Triggered')?'{"Script":"Powershell.exe -File D:/test/MPCExchangeProvisioning.ps1'+user.username+''+connection.PS_Password+'"}' : '{"Script":"Powershell.exe -File D:/test/MPCExchangeProvisioning.ps1'+user.username+''+connection.PS_Password+'"}'}; line: 1, column: 2]

Try syntax from below example 6 

https://docs.saviyntcloud.com/bundle/REST-v23x/page/Content/Developers-Handbook.htm


Regards,
Rushikesh Vartak
If this helped you move forward, click 'Kudos'. If it solved your query, select 'Accept As Solution'.