Decision Table Error Using Business Rule
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-16-2024 08:55 AM
Hi,
Why Im getting this error? What am I doing wrong?
This is my Decision table:
This is my Business Rule:
(function executeRule(current, previous /*null when async*/ ) {
// Add your code here
var dt = new sn_dt.DecisionTableAPI();
var inputs = {}
inputs.u_category = current.category;
inputs.u_name = 'alon';
var response = dt.getDecision('542898e593be4210b73aba7efaba103a', inputs); //
var result_a = response.result_elements.u_answer;
gs.log('alonfsafas: ' + result_a);
})(current, previous);
This is the error that Im getting:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-16-2024 09:10 AM
Hi @Alon Grod
The error message you are encountering indicates that the response object returned by dt.getDecision() is null. This suggests that either the Decision Table API call failed or the specific Decision Table ID and/or inputs do not exist or are not processed correctly.
1. Check if the Decision Table API is returning a valid response.
2. Add error handling and logging to capture more details about what might be going wrong.
also Try this script :
try {
// Initialize DecisionTableAPI
var dt = new sn_dt.DecisionTableAPI();
// Prepare inputs for the Decision Table
var inputs = {};
inputs.u_category = current.category;
inputs.u_name = 'alon';
// Call the Decision Table and get the response
var response = dt.getDecision('542898e593be4210b73aba7efaba103a', inputs);
// Log the response object to see its structure
gs.log('Decision Table Response: ' + JSON.stringify(response));
// Check if response is valid
if (!response) {
gs.error('Decision Table Response is null');
return;
}
// Check if result_elements exists in the response
if (!response.result_elements) {
gs.error('result_elements is null in the Decision Table response');
return;
}
// Extract the result from the response
var result_a = response.result_elements.u_answer;
// Log the result
gs.log('Decision Table Answer: ' + result_a);
} catch (error) {
gs.error('Error executing Decision Table: ' + error.message);
}
please mark this Helpful and Accepted Solution if this helps you. Your action will help me and the community in understanding same requirements.
Thanks & Regards
Deepak Sharma
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-16-2024 09:19 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-16-2024 09:36 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-16-2024 01:12 PM
Hi @Alon Grod,
Try hard-coding the inputs for now, i.e. inputs.u_category = inquiry
If that works, it means you need to validate that your input is correct.
Also, I would recommend adding a Default result as well if applicable.
Cheers