Search code examples
freemarkernetsuite

How do you evaluate and compare the value of item.istaxable in Netsuite?


I'm using the Advanced PDF/HTML Templates in Netsuite to create a custom output template. In this Template I want to evaluate an item to see if it is taxable.

NetSuite's Schema Defines a Sales Order with a Sub List Item that has a field .istaxable (source)

  • Field: istaxable
  • Type: checkbox
  • Label: Tax
  • Required: false

When I try to evaluate an expression such as:

<#if item.istaxable == true>

By printing the template I get the following error.

Left hand operand is a com.netledger.templates.model.StringModel

Right hand operand is a freemarker.template.TemplateBooleanModel$2

When I try to evaluate .istaxable as a String:

<#if item.istaxable == "true">

or

<#if item.istaxable == 'T'>

*EDIT: Updated in response to suggested answer

I am unable to save the template in the editor as it throws an error:

The only legal comparisons are between two numbers, two strings, or two dates. Left hand operand is a com.netledger.templates.model.BooleanModel Right hand operand is a freemarker.template.SimpleScalar

So is item.istaxable a StringModel or a BooleanModel?


Solution

  • Netsuite is notoriously inconsistent with how it treats boolean values, and in fact I have come across cases where the same field is treated differently depending on the transaction (in my case it was the isclosed field). I ended up using the syntax below:

    <#if (item.isclosed?is_boolean && item.isclosed) || (item.isclosed?is_string && item.isclosed == 'T')