Netsuite custom formula field using a CASE stateme...
# suitescript
s
Netsuite custom formula field using a CASE statement with multiple WHEN conditions returning "invalid expression", Im trying this for case like CASE WHEN THEN ELSE CASE WHEN THEN ELSE END END
s
You can do syntax like CASE WHEN THEN WHEN THEN ELSE END ... otherwise your problem may be that you need to wrap your inner CASE WHEN in parens ()
Additionally, you can try to make your expression in SuiteAnalytics instead as it has a formula checker that should help you find the problem
s
This is what my code looks like CASE WHEN {custrecord_tr_customer.custentitycust_tr_customer_level_apr.id} IS NOT NULL THEN {custrecord_tr_customer.custentitycust_tr_customer_level_apr} WHEN {custrecord_tr_employee.subsidiary.id} = 2 AND {custrecord_tr_project.custentity_clientpartner} IS NOT NULL AND {custrecord_tr_employee.id} != {custrecord_tr_project.custentity_clientpartner.id} THEN {custrecord_tr_project.custentity_clientpartner.id} WHEN {custrecord_tr_project.jobtype.id} = 1 AND {custrecord_tr_employee.id} = {custrecord_tr_project_executing_practice.custrecord_practicehead.id} THEN {custrecord_tr_employee.custentity_reportingmanager.id} WHEN {custrecord_tr_project.jobtype.id} = 1 AND {custrecord_tr_employee.id} != {custrecord_tr_project_executing_practice.custrecord_practicehead.id} THEN {custrecord_tr_project_executing_practice.custrecord_practicehead.id} WHEN {custrecord_tr_project.jobtype.id} = 2 AND {custrecord_tr_employee.id} != {custrecord_tr_project.custentity_deliverymanager.id} THEN {custrecord_tr_project.custentity_deliverymanager.id} WHEN {custrecord_tr_project.jobtype.id} = 2 AND {custrecord_tr_employee.id} = {custrecord_tr_project.custentity_deliverymanager.id} THEN {custrecord_tr_employee.custentity_reportingmanager.id} WHEN {custrecord_tr_project_executing_practice.id} NOT IN (402, 403, 404, 407, 192, 457, 458, 459, 460, 461, 462, 463, 464, 465, 466, 467, 469, 470) AND {custrecord_tr_project_executing_practice.custrecord_practicehead} IS NOT NULL AND {custrecord_tr_employee.id} != {custrecord_tr_project_executing_practice.custrecord_practicehead.id} THEN {custrecord_tr_project_executing_practice.custrecord_practicehead.id} ELSE CASE WHEN {custrecord_tr_project.jobtype.id} = 2 AND {custrecord_tr_employee.id} != {custrecord_tr_project.custentity_deliverymanager.id} THEN {custrecord_tr_project.custentity_deliverymanager.id} ELSE {custrecord_tr_employee.custentity_reportingmanager.id} END END
s
Yeah put that in the formula checker
s
formula checker?
s
in suite analytics
s
im using netsuite
s
I am aware, there is a suite analytics tab in netsuite
s
ok im not aware of this
s
If you are not using query, then your problem is likely all the multi-level joins
s
ya
no multilevel joins
s
2 dots is multi-level
Go to Analytics -> New DataSet and create your formula in there and use the formula checker
s
ok i will try
e
your case when is a bit off though, as seen below
Copy code
CASE
 WHEN {custrecord_tr_customer.custentitycust_tr_customer_level_apr.id} IS NOT NULL
  THEN {custrecord_tr_customer.custentitycust_tr_customer_level_apr}
 WHEN
That’s not valid. You can do “`CASE variable WHEN condition THEN whatever WHEN condition2 THEN whatever2`” but if you choose to use
CASE WHEN variable/condition THEN whatever
, you will need to follow it up with ELSE then wrap another CASE WHEN underneath, as you laid it out in your original post. This is not consistent with what you originally posted. See the difference?
alternatively, i think you can stipulate ELSE WHEN and continue along that path
actually, i may be incorrect. sorry about that