Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi
I am trying to conditionally increment a Big Dec context variable based on certain field values
currently I can do this via tJavaRow component, but want to bring this into a tMap - so the logic is centralized
this code currently works in tJavaRow
but when I try to code something similar in the Var Expression builder, I receive "Type mismatch: cannot convert from Number&Comparable<?> to BigDecimal"
I have tried to search online in several places to address this issue but have had zero luck
do you have any advice
thank you in advance
Hi,
Not very clean in my opinion, but if I understand your request you should try this.
Create a BigDecimal variable in the tMap, enter the expression builder and type the code:
null; // This is here because you need to affect a value to the variable
if(!"A".equals("B")) // Replace this with your condition
context.test = context.test.add(new BigDecimal(1)); // Replace with your context variable
As you can see, the expression builder can be used to enter a piece of Java code which is not used for the variable assignment.
The only rule is that the 1st line must reprsent the right part of the variable assignment, but of course, you are not forced to use this variable anywhere.
So, this is what you expect: the context variable is incremented by 1 for each input row under condition.
Hope this helps.
Hi,
Not very clean in my opinion, but if I understand your request you should try this.
Create a BigDecimal variable in the tMap, enter the expression builder and type the code:
null; // This is here because you need to affect a value to the variable
if(!"A".equals("B")) // Replace this with your condition
context.test = context.test.add(new BigDecimal(1)); // Replace with your context variable
As you can see, the expression builder can be used to enter a piece of Java code which is not used for the variable assignment.
The only rule is that the 1st line must reprsent the right part of the variable assignment, but of course, you are not forced to use this variable anywhere.
So, this is what you expect: the context variable is incremented by 1 for each input row under condition.
Hope this helps.
TRF
thank you
this works - sorry for not responding to you sooner
your efforts are much appreciated