UI Builder - Button visibility not working when system language is not english

rafas_10
Tera Guru

Hi everyone,

I've encountered an issue with a build in UI Builder. I created a custom button on a page and I've given a condition for that button to hide. If I use system language as English, it works perfectly, but when I use other language then English it doesn't work. 

Anyone has any ideia why?

Regards,

Sérgio

1 ACCEPTED SOLUTION

Incorrect Field Binding (Display Value vs Value)
Even checkbox fields can be exposed through display_value in UI Builder, which may be localized depending on how the data resource is configured.

Check this:

If your condition is using something like:
{{$data.checkbox_field == "Yes"}}

or

{{$data.checkbox_field.display_value == "Yes"}}

hen it will break in other languages where "Yes" is "Sí" or "Oui".

Fix: Use the actual value:

{{$data.checkbox_field == true}}

Or if bound via object
{{$data.checkbox_field.value == true}}

2. Data Resource Returns Localized Values
If you're using a data resource to query the HR Service, the checkbox field might be returned as a string instead of a boolean, depending on the response structure.

Example:

English response: "true" or "Yes"

Spanish response: "Sí"

French response: "Oui"

Fix:
In the data resource script (Scripted REST or GlideRecord), make sure the field is passed as a raw value, not getDisplayValue().

var gr = new GlideRecord('sn_hr_core_service');
if (gr.get(some_id)) {
return {
checkbox_field: gr.getValue('checkbox_field') // not getDisplayValue()
};
}

3. Form Configuration or Field Behavior Differences
In some environments, field behavior might vary due to:

Field being hidden or conditionally shown in non-English locales

Custom client scripts affecting behavior differently based on language

Different user roles or UI policies affecting visibility

Make sure:

The checkbox field is present and set consistently regardless of language

There’s no UI Policy or Client Script changing the value or hiding the field in localized forms



View solution in original post

4 REPLIES 4

danmjunqueira
Kilo Guru

Yes, this issue is likely related to how UI Builder handles conditional expressions when the system language is not English. Here's what’s most likely happening and how to fix it.

Why this happens:
UI Builder evaluates visibility conditions based on data bindings or static values. If your condition relies on string comparisons, for example:
{{$data.state == "Closed"}}

...then this works only when the language is English, because "Closed" is the display value shown in English. In other languages, it might be "Cerrado", "Fermé", or another translated value.

This causes the condition to fail, and the visibility rule does not behave as expected.

How to fix it:
1. Use system values instead of translated values
Instead of comparing against display values, use internal values like status codes or IDs. For example:

{{$data.state == "closed"}}

If the field stores system values (like "closed"), this will work regardless of the UI language.

2. Inspect the exact data behind the binding
Use the data panel in UI Builder to inspect what is actually returned in $data.state. Look for whether it's a label (translated string) or an internal value.

If it’s a translated label, you might need to:

Bind it to the value instead of display_value

Or change the source of the data being passed to the component

3. Use script-based logic in the data resource (if needed)
If necessary, create a data resource (like a Scripted REST API or server-side script) that returns values in a consistent format (not affected by language), and base your condition on that.

Summary
The issue happens because the condition uses translated strings, which vary by language.

Always compare against internal values, not translated labels.

Review the data bindings and confirm what value is actually being compared.




Ankur Bawiskar
Tera Patron
Tera Patron

@rafas_10 

please share what's the condition

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

The condition of the button is a data search to the hr service table. If a checkbox is ticket it should be hidden.

The thing is, why the same condition works for english and not other languages?

Incorrect Field Binding (Display Value vs Value)
Even checkbox fields can be exposed through display_value in UI Builder, which may be localized depending on how the data resource is configured.

Check this:

If your condition is using something like:
{{$data.checkbox_field == "Yes"}}

or

{{$data.checkbox_field.display_value == "Yes"}}

hen it will break in other languages where "Yes" is "Sí" or "Oui".

Fix: Use the actual value:

{{$data.checkbox_field == true}}

Or if bound via object
{{$data.checkbox_field.value == true}}

2. Data Resource Returns Localized Values
If you're using a data resource to query the HR Service, the checkbox field might be returned as a string instead of a boolean, depending on the response structure.

Example:

English response: "true" or "Yes"

Spanish response: "Sí"

French response: "Oui"

Fix:
In the data resource script (Scripted REST or GlideRecord), make sure the field is passed as a raw value, not getDisplayValue().

var gr = new GlideRecord('sn_hr_core_service');
if (gr.get(some_id)) {
return {
checkbox_field: gr.getValue('checkbox_field') // not getDisplayValue()
};
}

3. Form Configuration or Field Behavior Differences
In some environments, field behavior might vary due to:

Field being hidden or conditionally shown in non-English locales

Custom client scripts affecting behavior differently based on language

Different user roles or UI policies affecting visibility

Make sure:

The checkbox field is present and set consistently regardless of language

There’s no UI Policy or Client Script changing the value or hiding the field in localized forms