Adding more inputs into Flow Designer Action even with the limit reached

matthew_hughes
Kilo Sage

One thing that I've noticed when creating a Flow Designer Action, there is a limit to the number of inputs that are allowed. 

 

Because it this, it means that I've had to create two separate Flow Designer Actions:

matthew_hughes_0-1769179384042.png

 

matthew_hughes_1-1769179400846.png

 

I was just wondering if anyone has come across this issue before and if there's a way of combining two Flow Designer Actions into one.

 

10 REPLIES 10

Itallo Brandão
Tera Guru

Hi there,

To answer your questions directly:

  1. Has anyone seen this? Yes. While there is no hard "limit" on the number of inputs, the Flow Designer UI (Action Designer) starts to lag significantly and becomes unmanageable when you have too many individual inputs (like the 40+ you have there).

  2. Is there a way to combine them into one? Yes. The best way to handle this amount of data in a single Action is to stop using individual String/Boolean inputs for every field.

    The Solution: Use a JSON Object Instead of creating 50 separate inputs, create one input:

    • Name: payload

    • Type: JSON (or String)

    How to implement:

    1. Pass all your data (Name, Description, Owners, etc.) as a single JSON object from your Flow.

    2. In your Action's Script Step, parse this single input and update the record dynamically:

     
    (function execute(inputs, outputs) {
        var gr = new GlideRecord('cmdb_ci_business_app');
        if (gr.get(inputs.bus_app_sysid)) {
            var data = JSON.parse(inputs.payload);
    
            // Automatically updates any field sent in the JSON
            for (var key in data) {
                if (gr.isValidField(key)) {
                    gr.setValue(key, data[key]);
                }
            }
            gr.update();
        }
    })(inputs, outputs);

    This allows you to update 5, 50, or 100 fields using just one Action, solving both the split-action issue and the UI lag.


    If this response helps clarify the platform behavior and solve your requirement, please mark it as Accepted Solution. This helps the community grow and assists others in finding valid answers faster.

Best regards,
Brandão.

Hi @Itallo Brandão Thanks for looking into this.

 

So do I go into a Flow Designer Action and create a new input called 'payload' with a type of JSON and make it mandatory?

 

Are you able to provide an example of how I could update my variables? Some will only get update if the true/false inputs were selected.

Hi Matthew,

You are spot on with your understanding.

1. The Action Setup Yes, go into your Action Inputs and:

  • Create a New Input.

  • Label: Payload

  • Name: payload

  • Type: JSON (or String).

  • Mandatory: Yes.

2. Handling the "Update if True" Logic This is the best part: You handle the logic inside the Flow (before calling the Action). This keeps your Action simple and reusable.

Instead of passing the "True/False" flag to the Action, you simply don't include the field in the JSON if the flag is false. The Action script I provided earlier only updates fields that are actually present in the JSON.

How to implement (Step-by-Step):

Step A: In your Flow, add a "Script" Action (Core > Script) You will use this step to "build" the packet based on your variables.

  • Input Variable: Create one called ritm (drag your Requested Item record here).

  • Script:

(function execute(inputs, outputs) {
    var variables = inputs.ritm.variables; 
    var payloadObj = {}; // Start with an empty object

    // --- LOGIC: Only add to payload IF the checkbox is True ---

    // Example 1: Update Application Name?
    if (variables.update_application_name == 'true') {
        // We only add the 'name' key if the check is true
        payloadObj.name = variables.new_application_name.toString();
    }

    // Example 2: Update Owner?
    if (variables.update_business_owner == 'true') {
        // Map 'u_business_owner' (backend name) to the variable value
        payloadObj.u_business_owner = variables.new_business_owner.toString();
    }

    // ... Repeat this block for your other fields

    // Final Output: Convert the object to a String
    outputs.payload_string = JSON.stringify(payloadObj);
    
})(inputs, outputs);


Step B: Call your Custom Action

  • Add your custom Action to the Flow.

  • In the Payload input, drag the payload_string data pill from the Script Step you just created (Step A).

Why this works: If the user unchecks "Update Description", your script (Step A) will not add the short_description key to payloadObj. When the Action runs, it sees the key is missing and simply ignores that field, leaving the existing data on the record alone.


If this response helps clarify the implementation, please mark it as Accepted Solution.


Best regards,
Brandão.

Hi @Itallo Brandão 

 

Thanks for your help on this, so would it be like the below:

 

matthew_hughes_0-1769416910061.png

matthew_hughes_1-1769416943937.png



On my subflow, what do I select as Payload:

matthew_hughes_2-1769421461785.png

 

 

Hi @matthew_hughes ,

You are very close, but you have currently mixed two different approaches, which is why you are confused about the Payload input.

The Issue:

  • In your Action Inputs (Image 1), you created a Payload input. This expects the JSON to be built outside in the Flow.

  • But in your Script Step (Image 2), you are building the JSON inside the Action using the RITM.

  • Result: You don't need both. If you build it inside, you don't need to ask for it as an input.

The Fix (Recommended Path): Since you have already written the logic inside the Action Script (Image 2), let's stick to that method as it is easier to finish.

Step 1: Clean up Action Inputs Go to your Action Inputs and DELETE the Payload input.

  • Why? Your script calculates the payload automatically from the RITM, so you don't need to pass it manually from the Subflow. This solves your question "What do I select as Payload?" — the answer is: nothing, just remove it!

Step 2: Update the Script Your current script (Image 2) builds the object but does not save it. It stops after creating payloadObj. You need to add the update logic at the end.

Replace your script with this complete version:

(function execute(inputs, outputs) {
    // 1. Build the Payload Object from RITM Variables
    var variables = inputs.ritm.variables;
    var payloadObj = {}; 

    // Example logic: Only add to payload IF the checkbox is True
    if (variables.update_application_name == 'true') {
        payloadObj.name = variables.new_application_name.toString();
    }
    
    if (variables.update_business_owner == 'true') {
        payloadObj.u_business_owner = variables.new_business_owner.toString();
    }
    
    // ... Add all your other field checks here ...


    // 2. SAVE the changes to the Database
    // This part was missing in your screenshot
    var gr = new GlideRecord('cmdb_ci_business_app');
    
    // Use the SysID input to find the record
    if (gr.get(inputs.bus_app_sysid)) {
        
        // Loop through your payload and update the fields
        for (var key in payloadObj) {
            gr.setValue(key, payloadObj[key]);
        }
        
        gr.update(); // Commit changes
    }

})(inputs, outputs);

Summary of Changes:

  1. Action Inputs: Only Bus App SysID and RITM. (Delete Payload).

  2. Subflow: You will simply drag the RITM pill into the RITM input. You won't see a Payload input anymore.

If this solution solves your issue, please mark it as Accepted Solution.

Best regards, Brandão.