Decision Table - Not getting expected value back in response.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-23-2024 09:28 AM
I am putting a business rule together that takes a set of values from the form after it is saved and applies checks several possible boolean fields if the conditions apply.
I am able to get the false value to return, but the true value comes back as undefined.
var current = new GlideRecord("sn_vdr_risk_asmt_vdr_tiering_assessment");
if (current.get("2fa55b5cc3314a10fefddcef0501318f")) {
try {
var inputs = {};
inputs['u_inferences'] = current; // Reference, Sys ID of the record
var dt = new sn_dt.DecisionTableAPI();
var response = dt.getDecisions('5f86416e93a94210561430747aba1073', inputs);
var result_elements = response.result_elements;
current.u_biometric_information = result_elements.u_biometric_information.getValue(); // True/False
current.u_commercial_information = result_elements.u_commercial_information.getValue(); // True/False
current.u_geolocation_information = result_elements.u_geolocation_information.getValue(); // True/False
current.u_identifiers = result_elements.u_identifiers.getValue(); // True/False
current.u_inferences = result_elements.u_inferences.getValue(); // True/False
current.u_internet_network_activity = result_elements.u_internet_network_activity.getValue(); // True/False
current.u_none = result_elements.u_none.getValue(); // True/False
current.u_sensory_data = result_elements.u_sensory_data.getValue(); // True/False
current.u_sensitive_personal_information = result_elements.u_sensitive_personal_information.getValue(); // True/False
current.u_protected_classification_characteristics = result_elements.u_protected_classification_characteristics.getValue(); // True/False
current.u_professional_employment_info = result_elements.u_professional_employment_info.getValue(); // True/False
current.u_other_personal_information = result_elements.u_other_personal_information.getValue(); // True/False
} catch (e) {
gs.log("Couldn't run this script Error: " + e);
}
gs.info(current.u_biometric_information);
gs.info(current.u_commercial_information);
gs.info(current.u_geolocation_information);
gs.info(current.u_identifiers);
gs.info(current.u_inferences);
gs.info(current.u_internet_network_activity);
gs.info(current.u_none);
gs.info(current.u_sensory_data);
gs.info(current.u_sensitive_personal_information);
gs.info(current.u_professional_employment_info);
gs.info(current.u_protected_classification_characteristics);
gs.info(current.u_other_personal_information);
}
I am running this currently as a background script against a record I would expect the u_commercial_information to be true, but it's getting undefined.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-23-2024 11:21 AM
@Murthy Ch @Jon23 The initial part of this script was created with the Code Snippet from the Decision Builder itself.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-23-2024 11:59 AM
@Aaron Duncan - try adding:
gs.info(JSON.stringify(result_elements));
Then inspect the output for the element.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-23-2024 12:18 PM
Here's the end of the results.
"xml_view":"false"},
"u_internet_network_activity":{},
"u_other_personal_information":{},
"u_commercial_information":{},
"u_sensory_data":{},
"u_inferences":{},
"u_biometric_information":{},
"u_protected_classification_characteristics":{},
"u_sensitive_personal_information":{},
"u_none":{},
"u_geolocation_information":{},
"u_professional_employment_info":{},
"u_identifiers":{},
"sys_id":{}}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-23-2024 03:35 PM - edited 04-23-2024 03:36 PM
Your decision table has an input of a choice table. In your script you are passing a record from the Tiering Assessment table:
var current = new GlideRecord("sn_vdr_risk_asmt_vdr_tiering_assessment"); if (current.get("2fa55b5cc3314a10fefddcef0501318f")) { try { var inputs = {}; inputs['u_inferences'] = current; // Reference, Sys ID of the record
Are you wanting to evaluate the PII choice on the current record? If Yes, then you will need to change the input to the table you are evaluating the record from. Then in your condition you can pick the field/value you want to compare.
Also, you should check that 'u_inferences' is the correct column name. You can confirm the input column name on the sys_decision_input table.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-23-2024 12:35 PM
Hi @Aaron Duncan,
It looks like you are using getDecisions() which would return an array of objects.
Change the following line of code
var result_elements = response.result_elements;
to
var result_elements = response[0].result_elements;
Or if you want to return a single answer, use getDecision() instead.
For additional details, refer to the documentation - https://developer.servicenow.com/dev.do#!/reference/api/washingtondc/server/DecisionTableAPI
Cheers