BRENT TOBICZYK Posted November 12 Posted November 12 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. 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 Sterio, Louis Posted November 13 Members Posted November 13 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.
Lindsay Klatzkin Posted November 14 Posted November 14 (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 November 14 by Lindsay Klatzkin
BRENT TOBICZYK Posted November 18 Author Posted November 18 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
Lindsay Klatzkin Posted November 18 Posted November 18 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)
BRENT TOBICZYK Posted November 18 Author Posted November 18 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;
Recommended Posts