How use if else condition
-
I'm trying to do the if else condition in document itself but it's not working properly give me some example for create if else condition. Is this possible without creating function.
In document I'm trying like this { IF "{MREGEFIELD defect}" = "New" "YES" "NO" } it print the value while generating pdf 'YES' only
-
Are you using Handlebars?
I'm not shure what {MREGEFIELD defect} means. Isdefect
a property ofMREGEFIELD
? I.e.MREGEFIELD.defect
?I don't think Handlebars has a comparison helper out of the box.
#if
can only check if a value is truthy.I'm using the npm package "handlebars-helpers" which for example includes
#eq
for comparing values, like below. If your use case is a one-off it's probably easier to just write a function. Are you using JSReport Studio? In that case it's really simple to write a comparison helper function in the helper pane and call this function from Handlebars.Here is how your comparison could look like with #eq.
{{#eq MREGEFIELD.defect "New"}} Yes {{else}} No {{/eq}}