Jump to content

Override Rule for Colors based on data


LyndaEngelage

Recommended Posts

I have several business cards that use the Event Rule, On Record start "Color From Data" which works great. But now I have a customer that wants his name and title as is using the "Color From Data" Rule and then his phone, email and address as black. Is there a way to override the "Color From Data Rule for this particular card without messing up all the rest of the cards.

 

I use FusionPro Designer 12.1.3 on a Mac M1 using Monterery OS.

Screen Shot 2023-02-21 at 3.43.12 PM.png

Link to comment
Share on other sites

Create a new color called "Custom" in the FusionPro -> Advanced -> Colors dialog.  Then change the rule to override Custom instead of Black.  Put the content that you want to have the rule applied to in the Custom color, and the text you want to stay Black in Black.

If you want the color change rule to apply only to certain records, you can convert it to JavaScript and then put its code into an "if" clause, with whatever condition you want.

Link to comment
Share on other sites

Thanks Dan,

I need the Color Change rule to apply to all except the one record AND the text frame containing the phone, email, and address. Where specifically would I insert the "if" statement so it only affects the one record and text frame?

// BEGIN: Rule converted from XML Template "Color From Data":
{
    // Overrides a color based on a data field value.
    // Please specify the appropriate values.
    // Begin XML Template selections //
    var FieldName = "BC Type Color"; // "Choose the field containing the color specification (RGB or CMYK):" (Required): FieldList
    var ColorName = "Custom"; // "Choose a color to override:" (Required): ColorList
    // End XML Template selections //
    var colorData = Trim(Field(FieldName)).replace(/^#/, ''); // strip leading pound/hash sign
    
    var parts = colorData.match(/[\d\.]+/gi); // decimal numbers, with non-numeric delimiters
    
    if (colorData.match(/^([0-9a-f]{6}|[0-9a-f]{8})$/i)) // 6 or 8 hex digits
        parts = colorData.match(/[0-9a-f]{2}/gi).map(function(val) { return parseInt(val, 16) / 255 * 100; });
    
    if (parts.length < 4)
        parts.unshift("RGB");
    
    //return parts;
    
    // TODO: Validate 3 parts for RGB, 4 parts for CMYK, and ranges.
    if (parts.length < 4)
        parts.concat([0,0,0,0]);
    
    parts.unshift(ColorName);
    CreateFusionProColor.apply(null, parts);
    
    FusionProColor.prototype.changeFrameBordersAndFills = true;
}
// END: Rule converted from XML Template "Color From Data"

Link to comment
Share on other sites

1 hour ago, LyndaEngelage said:

I need the Color Change rule to apply to all except the one record AND the text frame containing the phone, email, and address. Where specifically would I insert the "if" statement so it only affects the one record and text frame?

If you want it to apply only to a particular record, you can just put the "if" statement right at the start, before the opening curly brace {, like so:

// BEGIN: Rule converted from XML Template "Color From Data":
if (Field("Sports Property Name") == "THUNDERING HERD")
{
// ...

Then that entire block of code will be run conditionally.

To apply the color change just to a particular text frame, please refer to my previous post.  You need to make sure that only the text in that one frame is using the named color specified to override in the rule.

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...