Decision Table: Use input as variable within the result

VernYerem
Tera Expert

We're looking to help our teams with consistency in naming conventions within our account request. 
This can be done with a series of IF statements in the flow, but I'm looking at trying to use a decision table. We have some simple decision tables that work great. The problem with this task is that the naming conventions vary depending on what's being requested, so the result needs to be the whole output rather than just something I can add via flow variables. 

I was hoping that is could just reference the input in brackets or something, but I haven't been able to get it to work. Here is an example I created within my PDI:

VernYerem_0-1764097526760.png


Can I use inputs as variables within the result? If not, any suggestions on how to handle this better than an if statement for each choice?

1 ACCEPTED SOLUTION

adityahubli
Tera Contributor

Hello @VernYerem ,

By Decision table it is not possible to access dynamic values in result set , so custom action is also way to acheive your requirnment  so mentioning some screenshot for your refference.

 

Mark this as helpfull if it helps you and accept as solution .

 

Regards ,

Aditya

 

 

p1.pngp2.pngp3.pngp4.pngp5.pngp6.png

View solution in original post

3 REPLIES 3

lauri457
Giga Sage

I'd say decision tables are more fit to make complex conditions into more manageable artefacts as opposed to using huge script blocks with conditions. But in this case the condition isn't that complex as there is one variable being evaluated. You could just create a single action with a script similar to below which will essentially achieve the same without the overhead from the no code abstraction.

const a = "std",
    fn = "firstname",
    ln = "lastname",
    nbr = "123";
let san, upn;
switch (a) {
    case "std":
        san = `${fn}.${ln}`;
        upn = `${nbr}.${ln}@example.com`;
        break;
    case "desktopadmin":
        san = `${ln}.${nbr}.DA`
        upn = `DA.${ln}.${nbr}@example.local`;
        break;
    case "serveradmin":
        san = `SA.${nbr}`
        upn = `SA${nbr}@example.com`;
        break;
    default:
        break;
}

 

Ankur Bawiskar
Tera Patron
Tera Patron

@VernYerem 

decision tables are mostly used for simpler logic

In your case it's somehow complex so better create a flow variable and handle the IF ELSE logic there using "Set Flow Variables" flow logic

Then use that in your flow.

💡 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  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

adityahubli
Tera Contributor

Hello @VernYerem ,

By Decision table it is not possible to access dynamic values in result set , so custom action is also way to acheive your requirnment  so mentioning some screenshot for your refference.

 

Mark this as helpfull if it helps you and accept as solution .

 

Regards ,

Aditya

 

 

p1.pngp2.pngp3.pngp4.pngp5.pngp6.png