Reputation: 13
I am using HCL Notes (previously IBM Notes and Lotus Notes before that).
I have a field named TransactionType
, it can be either Income or Expense.
Another field is TransactionAmount
. When TransactionType
is Expense, then I want the number in TranslationAmount
to be a negative number.
@If(transactionType = "Expense";-@ThisValue;@ThisValue)
I've tried various versions of this formula as an Input Translation. The problem is that every time the formula is run it changes a negative number to a positive number. Run it again it reverts to a negative number. I see why this is happening but I don't know how to have it run only once.
How do I prevent this from happening?
Upvotes: 1
Views: 39
Reputation: 467
Use This @Formula in TransactionAmount:
@If(TransactionType="Expense";-@Abs(@ThisValue);@Abs(@ThisValue))
Upvotes: 0
Reputation: 2359
Isn't it the user's responsibility that TransactionAmount is negative when they selected Expense as TransactionType? If you agree with me, you'd only need a Validation formula, like:
@If(TransactionType="Expense" & TransactionAmount<0; @Success;
TransactionType!="Expense" & TransactionAmount>0; @Success;
TransactionType="Expense" & TransactionAmount>=0; @Failure("Expense requires a negative amount. Please correct");
@Failure("A transaction requires a positive amount. Please correct"))
On the other hand, if you intend to correct the user, you might use the following translation formula:
@If((TransactionType="Expense" & TransactionAmount>0) | (TransactionType!="Expense" & TransactionAmount<0); -TransactionAmount; TransactionAmount)
PS I didn't live test these formulas... minor corrections may be necessary.
Upvotes: 1