Jump to content

Recommended Posts

Posted

I haven't seen a working example but wanted to know how to handle working with a null variable in a trigger change value formula.

image.png.28815bb8b6a0a86821415f075754f39b.png

as is, if taxabsval is null, it obviously returns nothing but if there is a value, the calculation works correctly. what is the correct way to declare that variable to allow the condition to work?

  • Members
Posted

Have you tried something like this? "{!SODOCUMENTENTRY.TAXABSVAL!}" != ""

Wrapping double quotes around it should sort of cast it to a string, then you can evaluate string on string. Give that a shot.

 

Posted (edited)

Have you tried something like this?  I tend to create variables to set equal to the reference values then use/manipulate them.

var taxAbsVal = 0;

if('{!SODOCUMENTENTRY.TAXABSVAL!}'.length > 0) {
	taxAbsVal = (parseFloat('{!SODOCUMENTENTRY.TAXABSVAL!}') || 0) ;
}

if(taxAbsVal > 0){
	return (taxAbsVal / 45);
}
else {
	return 0;
}

 

Edited by Lindsay Klatzkin
Posted

Unfortunately no. The problem is still in the if statement

 

var taxAbsVal = 123;

if('{!SODOCUMENTENTRY.TAXABSVAL!}'.length > 0) {
	taxAbsVal = 456;
}

return taxAbsVal;

this returns 123

Posted

Right, because the TAXABSVAL is null.  If it wasn't null, then it'd return 456.  The problem you were having (formula error) should be solved with my solution.

When you are debugging the formula, does the rendered text look like this?

if(''.length > 0)
Posted

correct, which is invalid for the comparison. I ended up using the variable in the if statement and it worked, like so 

 

if(taxAbsVal.length > 0) {
    taxAbsVal = (taxAbsVal/{!SODOCUMENTENTRY.TOTAL!});
}

return taxAbsVal;

×
×
  • Create New...