{"revision":"c10276e953456835cdbb1f3a60d58ae1980be353","document":{"id":1009,"path":"api-reference/server-api-reference/c_GlideElementDescriptorScopedAPI.md","title":"GlideElementDescriptor - Scoped, Global","bundle":null,"doc_type":null,"release":"australia","body":"\n# GlideElementDescriptor - Scoped, Global\n\nThe GlideElementDescriptor API provides information about individual fields in a glide record.\n\nThere is no constructor for this class. Use the GlideElement or GlideRecord getED\\(\\) method to obtain a GlideElementDescriptor object.\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## GlideElementDescriptor - getAttachmentEncryptionType\\(\\)\n\nReturns the encryption type used for attachments on the element's table.\n\nThis method is for use with the Edge Encryption plugin.\n\n|Name|Type|Description|\n|----|----|-----------|\n|None| | |\n\n|Type|Description|\n|----|-----------|\n|String|The encryption type used on attachments. Returns null if attachments on the element's table are not being encrypted.|\n\n```\nvar grInc = new GlideRecord('incident');\ngrInc.query('priority', '1');\n\nvar field = grInc.getElement('priority');\nvar ed = field.getED();\n\nvar isEdge = ed.getAttachmentEncryptionType();\ngs.info(isEdge);\n\n```\n\nOutput:\n\n```\nnull\n```\n\n## GlideElementDescriptor - getEncryptionType\\(\\)\n\nReturns the element's encryption type.\n\nThis method is for use with the Edge Encryption plugin.\n\n|Name|Type|Description|\n|----|----|-----------|\n|None| | |\n\n|Type|Description|\n|----|-----------|\n|String|The element's encryption type. Returns null if the element is not encrypted.|\n\n```\nvar grInc = new GlideRecord('incident');\ngrInc.query('priority', '1');\n\nvar field = grInc.getElement('priority');\nvar ed = field.getED();\n\nsEdge = ed.getEncryptionType();\ngs.info(isEdge);\n```\n\nOutput:\n\n```\nnull\n```\n\n## GlideElementDescriptor - getInternalType\\(\\)\n\nReturns the element's internal data type.\n\n|Name|Type|Description|\n|----|----|-----------|\n|None| | |\n\n<table id=\"table_scc_gv3_yr\" 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\nThe element's internal data type.Possible values:\n\n-   boolean\n-   char\n-   collection\n-   conditions\n-   date\n-   decimal\n-   documentation\\_field\n-   domain\\_id\n-   due\\_date\n-   email\n-   field\\_name\n-   file\\_attachment\n-   float\n-   glide\\_date\n-   glide\\_date\\_time\n-   glide\\_duration\n-   glide\\_list\n-   GUID\n-   html\n-   image\n-   integer\n-   long\n-   longint\n-   multi\\_two\\_lines\n-   journal\n-   journal\\_input\n-   numeric\n-   order\\_index\n-   password\n-   ph\\_number\n-   reference\n-   script\n-   script\\_plain\n-   string\n-   sys\\_class\\_name\n-   table\\_name\n-   template\\_value\n-   timer\n-   translated\\_field\n-   url\n-   user\\_image\n-   user\\_input\n-   user\\_roles\n-   video\n-   workflow\n\n</td></tr></tbody>\n</table>```\nvar grInc = new GlideRecord('incident');\ngrInc.query('priority', '1');\n \nvar field = grInc.getElement('priority');\nvar ed = field.getED();\n \nvar isEdge = ed.getInternalType();\ngs.info(isEdge);\n```\n\nOutput:\n\n```\ninteger\n```\n\n## GlideElementDescriptor - getLabel\\(\\)\n\nReturns the element's label.\n\n|Name|Type|Description|\n|----|----|-----------|\n|None| | |\n\n|Type|Description|\n|----|-----------|\n|String|The element's label.|\n\n```\nvar grInc = new GlideRecord('incident');\ngrInc.query('priority', '1');\n \nvar field = grInc.getElement('priority');\nvar ed = field.getED();\n \nvar isEdge = ed.getLabel();\ngs.info(isEdge);\n```\n\nOutput:\n\n```\nPriority\n```\n\n## GlideElementDescriptor - getLength\\(\\)\n\nReturns the element's length.\n\n|Name|Type|Description|\n|----|----|-----------|\n|None| | |\n\n|Type|Description|\n|----|-----------|\n|Number|The element's size.|\n\n```\nvar grInc = new GlideRecord('incident');\ngrInc.query('priority', '1');\n \nvar field = grInc.getElement('priority');\nvar ed = field.getED();\n \nvar isEdge = ed.getLength();\ngs.info(isEdge);\n```\n\nOutput:\n\n```\n40\n```\n\n## GlideElementDescriptor - getName\\(\\)\n\nReturns the element's name.\n\n|Name|Type|Description|\n|----|----|-----------|\n|None| | |\n\n|Type|Description|\n|----|-----------|\n|String|The element's name.|\n\n```\nvar grInc = new GlideRecord('incident');\ngrInc.query('priority', '1');\n \nvar field = grInc.getElement('priority');\nvar ed = field.getED();\n \nvar isEdge = ed.getName();\ngs.info(isEdge);\n```\n\nOutput:\n\n```\npriority\n```\n\n## GlideElementDescriptor - getPlural\\(\\)\n\nReturns the element's plural label.\n\n|Name|Type|Description|\n|----|----|-----------|\n|None| | |\n\n|Type|Description|\n|----|-----------|\n|String|The element's plural label.|\n\n```\nvar now_GR = new GlideRecord('incident');\nnow_GR.query();\nvar ed = now_GR.getED();\ngs.info(ed.getPlural());\n```\n\nOutput:\n\n```\nIncidents\n```\n\n## GlideElementDescriptor - hasAttachmentsEncrypted\\(\\)\n\nReturns true if an encrypted attachment has been added to the table.\n\nThis method is for use with the Edge Encryption plugin.\n\n|Name|Type|Description|\n|----|----|-----------|\n|None| | |\n\n|Type|Description|\n|----|-----------|\n|Boolean|Returns true if an encrypted attachment has been added to the table.|\n\n```\nvar grInc = new GlideRecord('incident');\ngrInc.query('priority', '1');\n\nvar field = grInc.getElement('priority');\nvar ed = field.getED();\n\nvar isEdge = ed.hasAttachmentsEncrypted();\ngs.info(isEdge);\n```\n\nOutput:\n\n```\nfalse\n```\n\n## GlideElementDescriptor - isAutoOrSysID\\(\\)\n\nReturns true if the element is an automatically generated or system field.\n\nAutomatically generated and system fields cannot be encrypted. This method is for use with the Edge Encryption plugin.\n\n|Name|Type|Description|\n|----|----|-----------|\n|None| | |\n\n|Type|Description|\n|----|-----------|\n|Boolean|True if the element is automatically generated or a system field.|\n\n```\nvar grInc = new GlideRecord('incident');\ngrInc.query('priority', '1');\nvar field = grInc.getElement('priority');\nvar ed = field.getED();\n\nisEdge = ed.isAutoOrSysID();\ngs.info(isEdge);\n\n```\n\nOutput:\n\n```\nfalse\n```\n\n## GlideElementDescriptor - isChoiceTable\\(\\)\n\nReturns true if the element is defined as a dropdown choice in its dictionary definition.\n\nChoice fields cannnot be encrypted.\n\n|Name|Type|Description|\n|----|----|-----------|\n|None| | |\n\n|Type|Description|\n|----|-----------|\n|Boolean|Returns true if the element is defined as a dropdown choice. Returns true even if there are no entries defined in the choice table. The last choice type, suggestion, does not return true.|\n\n```\nvar grInc = new GlideRecord('incident');\ngrInc.query('priority', '1');\n\nvar field = grInc.getElement('priority');\nvar ed = field.getED();\n\nvar isChoiceTable = ed.isChoiceTable();\ngs.info(isChoiceTable);\n```\n\nOutput:\n\n```\ntrue\n```\n\n## GlideElementDescriptor - isEdgeEncrypted\\(\\)\n\nReturns true if an element is encrypted.\n\nThis method is for use with the Edge Encryption plugin.\n\n|Name|Type|Description|\n|----|----|-----------|\n|None| | |\n\n|Type|Description|\n|----|-----------|\n|Boolean|Returns true if the element is encrypted, false otherwise.|\n\n```\nvar grInc = new GlideRecord('incident');\ngrInc.query('priority', '1');\n\nvar field = grInc.getElement('priority');\nvar ed = field.getED();\n\nvar isEdge = ed.isEdgeEncrypted();\ngs.info(isEdge)\n```\n\nOutput:\n\n```\nfalse\n```\n\n## GlideElementDescriptor - isEncrypted\\(\\)\n\nReturns whether the field represented by this descriptor is configured for field encryption.\n\nUse this method to programmatically detect encrypted fields before reading or writing sensitive data, or to enforce access policies based on a field's encryption status.\n\nRequired plugins: Field Encryption Starter \\(com.glide.field.encryption.starter\\). Without this plugin, isEncrypted\\(\\) returns false.\n\n|Name|Type|Description|\n|----|----|-----------|\n|None| | |\n\n<table id=\"table_kx1_tmp_z3c\" 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 field is configured for field encryption.\n\n Valid values:\n\n-   true: Field is configured for field encryption.\n-   false: Field isn't encrypted, or the Field Encryption Starter \\(com.glide.field.encryption.starter\\) plugin isn't active.\n\n</td></tr></tbody>\n</table>The following server-side script uses isEncrypted\\(\\) to check whether the short\\_description field on the Incident table is encrypted before logging its value. Copy this into a Background Script or Business Rule on your instance to test.\n\n**Note:** Use the [GlideRecord - getED\\(\\)](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/server-api-reference/c_GlideRecordAPI.md) or [Scoped GlideElement - getED\\(\\)](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/server-api-reference/c_GlideElementScopedAPI.md) method to obtain a GlideElementDescriptor object.\n\n```\n// Retrieve a sample Incident record\nvar gr = new GlideRecord('incident');\ngr.setLimit(1);\ngr.query();\n\nif (gr.next()) {\n    // Get the GlideElement for the field you want to inspect\n    var element = gr.getElement('short_description');\n\n    // Retrieve the descriptor from the element\n    var descriptor = element.getED();\n\n    // Check whether the field is configured for Field Encryption\n    if (descriptor.isEncrypted()) {\n        gs.info('short_description is encrypted. Value: ' + element.getDisplayValue());\n    } else {\n        gs.info('short_description is NOT encrypted. Value: ' + gr.getValue('short_description'));\n    }\n}\n```\n\nOutput \\(unencrypted\\):\n\n```\nshort_description is NOT encrypted. Value: Unable to connect to network\n```\n\nOutput \\(encryption enabled on the field\\):\n\n```\nshort_description is encrypted. Value: Unable to connect to network\n```\n\n## GlideElementDescriptor - isMandatory\\(\\)\n\nDetermines whether the element is mandatory and must contain a value before the record can be saved.\n\n|Name|Type|Description|\n|----|----|-----------|\n|None| | |\n\n<table id=\"table_yxq_xwv_shb\" 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 associated element is mandatory and must contain a value before the record containing the element can be saved.Possible values:\n\n-   true: element must contain a value; mandatory field\n-   false: element does not have to contain a value\n\n</td></tr></tbody>\n</table>This example shows how to check whether the name field is mandatory.\n\n```\nvar isRecordValid;\nvar now_GR = new GlideRecord('my_table');\nvar field = now_GR.getElement('name');\nvar elementDescriptor = field.getED();\nnow_GR.query();\nwhile (now_GR.next()) {\nif (elementDescriptor.isMandatory() && !now_GR.name) {\n       isRecordValid = false;\n  }\n}\n```\n\n## GlideElementDescriptor - isVirtual\\(\\)\n\nReturns true if the element is a virtual element.\n\nA virtual element is a calculated field as set by the dictionary definition of the field. Virtual fields cannot be encrypted.\n\n|Name|Type|Description|\n|----|----|-----------|\n|None| | |\n\n|Type|Description|\n|----|-----------|\n|Boolean|Returns true if the element is a virtual element.|\n\n```\nvar grInc = new GlideRecord('incident');\ngrInc.query('priority', '1');\n\nvar field = grInc.getElement('priority');\nvar ed = field.getED();\n\nvar isVirtual = ed.isVirtual();\ngs.info(isVirtual);\n```\n\nOutput:\n\n```\nfalse\n```\n\n"}}