Expand my Community achievements bar.

SOLVED

XDP Form - referencing current row DDL value and setting colour of value

Avatar

Level 4

I have a paragraph number field in a repeating table row. I cannot seem to get the code correct, which is as follows:

 

form1.Page1.SubChecklist.Table.Detail.ParaNum::ready:layout - (JavaScript, client)

var vCurrentRow = this.parent.index;
if (Table.Detail[" + vCurrentRow + "].DDLAlign.rawValue == "No" || Table.Detail[" + vCurrentRow + "].DDLPrompt.rawValue == "No"){
if (xfa.host.version < {
this.resolveNode("$").fontColor = "249, 11, 8";

}
else {
var CaptionColorBackup = this.resolveNode("$").caption.font.fill.color.value;
this.resolveNode("$").font.fill.color.value = "249, 11, 8";
this.resolveNode("$").caption.font.fill.color.value = CaptionColorBackup;

}
}

 

The above script is running on the field "ParaNum" as indicated. If I use a "this." reference, the color change triggers properly for the first row.

 

In attempting to write the appropriate code for repeating rows, I cobbled together the above code, which, does not trigger.

 

I know I am missing a fundamental within the code so I am asking for help here as I cannot figure out why the code is not triggering. 

 

The check is on values further in the row which have the value of "No" and sets the paragraph number field to red.

 

The "< 8)" disappears in the code above for Acrobat versioning. Please disregard this in the above.

 

Please help.

1 Accepted Solution

Avatar

Correct answer by
Level 4

@MorisMonk 

 

This worked for me:

var rowCount = Table._Detail.count;
for (var i=0;i<rowCount;i++)
 
if (Table.Detail.all.item(i).DDLAlignment.rawValue == "No" || Table.Detail.all.item(i).DDLPrompts.rawValue == "No" || Table.Detail.all.item(i).DDLPunctuation.rawValue == "No" || Table.Detail.all.item(i).DDLSpelling.rawValue == "No" || Table.Detail.all.item(i).DDLWidow.rawValue == "No" || Table.Detail.all.item(i).DDLProgram.rawValue == "No" || Table.Detail.all.item(i).DDLIVData.rawValue == "No" || Table.Detail.all.item(i).DDLNoPub.rawValue == "No"){
if (xfa.host.version <8) {
  Table.Detail.all.item(i).ParaNum.fontColor = "249, 11, 8";
 
  }
  else {
  var CaptionColorBackup = this.resolveNode("$").caption.font.fill.color.value;
  Table.Detail.all.item(i).ParaNum.font.fill.color.value = "249, 11, 8";
  Table.Detail.all.item(i).ParaNum.caption.font.fill.color.value = CaptionColorBackup;
 
  }
}

 

View solution in original post

9 Replies

Avatar

Level 5

Have you tried with

if (DDLAlign.rawValue == "No" || DDLPrompt.rawValue == "No") {

Avatar

Level 4

Yes, some time ago, and, that works for the first row. However, for subsequent rows it does not.

All the fields are within the same row, and, the issue I see is that the instanceManager iteration of the field (or row) is not being referenced for subsequent rows or correctly for the initial row. From the start, there is only one row, and, depending on the user needs they can enter a number to add many additional rows.

Therefore, the reference to instanceManager and using that value within the row fields may be needed. However, my approach is not working. That is where I need to have the code fixed. Perhaps the row should hold [*] for the instanceManager iteration or a code change to the way I have written it above.

Avatar

Level 4

This simplified code works ONLY on the first row:

 

form1.Page1.SubChecklist.Table.Detail.ParaNum::ready:layout - (JavaScript, client)

 

if (this.DDLAlign.rawValue == "No" || this.DDLPrompt.rawValue == "No"){
if (xfa.host.version <8)  {
this.fontColor = "249, 11, 8";

}
else {
var CaptionColorBackup = this.resolveNode("$").caption.font.fill.color.value;
this.font.fill.color.value = "249, 11, 8";
this.caption.font.fill.color.value = CaptionColorBackup;

}
}

Avatar

Level 5

If that code is in ParaNum::ready:layout then I believe it should work.

FYI I did a little test and it works for me.

Avatar

Level 4

Yes, as I mentioned it does work. but, ONLY on the first row. Not additional rows added via instanceManager.

I believe what is required is code which references the instanceManager to identify the current instance and therefore the color change for NOs on DDL values will change THAT row's paragraph number text color.

 

Avatar

Level 5

Just to clarify, what you are trying to achieve works for me i.e. each row working as expected, not ONLY the first row.

Avatar

Level 4

Moris, I appreciate the input and contribution. The rows are dynamically created. At the outset the table has only ONE row. The user then can set the number of rows needed. As such, the rows that are generated have a dynamic name. These are new rows that exist only after the user sets the number of rows they require, they are iterations of the initial row. So, referencing the fields in the row may require code to identify the instanceManager generated row names. As such, it only works on the first row on my form.

Avatar

Level 4

Requesting assistance with this from @radzmar on this topic.

Avatar

Correct answer by
Level 4

@MorisMonk 

 

This worked for me:

var rowCount = Table._Detail.count;
for (var i=0;i<rowCount;i++)
 
if (Table.Detail.all.item(i).DDLAlignment.rawValue == "No" || Table.Detail.all.item(i).DDLPrompts.rawValue == "No" || Table.Detail.all.item(i).DDLPunctuation.rawValue == "No" || Table.Detail.all.item(i).DDLSpelling.rawValue == "No" || Table.Detail.all.item(i).DDLWidow.rawValue == "No" || Table.Detail.all.item(i).DDLProgram.rawValue == "No" || Table.Detail.all.item(i).DDLIVData.rawValue == "No" || Table.Detail.all.item(i).DDLNoPub.rawValue == "No"){
if (xfa.host.version <8) {
  Table.Detail.all.item(i).ParaNum.fontColor = "249, 11, 8";
 
  }
  else {
  var CaptionColorBackup = this.resolveNode("$").caption.font.fill.color.value;
  Table.Detail.all.item(i).ParaNum.font.fill.color.value = "249, 11, 8";
  Table.Detail.all.item(i).ParaNum.caption.font.fill.color.value = CaptionColorBackup;
 
  }
}