{"title":"System.GuiAllowed() Method","url":"https://jonas-paprotka.de/docs/dev-itpro/developer/methods-auto/system/system-guiallowed-method/","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/methods-auto/system/system-guiallowed-method, 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/methods-auto/system/system-guiallowed-method","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":"Checks whether the AL code can show any information on the screen.","date":"2026-10-01","meta":{"topic":"reference"},"outline":[{"level":2,"title":"Syntax","slug":"syntax","at":127,"chars":189},{"level":2,"title":"Return Value","slug":"return-value","at":316,"chars":54},{"level":2,"title":"Remarks","slug":"remarks","at":370,"chars":515},{"level":2,"title":"Example","slug":"example","at":885,"chars":394},{"level":2,"title":"Example (Shopify integration)","slug":"example-shopify-integration","at":1279,"chars":837},{"level":2,"title":"Related information","slug":"related-information","at":2116,"chars":134}],"text":"> Version: _Available or changed with runtime version 1.0._\nChecks whether the AL code can show any information on the screen.\n## Syntax\n```al\nOk :=   System.GuiAllowed()\n```\n> NOTE\n> This method can be invoked using property access syntax.\n> NOTE\n> This method can be invoked without specifying the data type name.\n## Return Value\nOk\nType: ../boolean/boolean-data-type\n## Remarks\nThe System.GuiAllowed method returns true if the session where your AL code is running allows you to use methods that interact with the user, such as ../dialog/dialog-open-method, ../dialog/dialog-update-method, or ../dialog/dialog-close-method.\nIf the same codeunit needs to run both in the UI but also in the background (in a scheduled task or with a job queue entry) or in a web service call (SOAP/OData/API), then use `if GuiAllowed() then` calls to encapsulate AL code that interacts with the user.\n## Example\nThis example shows how to use the GuiAllowed method.\n```al\nif GuiAllowed then\n    Message('Code is running on a client.');\n```\nIf the code runs on a client, which means that the user interface is available, a message box appears with the following message.\nCode is running on a client\nIf the code runs in a web service call or in the background, then the message won't be displayed.\n## Example (Shopify integration)\nThis example shows how the Shopify integration uses GuiAllowed to provide feedback to the user when the code is running in the client, while allowing the business logic to also run in the background or being called from a web service.\n```al\nprocedure AddItemToShopify(Item: Record Item; ShopifyShop: Record \"Shpfy Shop\")\nvar\n    ProgressDialog: Dialog;\nbegin\n    if GuiAllowed then begin\n        ProgressDialog.Open(DialogMsg);\n        ProgressDialog.Update(1, SyncInformationProgressLbl);\n    end;\n\n    // business logic code here\n\n    if ShopifyShop.\"Sync Item Images\" = ShopifyShop.\"Sync Item Images\"::\"To Shopify\" then begin\n        if GuiAllowed then\n            ProgressDialog.Update(1, FinishSyncProgressLbl);\n        // business logic code here\n    end;\n\n    // some more business logic\nend;\n```\n## Related information\nsystem-data-type\nGet Started with AL<../../devenv-get-started>\nDeveloping Extensions<../../devenv-dev-overview>"}