GlideRecord object has empty objects if stringified
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-07-2022 09:16 AM - edited 11-07-2022 09:17 AM
Hi,
I am trying to understand GlideRecord API and I have used the below code as a background script, for testing:
var incidentGlideRecord = new GlideRecord('incident');
incidentGlideRecord.get('552c48888c033300964f4932b03eb092');
gs.print(JSON.stringify(incidentGlideRecord));
I was trying to see the object structure and how different fields are named. I was especially curious for e.g. the incident table's priority field, because it is a choice list that has a display value and a system value.
I was under the impression that incident.priority would also be an object, with a few parameters, however it's just returned as an empty object, and all other fields are also just empty objects, as you can see below (I have pasted the full JSON body that the above code prints).
However, even though incidentGlideRecord.priority is an empty object, if I just type gs.print(incidentGlideRecord.priority), it will actually return to me the priority value. Why is this?
Could someone please explain how this works?
{
"sys_meta":{
"active":"1",
"array":"0",
"attributes":"all_tables.query_hints=true,email_client=true,hasWorkflow=true,live_feed=true",
"audit":"1",
"calculation":"",
"choice":"1",
"choice_field":"",
"choice_table":"",
"create_roles":"",
"default_value":"",
"delete_roles":"itil_admin",
"dependent":"",
"dependent_on_field":"",
"display":"number",
"dynamic_creation":"0",
"dynamic_creation_script":"",
"dynamic_default_value":"",
"dynamic_ref_qual":"",
"element_reference":"0",
"filterable":"1",
"foreign_database":"",
"function_definition":"",
"function_field":"0",
"groupable":"1",
"help":"",
"hint":"",
"i18n_sortable":"1",
"internal_type":"collection",
"label":"Incident",
"language":"en",
"mandatory":"0",
"matchable":"1",
"max_length":"40",
"multi_text":"0",
"name":"incident",
"plural":"Incidents",
"primary":"0",
"read_only":"0",
"read_roles":"",
"reference":"",
"reference_cascade_rule":"",
"reference_floats":"0",
"reference_key":"",
"reference_qual":"",
"reference_qual_condition":"",
"reference_type":"",
"sizeclass":"67",
"sortable":"1",
"spell_check":"0",
"staged":"0",
"sys_package":"f6f312a4f98211108c8bd16244dfe7bd",
"sys_scope":"global",
"table_reference":"0",
"text_index":"1",
"type":"0",
"type_description":"collection",
"unique":"0",
"url":"",
"url_target":"",
"use_dynamic_default":"0",
"use_reference_qualifier":"simple",
"virtual":"0",
"widget":"",
"write_roles":"",
"xml_view":"0"
},
"parent":{
},
"made_sla":{
},
"caused_by":{
},
"watch_list":{
},
"upon_reject":{
},
"sys_updated_on":{
},
"child_incidents":{
},
"origin_table":{
},
"hold_reason":{
},
"task_effective_number":{
},
"approval_history":{
},
"number":{
},
"resolved_by":{
},
"sys_updated_by":{
},
"opened_by":{
},
"user_input":{
},
"sys_created_on":{
},
"sys_domain":{
},
"state":{
},
"sys_created_by":{
},
"route_reason":{
},
"knowledge":{
},
"order":{
},
"calendar_stc":{
},
"closed_at":{
},
"cmdb_ci":{
},
"delivery_plan":{
},
"impact":{
},
"contract":{
},
"active":{
},
"work_notes_list":{
},
"business_service":{
},
"business_impact":{
},
"priority":{
},
"sys_domain_path":{
},
"rfc":{
},
"time_worked":{
},
"rejection_goto":{
},
"expected_start":{
},
"opened_at":{
},
"business_duration":{
},
"group_list":{
},
"work_end":{
},
"reopened_time":{
},
"resolved_at":{
},
"caller_id":{
},
"approval_set":{
},
"subcategory":{
},
"wf_activity":{
},
"work_notes":{
},
"universal_request":{
},
"short_description":{
},
"close_code":{
},
"correlation_display":{
},
"delivery_task":{
},
"work_start":{
},
"assignment_group":{
},
"business_stc":{
},
"additional_assignee_list":{
},
"cause":{
},
"description":{
},
"origin_id":{
},
"calendar_duration":{
},
"notify":{
},
"sys_class_name":{
},
"service_offering":{
},
"close_notes":{
},
"closed_by":{
},
"follow_up":{
},
"parent_incident":{
},
"sys_id":{
},
"contact_type":{
},
"reopened_by":{
},
"incident_state":{
},
"urgency":{
},
"problem_id":{
},
"company":{
},
"reassignment_count":{
},
"activity_due":{
},
"assigned_to":{
},
"severity":{
},
"variables":{
},
"variable_pool":{
},
"hierarchical_variables":{
},
"comments":{
},
"sla_due":{
},
"approval":{
},
"comments_and_work_notes":{
},
"due_date":{
},
"sys_mod_count":{
},
"reopen_count":{
},
"sys_tags":{
},
"escalation":{
},
"upon_approval":{
},
"correlation_id":{
},
"location":{
},
"category":{
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-12-2022 06:38 AM
Surprised that there are no replies. Anyway:
The fields on a GlideRecord are actually GlideElement objects. JSON.stringify would have issues turning these into JSON.
I do not know how these GlideElements work or look like for now, would be nice to have more information on that.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-12-2022 06:58 AM
Hi @haz0r1337
Can you please explor below article. It might help you to understand this.
https://davidmac.pro/posts/2021-06-10-gliderecord-json/