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
Valued Contributor II
Valued Contributor II

Hi @BinduVaranasi ,

Can you try below one:

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


Regards,

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

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.

pmahalle
Valued Contributor II
Valued Contributor II

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


Regards,

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

armaanzahir
Regular Contributor III
Regular Contributor III

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.