Hi all,
I want to set the foreground color of a row’s field in a foundset based on a value.
Code so far:
var vAge = plugins.dialogs.showQuestionDialog(‘Aging’, ‘Please select aging term in days. Serial numbers for items \nopen longer than the period selected will appear in red.’, ‘10’, ‘15’, ‘20’, ‘Cancel’);
if (vAge == ‘Cancel’)//Exit method
{
return;
}
var vDate = utils.dateFormat(new Date(2006,10,10),‘MM-dd-yyyy HH:mm:ss’);// Put date specified into date format. Months start at 0!
controller.find();
text1 = ‘#imported’;// # ignores case
date1 = ‘>’ + vDate + ‘|MM-dd-yyyy’;
controller.search();
if (databaseManager.getFoundSetCount(foundset) == 0)
{
application.beep();
plugins.dialogs.showInfoDialog(‘Find Result’, ‘No records were found.’, ‘OK’);
return;
}
//Loop thru foundset evaluating dates
var vMax = controller.getMaxRecordIndex();//Get number in foundset
for (row = 1; row <= vMax; row++)
{
controller.setSelectedIndex(row);//Go to row one
//Calculate difference in days
var vToday = new Date(2006,10,30);//Leave formatted as ‘Thu Nov 30 00:00:00 PST 2006’
var vDate = date1;
var vDifference = 0;//Difference between Today and Date data
vDifference = vToday - vDate;
var vDays = 0;//Difference expressed in days
vDays = Math.round(vDifference/(10006060*24));
//divide by number of milliseconds in a day and round off
if (vDays > vAge)//Difference versus dialog selection
{
//Set / Get foreground color
elements.text3.fgcolor = ‘#ff3333’;
text3 = ‘Red’;
var vColor = elements.text3.fgcolor;
application.output(row + ’ ’ + vDays + ’ ’ + vColor + ’ ’ + text3);
}
else
{
//Set / Get foreground color
elements.text3.fgcolor = ‘#000000’;
text3 = ‘Black’;
var vColor = elements.text3.fgcolor;
application.output(row + ’ ’ + vDays + ’ ’ + vColor + ’ ’ + text3);
}
}
Application Output =
1 19 #ff3333 Red
2 18 #ff3333 Red
3 17 #ff3333 Red
4 16 #ff3333 Red
5 15 #000000 Black
It looks like each specific field’s color has been set, but the column takes on the color of the last field processed. i.e. the column is either all red or all black. What am I missing?