0

I'm having an issue with nesting a case statement in a Netsuite saved search. Found plenty of examples on here and around the web, but I cannot seem to get it right. Basically I'm trying to make a report for our CFO that will show the taxable amount of certain orders. The first thing I check is if the customer is tax exempt or not. If they are, I want 0.00 to show. If they are not, I check to see if the order has already been taxed and remove that amount from the order total and display the difference. If none of these are true (customer is taxable and tax has not been charged) display the order total.

I've tried multiple ways of nesting, but the way that seems to work for most people is something like this:

CASE WHEN {customermain.taxable} = 'F' THEN '0.00' WHEN {netamountnotax} > 0 THEN {totalamount}-({totalamount}-{netamountnotax}) ELSE {totalamount} END 

When I run this as a Formula (Text), the field displays an error, "ERROR: Invalid Expression". When I use it as Formula (Currency), the whole search errors out.

I thought that it might be because I was outputting text, so I single quoted what the result should be, but that caused the search to error out as well.

2 Answers 2

1

What's the datatype of your variables, {totalamount}, {netamountnotax}?
Also, {totalamount}-({totalamount}-{netamountnotax}) cancels-out to just {netamountnotax}, regardless of what {totalamount} is:
5-(5-4)=4
If you're trying to get just the tax amount, you'll just need:
{totalamount}-{netamountnotax}

If they're decimal/currency, you need to take the single quotes away from '0.00'.
If the environment requires strict types, you may have to cast 0 to decimal/currency, whatever your other variables are.

Sign up to request clarification or add additional context in comments.

1 Comment

P.S. I haven't got enough reputation to comment on your answer, but be careful casting values to characters, especially when sorting/ordering in a report. You'll likely find 5 is greater than 499999. And adding them as strings, you may get 5499999 instead of 500004.
0

When I wrapped the results of the two decimal/currency outputs in TO_CHAR() it worked.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.