Hi - I am trying to apply the below script to align my currency numbers when there is a negative number. For example, I want to align the numbers as such instead of the default alignment. When I try to use the script below, I get an error message " can not call method charAt from undefined". This script works fine outside of Connect.
809,000.00
(150,152.25)
NumberInStringFormatToAlign = record.tables.CurrentQTR[“Contribution”];
var LastCharacterInString = record.tables.CurrentQTR[“Contribution”].charAt(record.tables.CurrentQTR[“Contribution”].length - 1);
I guess you lack the row level in the CurrentQTR table and a field reference is missing. The following refers to the “Contribution” field in the first row of the “CurrentQTR” data table:
var foo = record.tables[“CurrentQTR”][0].fields[“Contribution”];
Guess the field type of “Contribution” is Currency, in that case you would need to cast the value to a string first. Consider the following (notice the toString();):
var NumberInStringFormatToAlign = record.tables["CurrentQTR"][0].fields["Contribution"].toString();
In data mapper, it is a string ( ex. -809,000.00). I format it as currency no symbol so that it shows as (809,000.00).
I added your suggestion above and still getting the same error ( cannot call method “charAt” of undefined. I also changed the script a little bit. I now have the below script. The error message goes away but there are no results.