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

proxy address code to fit in if-else scenario

sbiswal
New Contributor II
New Contributor II

Hi,

Our current updateaccount code is in the form of an if-else code, like the below:

{${if(task?.accountKey.customproperty10 == '')
'"company":"'+user?.companyname+'",
"st":"'+user?.state+'",'
else
'"givenname" : "'+user?.firstname+'",
"sn" : "'+user?.lastname+'",'

We need to fit a code in here for proxy address that is a little complicated. Does anyone know how to do that?

The code is: "proxyaddresses":["SMTP:${user.email}","${task?.accountKey.customproperty51.replace('SMTP','smtp')}"]

Thank you!

4 REPLIES 4

sudeshjaiswal
Saviynt Employee
Saviynt Employee

Hello @sbiswal,

You may try the below code to achieve this,

Sample 1

{${if(task?.accountKey.customproperty10 == '')
'"company":"'+user?.companyname+'", "st":"'+user?.state+'",
"proxyaddresses":["SMTP:${user.email}","${task?.accountKey.customproperty51.replace('SMTP','smtp')}"]'
else
'"givenname" : "'+user?.firstname+'", "sn" : "'+user?.lastname+'",
"proxyaddresses":["SMTP:${user.email}","${task?.accountKey.customproperty51.replace('SMTP','smtp')}"]'
}}

Sample 2

{
${if(task?.accountKey.customproperty10 == '')
'"company":"'+user?.companyname+'", "st":"'+user?.state+'",'
else
'"givenname" : "'+user?.firstname+'", "sn" : "'+user?.lastname+'",'}
"proxyaddresses": [
"SMTP:${user.email}",
"${task?.accountKey.customproperty51.replace('SMTP','smtp')}"
]
}


Thanks,

If you find the above response useful, Kindly Mark it as "Accept As Solution".

Hey Sudesh,

Thanks for the response. Unfortunately, both the codes gave syntax errors:

1) Error while Update operation for account-TestCOne in AD - Failed to parse template script (your template may contain an error or be trying to use expressions not currently supported): startup failed: SimpleTemplateScript295.groovy: 1: expecting ''', found '\n' @ line 1, column 296. 51.replace('SMTP','smtp')}\"], ^ 1 error

2)Error while Update operation for account-TestCOne in AD - Failed to parse template script (your template may contain an error or be trying to use expressions not currently supported): startup failed: SimpleTemplateScript276.groovy: 1: expecting ''', found '\n' @ line 1, column 231. sses": ["SMTP:${user.email}\", ^ 1 error Error while Update operation for account-TestCOne in AD - Failed to parse template script (your template may contain an error or be trying to use expressions not currently supported): startup failed: SimpleTemplateScript295.groovy: 1: expecting ''', found '\n' @ line 1, column 296. 51.replace('SMTP','smtp')}\"], ^ 1 error

Is there any other code I could try?

Thank you,

Seemran Biswal

Hello @sbiswal,

you may try to use this:

{
"proxyaddresses": ["SMTP:${user.email}","${task?.accountKey.customproperty51.replace('SMTP','smtp')}"],
${if (task?.accountKey.customproperty10 == '') {'\"company\":\"' + user?.companyname + '\",\"st\":\"' + user?.state + '\"'}
else {'\"givenname\":\"' + user?.firstname + '\",\"sn\":\"' + user?.lastname + '\"'}}}

Thanks,

If you find the above response useful, Kindly Mark it as "Accept As Solution".

DixshantValecha
Saviynt Employee
Saviynt Employee

Hi @sbiswal

Please validate 

{
  ${
    if (task?.accountKey.customproperty10 == '') {
      '"company":"'+user?.companyname+'",' +
      '"st":"'+user?.state+'",' +
      '"proxyaddresses":["SMTP:'+user.email+'","'+task?.accountKey.customproperty51.replace('SMTP','smtp')+'"]';
    } else {
      '"givenname" : "'+user?.firstname+'",' +
      '"sn" : "'+user?.lastname+'",' +
      '"proxyaddresses":["SMTP:'+user.email+'","'+task?.accountKey.customproperty51.replace('SMTP','smtp')+'"]';
    }
  }
}

 Let us know if further assistance is needed.