Jump to content
View in the app

A better way to browse. Learn more.

FMForums.com

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Field formatting via script

Featured Replies

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?

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

  • Author

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

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

Isn't this about version 9? Why not use conditional formatting? Old habits die hard? Are there enough questions here?

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

They need to be in reversed order, compared to what you would do in a Case() function.

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

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 )

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.

That reverse evaluation is going to take some getting used to. Thank you!

Create an account or sign in to comment

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.