07/24/2023 05:12 AM
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.
Solved! Go to Solution.
07/24/2023 05:22 AM
Hi @BinduVaranasi ,
Can you try below one:
CASE WHEN (('${user.entity}' == 'XX') and ('${user.customproperty5}' == 'YY')) THEN 'AA' ELSE 'BB' END
07/24/2023 05:29 AM
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.
07/24/2023 05:32 AM
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
07/24/2023 05:32 AM
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
07/24/2023 05:37 AM
Hi @pmahalle
single = worked . Thanks for the solution.
@armaanzahir I am using the Database connector.
Thanks
Bindu.