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

Database connector : Case statement in a Insert Query (CreateAccountJSON)

BinduVaranasi
New Contributor
New Contributor

Hi Team,

I am trying to implement a case statement in the createAccountJSON. 

In the insert query , I need a case statement syntax which will fetch the correct value depending on the user attributes. I had tried the below possible values , but no luck.

a) CASE WHEN ((${user.entity} == 'XX') and (${user.customproperty5} == 'YY')) THEN 'AA' ELSE 'BB' END

b) ${CASE WHEN ((user.entity == 'XX') and ( user.customproperty5 == 'YY')) THEN 'AA' ELSE 'BB' END}

c) ${(user?.entity == 'XX' && user?.customproperty5=='YY') ? 'AA': 'BB' }

d) CASE WHEN ((user.entity == 'XX') and ( user.customproperty5 == 'YY')) THEN 'AA' ELSE 'BB' END

Please help me to get the right syntax

Thanks

Bindu.

 

5 REPLIES 5

pmahalle
All-Star
All-Star

Hi @BinduVaranasi ,

Can you try below one:

CASE WHEN (('${user.entity}' == 'XX') and ('${user.customproperty5}' == 'YY')) THEN 'AA' ELSE 'BB' END


Pandharinath Mahalle(Paddy)
If this reply answered your question, please Accept As Solution to help other who may have a same problem. Give Kudos 🙂

Hi @pmahalle ,

The above expression also did not work. 

Please confirm if we can use multiple conditions in the case statements with and condition. 

Please let me know if any.

Thanks

Bindu.

Yes you can add multiple conditions.

Hey try with single = instead of two as below. It's SQL not groovy or java

CASE WHEN (('${user.entity}' = 'XX') and ('${user.customproperty5}' = 'YY')) THEN 'AA' ELSE 'BB' END


Pandharinath Mahalle(Paddy)
If this reply answered your question, please Accept As Solution to help other who may have a same problem. Give Kudos 🙂

armaanzahir
Valued Contributor
Valued Contributor

Hi @BinduVaranasi ,

 

Can you share the whole createaccountjson you're trying. In MySql, Case statements do support multiple conditions separated by a logical operand. 

What is the target database?

 

Thanks,

Armaan

 

Regards,
Md Armaan Zahir

Hi @pmahalle 

single = worked . Thanks for the solution.

@armaanzahir I am using the Database connector. 

 

Thanks

Bindu.