Question
How to convert the number with the "CR" part (credit) in the money field to a negative money value without "CR"?
For instance:
"$32.00CR" to "$ -32.00"
Answer
The above modification can be achieved with the following script.
//get the current value of the field
var value = Context.GetField("Field").Text;
//if "CR" part is found in a field the value is stripped off blanks, commas, $-sign, and "CR"
if (value.indexOf("CR") != -1){
value = value.replace("$", "").replace(" ", "").replace("CR", "");
//add "-" sign at the start of the line
value = "-" + value;
//assign an updated amount of money to a field
var new_amount = new AmountOfMoney(parseFloat(value), "$");
Context.GetField("Field").Value = new_amount;
}
The result of running this rule is shown below.
Comments
0 comments
Please sign in to leave a comment.