Jump to content
Claris Engage 2025 - March 25-26 Austin Texas ×

Field formatting via script


This topic is 6293 days old. Please don't post here. Open a new topic instead.

Recommended Posts

Posted

I have a layout with 3 radiobuttons for setting priorities. (Urgent, Normal, Low)

I would like to change the color of the text in a different field based on the choice a user makes on the radio buttons.

Sorry these questions are elementary scripting questions...

What is the function that returns the value from a field? AND what is the function that can be used to change the color of a text in a field?

Posted (edited)

You don't need a script - only apply an Auto-Enter calculation to your [color:blue]text field (the one you wish to change colors). Insert this calculation in the Options, Auto-Enter, calculated value:

Case (

[color:blue]radiobutton = "Urgent" ; TextColor ( [color:blue]text ; RGB ( 255 ; 0 ; 0 ) ) ;

[color:blue]radiobutton = "Normal" ; TextColor ( [color:blue]text ; RGB ( 0 ; 255 ; 0 ) ) ;

TextColor ( [color:blue]text ; RGB (0 ; 0 ; 255 ) )

)

Change [color:blue]radiobutton to the name of your radio button field. Change [color:blue]text to the name of your text field. Change your colors as needed.

Be sure to uncheck (also on the Auto-Enter tab), the checkbox 'Do Not Replace Existing value.' Modify this calculation depending upon your needs. If you need help, let us know. :wink2:

Edited by Guest
Corrected calculation
Posted (edited)

Thank you very much.

One more thing.

Do I need to explicitly reference the radiobutton or the field if the change in color is expected in a different layout?

Edited by Guest
Posted (edited)

No, when you reference a field within the field definition window, then it applies to that field everywhere (because you specify the context within the calculation dialog itself).

UPDATE: Let me rephrase that a bit ... if you place that calculation on different layouts, it will work the same. But yes, you must reference the fields within it. And, if the layout is related to the table where the field exists, it will work.

In other words ... I have no idea what you are getting at and I'm punting right now. :wink2:

Edited by Guest
Posted (edited)

I tried conditional formatting. But I could not get more than two options in it. :)

I could not make it work, Michael - only work like boolean - format or not format. Please show how 3 different colors based upon 3 different criteria might look in one calculation ... I tried both value and formula.

And no, not too many questions! ROFLMFAO! I've only played with conditional formatting a few times now making text disappear by changing it to background color, etc but nothing multi-criteria. Ha ha!

Edited by Guest
Posted (edited)

Formula is test::radiobutton ≠"Low" and test::radiobutton = "Urgent" ( format red text )

Formula is [color:red]test::radiobutton ≠ "Urgent" and test::radiobutton = "Normal" ( format green text )

There might be simpler ways but this works. :crazy2:

UPDATE: First line removed - default unnecessary. Added: default color is whatever you wish - black or blue or ... ha ha

REMOVE THE PART IN RED!

Edited by Guest
Posted

Somehow I forgot this was based on a radio button - I was already thinking how to make this with ranges. With a radio button, it is indeed simpler, because only one condition can be true, so the order doesn't matter.:)

Formula is test::radiobutton = "Urgent" ( format red text )

Formula is test::radiobutton = "Normal" ( format green text )

Posted

I kept whittling on it. I was certain I had tried that at first and it didn't work. But it does now. I realize it was because I was attempting to put a Case() statement within it.

This topic is 6293 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.