{"title":"StyleExpr Property","url":"https://jonas-paprotka.de/docs/dev-itpro/developer/properties/devenv-styleexpr-property/","by":"JOP-AL","license":"Copyright (c) Microsoft Corporation. CC BY 4.0, https://creativecommons.org/licenses/by/4.0/; code samples MIT. From https://learn.microsoft.com/en-us/dynamics365/business-central/dev-itpro/developer/properties/devenv-styleexpr-property, MicrosoftDocs/dynamics365smb-devitpro-pb at 828b6ee (2026-11-19). Changed: includes filled in, links to this site, and for agents shortened without dropping a fact.","credit":"Microsoft Corporation, CC BY 4.0","origin":"https://learn.microsoft.com/en-us/dynamics365/business-central/dev-itpro/developer/properties/devenv-styleexpr-property","source":{"name":"Business Central developer and IT pro docs","repo":"https://github.com/MicrosoftDocs/dynamics365smb-devitpro-pb","commit":"828b6ee72fcd75755627cd6011f3d20899217ab2","date":"2026-11-19"},"checked":"2026-11-19","description":"Sets whether the format that is specified in the Style Property is applied to text in a field.","date":"2026-10-01","meta":{"topic":"reference"},"outline":[{"level":2,"title":"Applies to","slug":"applies-to","at":459,"chars":38},{"level":2,"title":"Remarks","slug":"remarks","at":497,"chars":942},{"level":2,"title":"Related information","slug":"related-information","at":1439,"chars":40}],"text":"> Version: _Available or changed with runtime version 1.0._\nSets whether the format that is specified in the Style Property is applied to text in a field. For fields in a CueGroup control, this property is used to configure the color of the color indicator on the cue.\nThis note pertains to backward compatibility only. If the property is set to Boolean true or false, it sets whether the format specified in the Style property is applied to text in a field.\n## Applies to\n Page Label\n Page Field\n## Remarks\n> NOTE\n> The information in this topic is mainly applicable to formatting the text of page fields.\nIn the devenv-style-property, you can see the available styles. The StyleExpr property is used to set the style for a field based on a condition. The StyleExpr property is a Boolean expression that determines whether the style is applied to the field. If the expression evaluates to true, the style is applied. If the expression evaluates to false, the style isn't applied.\nYou can use a conditional setting of styles by inserting the conditional code in, for example, the ../triggers-auto/page/devenv-onaftergetrecord-page-trigger. Remember to cover all cases in else branches to avoid incorrect styles. For example:\n```al\nif (MyField = 'abc')\n    then\n        MyStyleVar := 'Ambiguous'\n    else\n        MyStyleVar := 'Favorable'\n```\n> NOTE\n> To use a variable for the StyleExpr property, it must be set as a global page variable.\n## Related information\ndevenv-properties"}