Jozef Pietruniak Posted May 21 Share Posted May 21 I created a trigger that creates a STATS journal to post the QUANTITY of an item purchased or sold. Is there away of adding an IF statement in the API to change the TR_TYPE to "-1"if the quantity being passed is a negative? Link to comment Share on other sites More sharing options...
Members Sterio, Louis Posted May 21 Members Share Posted May 21 You would have two separate smart events and add a specific condition to each. The condition would be reversed for each one. Link to comment Share on other sites More sharing options...
Preston, Charlie Posted May 22 Share Posted May 22 You could also use an EVAL within the API call - something like the following: <TR_TYPE>#EVAL[ if ({!INJECTION_PARAM_QUANTITY!} < 0) {"-1"} else {"1"}; ]</TR_TYPE> 3 Link to comment Share on other sites More sharing options...
Jozef Pietruniak Posted May 30 Author Share Posted May 30 Can I add a formula to convert the -QTY to Positive when I'm posting the value? In other words can I post the ABS value? Link to comment Share on other sites More sharing options...
Preston, Charlie Posted May 31 Share Posted May 31 Within EVAL you are writing JavaScript, so you can use the standard JS functions: <TRX_AMOUNT>#EVAL[ Math.abs({!INJECTION_PARAM_QUANTITY!}); ]</TRX_AMOUNT> 1 Link to comment Share on other sites More sharing options...
Recommended Posts