XDP Form - referencing current row DDL value and setting colour of value | Community
Skip to main content
LucreciousDFF
Level 4
March 5, 2024
Solved

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

  • March 5, 2024
  • 3 replies
  • 1463 views

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.

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by LucreciousDFF

@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;
 
  }
}

 

3 replies

Level 4
March 6, 2024

Have you tried with

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

LucreciousDFF
Level 4
March 6, 2024

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;

}
}

Level 4
March 6, 2024

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.

 


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

LucreciousDFF
Level 4
March 6, 2024

Requesting assistance with this from @radzmar on this topic.

LucreciousDFF
LucreciousDFFAuthorAccepted solution
Level 4
March 7, 2024

@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;
 
  }
}