Jump to content

Returning text in a specific color depending on a user input field value


bobk_IMbranded

Recommended Posts

I have created a FP template that asks for a user to input custom text. I would like to display the text in one field in a specific color - in this case the corporate color of the user's dealership - based on the value of the other field.

 

I've set up a template that has two user input fields: "Dealer" and "Message". "Dealer" is associated with the [log in] info and will pre-populate with a value. Since each DealerName is equal to a specific corporate color, it should return that color to the text in my field "Message".

(all my colors are setup in the Advanced/Colors in FusionPro)

 

The rule I created looks like this:

 

if (Field("Dealer") == "DealerName") //from the user's login profile

{

return <color name = "DodgeRed">Field("Message")</color>;

else return <color name = "Black">Field("Message")</color>;

}

 

It's not working though. What did I do wrong?

Link to comment
Share on other sites

I have created a FP template that asks for a user to input custom text. I would like to display the text in one field in a specific color - in this case the corporate color of the user's dealership - based on the value of the other field.

 

I've set up a template that has two user input fields: "Dealer" and "Message". "Dealer" is associated with the [log in] info and will pre-populate with a value. Since each DealerName is equal to a specific corporate color, it should return that color to the text in my field "Message".

(all my colors are setup in the Advanced/Colors in FusionPro)

 

The rule I created looks like this:

 

if (Field("Dealer") == "DealerName") //from the user's login profile

{

return <color name = "DodgeRed">Field("Message")</color>;

else return <color name = "Black">Field("Message")</color>;

}

 

It's not working though. What did I do wrong?

Try this:

if (Field("Dealer") == "DealerName") //from the user's login profile
   return  '<color name="DodgeRed">' + TaggedTextFromRaw(Field("Message")) + '</color>';
//else
   return  '<color name="Black">' + TaggedTextFromRaw(Field("Message")) + '</color>';

You need either single or double quotes to denote a literal string, and you need to use the plus sign to concatenate strings, including those returned from functions such as Field(). Also, you don't want curly braces around both the primary return statement and the "else" clause.

Link to comment
Share on other sites

Thanks! would that be the same for a box fill? Say, for a background color that was to change color in the same fashion?

No, to change a frame's fill color, you would do something like this, probably in OnRecordStart:

FindTextFrame("YourFrameName").fillColorName = "Red";

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...