The CreatorCon Call for Content is officially open! Get started here.

Dynamic field labels

Alex Ward
Kilo Guru

Hi All,

I'm looking for some advice on how to achieve a dynamic field label. The field is an integer representing distance, I personally read distance in Miles, but this is obviously not a global preference. I've created a system property that handles the conversion from Miles -> Km and Km -> Miles. What I would like to do then is update the field label to read "Distance (Km)" or "Distance (Miles)" depending on the current sys_property value.

I know that a label CAN be change with client side script, weather it should be is another matter, thinking DOM manipulation best practice etc.

I know that the value of a property can be captured with a getProperty, but cannot use gs. in client side scripting......

How would others approach this? 

1 ACCEPTED SOLUTION

To capture the property, You need to write a display business rule and save it in a g_scratchpad variable.

In your display BR, add the following script

g_scratchpad.my_property = gs.getProperty('property_name');

And in your client script

g_form.setLabelOf('field_name', g_scratchpad.my_property);

View solution in original post

7 REPLIES 7

Alikutty A
Tera Sage

Hello Alex,

You can do it using the Glide Form API on the client side using setLabelOf function()

g_form.setLabelOf('field_name', 'Your Lable here');

Thanks!

sounds good, still wondering about getting the value of the property

To capture the property, You need to write a display business rule and save it in a g_scratchpad variable.

In your display BR, add the following script

g_scratchpad.my_property = gs.getProperty('property_name');

And in your client script

g_form.setLabelOf('field_name', g_scratchpad.my_property);

This is what i'm working towards at the moment after reading a post from Chuck.

 

I still have some concerned that this will be checking against the property and updating the label each time the tables is queried. This essentially voids the purpose of setting a system property (to avoid repeated checks and actions).