DecisionTableAPI getDecision is NOT returning correct content in response

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-06-2020 01:39 PM
I have a very simple background script I'm wanting to execute. It's straight from the documentation from ServiceNow on how to use the DecisionTableAPI. The problem that I'm having is that the response provides content that is showing an empty record for the sys_user_group response answer. Why is this API not returning the correct answer record.
If I create a Flow Designer Flow and embed the Decision table Action there, it returns values as expected. Therefore, I know my decision table and the answers are setup correctly. I've also pasted images of them below. Any help is appreciated.
SNOW DecisionTableAPI Documentation: I do see the docs say it's intended for use within scoped and global server-side scripts. It's also says that "The APIs below are intended for scoped applications and may behave differently in the global scope." Does differently mean not work at all?
One of my answers is set to default and when I can getDecisions, it still comes back with empty result for sys_user_group answers.
var dt = new sn_dt.DecisionTableAPI();
var input = {};
input['u_software_choice'] = 'in5';
gs.info("getDecision: " + JSON.stringify(dt.getDecision('73eb47e3dbebd850ddceaf29139619d0', input)));
Response:
{
"sys_meta": {
"active": "1",
"array": "0",
"attributes": "all_tables.text_index_translations=true,iterativeDelete=true",
"audit": "0",
"calculation": "",
"choice": "0",
"choice_field": "",
"choice_table": "",
"create_roles": "",
"default_value": "",
"delete_roles": "admin",
"dependent": "",
"dependent_on_field": "",
"display": "name",
"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": "Group",
"language": "en",
"mandatory": "0",
"matchable": "1",
"max_length": "40",
"multi_text": "0",
"name": "sys_user_group",
"plural": "Groups",
"primary": "0",
"read_only": "0",
"read_roles": "",
"reference": "",
"reference_cascade_rule": "",
"reference_floats": "0",
"reference_key": "",
"reference_qual": "",
"reference_qual_condition": "",
"reference_type": "",
"sizeclass": "0",
"sortable": "1",
"spell_check": "0",
"staged": "0",
"sys_package": "8e60bd33db103200f827fb16bf9619cd",
"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": "admin",
"xml_view": "0"
},
"parent": {},
"u_reporting_structure": {},
"roles": {},
"description": {},
"source": {},
"sys_updated_on": {},
"type": {},
"u_avp": {},
"points": {},
"u_approver_group": {},
"sys_id": {},
"sys_updated_by": {},
"default_assignee": {},
"sys_created_on": {},
"vendors": {},
"email": {},
"sys_created_by": {},
"manager": {},
"sys_mod_count": {},
"active": {},
"average_daily_fte": {},
"u_ldap_object_guid": {},
"sys_tags": {},
"u_vp": {},
"cost_center": {},
"hourly_rate": {},
"u_director": {},
"name": {},
"exclude_manager": {},
"include_members": {}
}
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-06-2020 04:58 PM
Not sure about the question. What is the expected returned value? Is there suppose to be any match on the condition "input['u_software_choice'] = 'in5'; ? Difficult to determine from the blacked out screenshots.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-07-2020 12:58 PM
Yes there are two decisions shown in the screen shots and I'm expecting to have one of them return. Like I mentioned, when I put this into a Flow, it works fine. Therefore, I know my decision tree is setup correctly and working. The part that is not working (and the focus of my question) is why is the script not working as coded? I used the SN docs to create this.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-20-2021 08:36 AM
It happened the same to me...the weird thing is that when I print the whole object JSON.stringify(response) everything is empty, but if I print response.name and response.sys_id it prints the correct values.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-25-2022 11:22 PM
Thanks for this - that answer helped me too - I hadn't quite grasped that the response is in the form of a GlideRecord.