Interested in a ServiceNow event built for developers? Registration for now[dev]26 is officially open!

Decision table API

kali
Tera Contributor

Hi All, I have a decision table with four inputs called category,location,Ticke id , category , location both are reference and ticket id is choice and i am using the below to get the answer 

var decision = new sn_dt.getDecisionTableAPI();

decision.getDecision('decisiontableID',inputs)'

and var inputs={'u_category:':'123','u_location':'538375',u_ticket_id:''} since ticket id is a choice type we have created a decision table record with ticket id is not empty then how should i create the input object and when i am passing my input it is giving me the default answer

 

Thanks for your help on this

3 REPLIES 3

Ankur Bawiskar
Tera Patron

@kali 

For choice input you should pass choice internal value and not Label

For reference input pass sysId

Updated script

var inputs = {
    u_category: '123',       // sys_id of the category record
    u_location: '538375',    // sys_id of the location record
    u_ticket_id: 'choice_value' // internal value of the choice
};

var dt = new sn_dt.DecisionTableAPI();
var response = dt.getDecision('DECISION_TABLE_SYS_ID', inputs);

gs.info(JSON.stringify(response));

💡 If my response helped, please mark it as correct and close the thread 🔒— this helps future readers find the solution faster! 🙏

Regards,
Ankur
Certified Technical Architect  ||  10x ServiceNow MVP  ||  ServiceNow Community Leader

Hi @Ankur Bawiskar ,

In some of the decision table records the Ticket id selected is not empty or is empty then how should i pass them in the inputs object,hope you got my question

@kali 

you can define row conditions as this

 

  • u_ticket_id is empty

  • u_ticket_id is not empty

  • u_ticket_id = INC

  • u_ticket_id = REQ

  • etc.

 

To match empty you should pass empty string

u_ticket_id: ''

To match for not empty you should pass any valid non empty choice

u_ticket_id: 'INC'

💡 If my response helped, please mark it as correct and close the thread 🔒— this helps future readers find the solution faster! 🙏

Regards,
Ankur
Certified Technical Architect  ||  10x ServiceNow MVP  ||  ServiceNow Community Leader