Jump to content

Change all Variable text fields to a specific color


hansyddem

Recommended Posts

Does anyone know of a way to change the color of all variable text fields at one time? 

I have a job with A LOT of variable text fields. Rather than manually changing the colors, I was hoping that I could build an on RecordStartRule that will change the color of all the variable fields, I can do a spot check on the output. When ready, I'd be able to turn off the rule and the original colors in the document would be used.  

I created the OnRecordStart rule below but it didn't work. Anyone have any ideas? 

if (((((((((((((((((((((Field("F1") != "") || (Field("F2") != "")) || (Field("F3") != "")) || (Field("F4") != "")) || (Field("F5") != "")) || (Field("F6") != "")) || (Field("F7") != "")) || (Field("F8") != "")) || (Field("F9") != "")) || (Field("F10") != "")) || (Field("F11") != "")) || (Field("F12") != "")) || (Field("F13") != "")) || (Field("F14") != "")) || (Field("F15") != "")) || (Field("F16") != "")) || (Field("F17") != "")) || (Field("F18") != "")) || (Field("F19") != "")) || (Field("F20") != "")) || (Field("F21") != ""))
{
   return "<span>" + "<color name=\"Variable\">" + "</span>";
}

 

Link to comment
Share on other sites

You can do this by overwriting the values of the fields with FusionPro.Composition.AddVariable

var fields2change = ["F1","F2","F3","F4","F5","F6","F7","F8","F9","F10","F11","F12","F13","F14","F15","F16","F17","F18","F19","F20","F21"];

for (var i in FusionPro.Fields)
{
	if (fields2change.indexOf(i) > -1 && FusionPro.Fields[i] != "")
		FusionPro.Composition.AddVariable(i, '<span><color name="Red">' + FusionPro.Fields[i] + '</span>', true);
}

In this example, first list out the field names you want to change, then loop through all the fields searching for just the ones you want to change and if they contain a value. If you find one, then you change the value using FusionPro.Composition.AddVariable to the color you want, in this case I used "Red".

  • Like 1
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...