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.

Changing color of fields by calculation

Featured Replies

I have found the function "If ( CODE="1" ; TextColor(NAME;RGB(150;0;0))". I have a field "name" and a field "code". If "code"=1 I want to turn the "name" field text red. I cant get this to work any ideas? TIA

Ivan

  • Author

NM

You can't change the colour of the text field self this way, only the content of the calculation field which uses the TextColor function.

Actually, I believe you can. With FM7 you can use that as an auto-enter calculation on your Name field.

Be sure to unclick right under 'by calculation' the box that says "Do not replace existing value." In this way, the text color will continually change depending upon the Code.

Cool! laugh.gif

It works (but I had to reenter the values, after applying the auto enter calculation to the text field).

  • Author

code=1

changecolor field "If (CODE=1 ; TextColor ( NAME ; RGB (250; 0 ; 0 ) ) ; TextColor (NAME ; RGB ( 0 ; 0 ; 0 ) ) )"

Only thing that changes is the contents of "word field" "name" in changecolor field. If only I could make "name field" = "changecolor field"

  • Author

create script to:

Set name field = changecolor field.

Need a "SetField" command in the calculation collection, this would be a snap.

Ivan

Why are you using another field called changecolor? This calculation attached to your Name field will allow the name to change to reddish when Code = 1. TextColor(Name; (Code = 1) * 9830400 ). This is the most efficient way to code it. Just be sure to unclick right under 'by calculation' the box that says "Do not replace existing value." That's the key.

This next one will only display the name in red if Code = 1 otherwise the field will remain empty. If(Code; TextColor (Name; RGB ( 150; 0; 0) )). I had to throw this in ... I really like it with auto-enter! It is nicer than requiring validation on a field. Instead of insisting a field remain empty, it quietly and sweetly removes the data instead. This auto-enter ability (in FM7) replaces many script steps and validation requirements, such as formatting for phone numbers, etc. This particular calc (not allowing data in a field) makes me smile and I have come up with all kinds of uses for it. wink.gif I have Manager's box for 'Manager Comments Only'. If Privilege Set isn't Manager, the User's entry doesn't stick.

Detlev said... but I had to reenter the values, after applying the auto enter calculation to the text field.

Unclick 'Do Not Evaluate...' in the calculation dialog. But you are correct, I believe, in that you'd need to force a recalculation if you wish to change the color of the text in a standard field (pre auto-enter calculation).

You could loop with one script step: Set Field [Code, Code]. It doesn't matter what field it sets but Code (being numeric 1) might be quicker. Even Replace Contents (same calc). Simply setting any field to itself will force an update according to the record's auto-enter calculation.

Create an account or sign in to comment

Important Information

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

Account

Navigation

Search

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.