How to call decision table from script include and get result in output
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-27-2024 02:57 AM
Hi Team,
I have created a decision table and created 3 inputs {Country (reference), location (reference), and employment type(choice)} and in answer, there is a choice field called Delivery.
Now I need to call the decision table from the script include and want to get the value of the answer for that I have written below script and I am trying with background script now for testing but I am getting undefined in response
var location = '';
var country = '';
var hire_type = '';
var req_for = new GlideRecord('sys_user');
req_for.addQuery('sys_id', "112da5bdc3e671d006f8d4af05013164"); // user syd_id
req_for.query();
if (req_for.next()) {
location = req_for.u_onboarding_location.getDisplayValue();
country = req_for.u_onboarding_location.country;
hire_type = req_for.u_onboarding_employment_type.getDisplayValue();
}
gs.print(location + " " + country + " " + hire_type);
var decisionID = "";
var grD = new GlideRecord('sys_decision');
grD.addQuery('name', 'table name');
grD.query();
if (grD.next()) {
decisionID = grD.sys_id;
}
gs.print(decisionID);
var dtpi = new sn_dt.DecisionTableAPI();
var decisionInputs = {
u_country: country,
u_location: location,
u_employment_type :hire_type
};
var response = dtpi.getDecision(decisionID, decisionInputs);
var bb = response.result_elements.delivery;
gs.print(bb);
In response.result_elementst I am getting undefined, Can someone help me here with the correct code?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-27-2024 03:04 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-27-2024 09:59 PM
Hi @Yashsvi
Thanks for the response,
I have gone through all the articles but I am not getting where I am making mistake.
Can you please guide me on where I need to adjust my code?
Regards,
Lucky