The CreatorCon Call for Content is officially open! Get started here.

Automate decision table to update via flow

Varun Sharma
Tera Expert

Hi Team, 

 

I've a requirement where i've created a decision table which contain multiple output result for single input value. 

I want a flow to run via service catalogue ,so the requestor can update the values in Decision table and keep it updated. 

What scripting API can i use, i'm not able to understand how the output values are stored and if i can pick and choose what i want to update . 

kindly assist. 

 
1 ACCEPTED SOLUTION

Varun Sharma
Tera Expert

Hi Everyone , 

 

anyone faces similar requirements in future, 

here is how i did it , 

 

 var decisionTableGR = new GlideRecord('sys_decision');
    decisionTableGR.addQuery('sys_id', decisionTableSysId);
    decisionTableGR.query();
    if (decisionTableGR.next()) {
        var decisionAnswerGR = new GlideRecord('sys_decision_question');
        decisionAnswerGR.addEncodedQuery('decision_table=table_SYS ID ^active=true'');
        decisionAnswerGR.query();
        while (decisionAnswerGR.next()) {

            var resultElements = decisionAnswerGR.answer.toString();
            var grDecisionResult = GlideRecord('sys_decision_multi_result');
            grDecisionResult.get(resultElements);

            grDecisionResult.result_elements.variableONTable = newVariableValue;
            grDecisionResult.update();

        }

View solution in original post

7 REPLIES 7

@Ankur Bawiskar , my business requirement is that we create approval based on the category, 

these owners and subowners for the category often change, earlier these values were hard coded, i've now updated these values in Decision table and i'm automating the updation of owner and subowners via the Service catalogue. 

 

Regards, 

Varun Sharma

@Varun Sharma 

Sorry that's not the actual purpose why we use Decision tables.

Decision tables cannot be updated via script etc

They are to be configured from UI by admins or developers.

If there is change in requirement an admin can simply navigate to that decision table and update it and publish that.

If my response helped please mark it correct and close the thread so that it benefits future readers.

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

Varun Sharma
Tera Expert

Hi Everyone , 

 

anyone faces similar requirements in future, 

here is how i did it , 

 

 var decisionTableGR = new GlideRecord('sys_decision');
    decisionTableGR.addQuery('sys_id', decisionTableSysId);
    decisionTableGR.query();
    if (decisionTableGR.next()) {
        var decisionAnswerGR = new GlideRecord('sys_decision_question');
        decisionAnswerGR.addEncodedQuery('decision_table=table_SYS ID ^active=true'');
        decisionAnswerGR.query();
        while (decisionAnswerGR.next()) {

            var resultElements = decisionAnswerGR.answer.toString();
            var grDecisionResult = GlideRecord('sys_decision_multi_result');
            grDecisionResult.get(resultElements);

            grDecisionResult.result_elements.variableONTable = newVariableValue;
            grDecisionResult.update();

        }