0

I currently have a flow that calls an invocable method in order to perform a callout. From the flow, I pass in several arguments to the invocable method. However, sometimes, these arguments can be null. When the flow gets fired though, I get an error saying Argument cannot be null.. I assumed this was because I was trying to pass a null value into a method in my Apex file, so I put in checks for null invocable variables. However, I keep getting the same error. Code below:

public class Test {
    public class FlowInputs{
        @InvocableVariable
        public string sfId;
        
        @InvocableVariable
        public string ring_group_name;
        
        @InvocableVariable
        public string ring_group_extension;
    }

    @InvocableMethod(label='Test Invocable' description='Test Invocable' category='Account')
    public static void TestMethod(List<FlowInputs> inputs) {
        string sfId = inputs[0].sfId == null ? '' : inputs[0].sfId;
        string ring_group_name = inputs[0].ring_group_name == null ? '' : inputs[0].ring_group_name;
        string ring_group_extension = inputs[0].ring_group_extension == null ? '' : inputs[0].ring_group_extension;
        FutureAddRingGroupFusion(sfId, ring_group_name, ring_group_extension);
    }

    @future(callout=true)
    public static void FutureAddRingGroupFusion(string sfId, string ring_group_name, string ring_group_extension) {
        //do stuff here
    }
}

In this example, ring_group_name could sometimes be null when I call this flow. I originally thought that by doing a check and sending in a blank string, it would resolve the issue, but apparently not.

3
  • 1
    How do you know the error is coming because of a parameter being null in InvocableVariable or Flow? Did you check with debug logs where the flow actually throws the error? Nov 20 '20 at 20:01
  • N.B. you need to bulkify the invocable as when the flow executes on a batch, it will call the invocable once with a list of FlowInputs
    – cropredy
    Nov 20 '20 at 22:06
  • You were right, the null parameter was happening inside the invocable method elsewhere. Thank you!
    – user90334
    Nov 23 '20 at 17:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.