{"revision":"c10276e953456835cdbb1f3a60d58ae1980be353","document":{"id":774,"path":"api-reference/server-api-reference/GlideApplicationProperty.md","title":"GlideApplicationProperty - Scoped, Global","bundle":null,"doc_type":null,"release":"australia","body":"\n# GlideApplicationProperty - Scoped, Global\n\nThe GlideApplicationProperty API provides methods to get and set application property values for a specific domain.\n\nApplication properties enable service providers to customize application functionality based on the domain. Instead of only having a single system property \\(System Property \\[sys\\_properties\\] table\\) that defines the functionality for all domains and users, application properties can be implemented to define functionality for specific domains.\n\nTo access this API you must activate the Domain Support - Domain Extensions Installer \\(com.glide.domain.msp\\_extensions.installer\\) plugin.\n\nFor additional information on domain-specific application properties, see [Domain-separated application properties](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/platform-security/ds-application-properties.md).\n\n**Parent Topic:**[Server API reference](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/server-api-reference/api-server.md)\n\n## GlideApplicationProperty - getValue\\(String name, String domainSysId\\)\n\nReturns the value for the specified application property and domain sys\\_id.\n\nThe list of available application properties is located in the Application Properties \\[sys\\_application\\_property\\] and Application Property Values \\[sys\\_application\\_property\\_value\\] tables.\n\n**Note:** If the specified domain is a child domain, and there is not an application property for the child domain, the method returns the parent domain application property, if available.\n\n<table id=\"table_qzq_b2c_llb\" class=\"parameters\"><thead><tr><th>\n\nName\n\n</th><th>\n\nType\n\n</th><th>\n\nDescription\n\n</th></tr></thead><tbody><tr><td>\n\nname\n\n</td><td>\n\nString\n\n</td><td>\n\nName of the application property to return.**Note:** If the application is not global, you must prefix the name of the sys\\_application\\_property with the application's scope.\n\n</td></tr><tr><td>\n\ndomainSysId\n\n</td><td>\n\nString\n\n</td><td>\n\nOptional. Sys\\_id of the domain associated with the application property.Default: Session domain\n\n</td></tr></tbody>\n</table><table id=\"table_rzq_b2c_llb\" class=\"returns\"><thead><tr><th>\n\nType\n\n</th><th>\n\nDescription\n\n</th></tr></thead><tbody><tr><td>\n\nString\n\n</td><td>\n\nValue of the specified application property for the specified domain. If **domainSysId** is not passed in the call, then returns the session domain.If the specified application property doesn't exist, returns the same-name system property value.\n\n If the user does not have access rights to the specified domain, throws an exception and no value is returned.\n\n</td></tr></tbody>\n</table>This example shows how to create a new application property and override its value for ACME and Cisco domains.\n\n```\nvar MY_APP_PROP_NAME = 'my-app-prop';\nvar ACME_DOMAIN_ID = 'c90d4b084a362312013398f051272c0d';\nvar CISCO_DOMAIN_ID = 'c90f91924a362312001bdefae0f35d68';\n\n// create a new app_config entry:\nvar now_GR = new GlideRecord('sys_application_property');\nnow_GR.name = MY_APP_PROP_NAME; \nnow_GR.default_value = 'my-app-prop-default_value'; \nnow_GR.insert();\n\n// Override the value for ACME domain, catch exception if user can't access the specified domain\ntry {\n  GlideApplicationProperty.setValue(MY_APP_PROP_NAME, 'prop-value-ACME', ACME_DOMAIN_ID);\n  gs.info('Value for ACME domain: ' + GlideApplicationProperty.getValue(MY_APP_PROP_NAME, ACME_DOMAIN_ID));\n} catch (ex) {\n  gs.info('Exception: ' + ex);\n}\n\n// Override the value for Cisco domain -- assuming that the current session domain is Cisco. Notice that we don't pass domain-id explicitly\nsession.setDomainID(CISCO_DOMAIN_ID); // NOTE: this API is not available from non-global scope (use domain-picker to switch to Cisco)\ngs.info('Domain: ' + session.getCurrentDomainID());\nGlideApplicationProperty.setValue(MY_APP_PROP_NAME, 'prop-value-Cisco');\ngs.info('Value for current session (Cisco) domain: ' + GlideApplicationProperty.getValue(MY_APP_PROP_NAME));\n\n```\n\nOutput:\n\n```\n*** Script: Value for ACME domain: prop-value-ACME\n*** Script: Domain: c90f91924a362312001bdefae0f35d68\n*** Script: Value for current session (Cisco) domain: prop-value-Cisco\n```\n\n## GlideApplicationProperty - setValue\\(String name, String value, String domainSysId\\)\n\nStores the specified value in the specified application property for the specified domain, or the current session domain if not specified.\n\nThe following are guidelines for using this method:\n\n-   The application property is not created if its name contains one of the following strings:\n    -   glide.properties.blacklist\n    -   glide.properties.no\\_db\\_override\n    -   glide.properties.safe\\_overrides\n    -   glide.properties.maint\\_write\\_roles\n-   The application property is not created if there is an existing system property with the same name, and the system property is marked as private.\n-   The application property is not created if there is an existing system property and the application property does not reference it.\n-   The name of the application property in the sys\\_application\\_property table is prefixed with the application's scope if it is not global.\n-   This method cannot be called from a different scope.\n\n<table id=\"table_qzq_b2c_llb\" class=\"parameters\"><thead><tr><th>\n\nName\n\n</th><th>\n\nType\n\n</th><th>\n\nDescription\n\n</th></tr></thead><tbody><tr><td>\n\nname\n\n</td><td>\n\nString\n\n</td><td>\n\nName of the application property to save.**Note:** If the application is not global, you must prefix the name of the sys\\_application\\_property with the application's scope.\n\n</td></tr><tr><td>\n\nvalue\n\n</td><td>\n\nString\n\n</td><td>\n\nValue to store in the specified application property.\n\n</td></tr><tr><td>\n\ndomainSysId\n\n</td><td>\n\nString\n\n</td><td>\n\nOptional. Sys\\_id of the domain associated with the application property.Default: Current session domain\n\n</td></tr></tbody>\n</table><table id=\"table_vpy_dlc_llb\" class=\"returns\"><thead><tr><th>\n\nType\n\n</th><th>\n\nDescription\n\n</th></tr></thead><tbody><tr><td>\n\nBoolean\n\n</td><td>\n\nFlag that indicates whether the save operation was successful.Valid values:\n\n-   true: Value was successfully saved.\n-   false: An error occurred and the application property was not created/updated.\n\n If the user does not have access rights to the specified domain, throws an exception and no value is returned.\n\n</td></tr></tbody>\n</table>This example shows how to create a new application property and override its value for ACME and Cisco domains.\n\n```\nvar MY_APP_PROP_NAME = 'my-app-prop';\nvar ACME_DOMAIN_ID = 'c90d4b084a362312013398f051272c0d';\nvar CISCO_DOMAIN_ID = 'c90f91924a362312001bdefae0f35d68';\n\n// create a new app_config entry:\nvar now_GR = new GlideRecord('sys_application_property');\nnow_GR.name = MY_APP_PROP_NAME; \nnow_GR.default_value = 'my-app-prop-default_value'; \nnow_GR.insert();\n\n// Override the value for ACME domain, catch exception if user can't access the specified domain\ntry {\n  GlideApplicationProperty.setValue(MY_APP_PROP_NAME, 'prop-value-ACME', ACME_DOMAIN_ID);\n  gs.info('Value for ACME domain: ' + GlideApplicationProperty.getValue(MY_APP_PROP_NAME, ACME_DOMAIN_ID));\n} catch (ex) {\n  gs.info('Exception: ' + ex);\n}\n\n// Override the value for Cisco domain -- assuming that the current session domain is Cisco. Notice that we don't pass domain-id explicitly\nsession.setDomainID(CISCO_DOMAIN_ID); // NOTE: this API is not available from non-global scope (use domain-picker to switch to Cisco)\ngs.info('Domain: ' + session.getCurrentDomainID());\nGlideApplicationProperty.setValue(MY_APP_PROP_NAME, 'prop-value-Cisco');\ngs.info('Value for current session (Cisco) domain: ' + GlideApplicationProperty.getValue(MY_APP_PROP_NAME));\n\n```\n\nOutput:\n\n```\n*** Script: Value for ACME domain: prop-value-ACME\n*** Script: Domain: c90f91924a362312001bdefae0f35d68\n*** Script: Value for current session (Cisco) domain: prop-value-Cisco\n```\n\n"}}