Calling invocable method from "Custom Apex Action" does not recognize invocable variable/parameter

  • 1
  • Question
  • Updated 2 years ago
Trying to use the action framework to directly call Apex, but the skuid page doesn't seem to recognize my invocable variable when it is actually executed. Is there any better documentation out there on this? It would be a great feature to utilize.

Here's what I have set up in the Skuid configuration:


And here's my apex code:
@InvocableMethod(label='Recalculate Region Assignment')
global static List<AssignmentResponse> setOwner(List<AssignmentRequest> assignmentRequests) { List<AssignmentResponse> responses = new List<AssignmentResponse>(); AssignmentResponse res = new AssignmentResponse(); responses.add(res); System.debug('uh... hello?'); Id accountId = assignmentRequests[0].accountId; Account account = [SELECT Id, GroupsRegion__c FROM Account WHERE Id = :accountId]; Repository.RegionAssignment regionAssignment = new Repository.RegionAssignment(); new AssignmentService(regionAssignment).setOwner(account); update account; return responses; } global class AssignmentRequest { @InvocableVariable(required=true description='The account Id needed' label='Account Id') global Id accountId; } global class AssignmentResponse { @InvocableVariable global String message = 'OHHH yeaaaaaa!'; }

Calling this action results in the following error:



Seems strange that the invocable variable is not found, considering the skuid configuration was able to populate it in my first screenshot. Any idea what I could be doing wrong?
Photo of Matt Mitchener

Matt Mitchener

  • 150 Points 100 badge 2x thumb

Posted 2 years ago

  • 1
Photo of Peter Hale

Peter Hale, Employee

  • 330 Points 250 badge 2x thumb
I think you make the variable public, instead of global.  So the response could look like this:

    global class AssignmentRequest {
        @InvocableVariable(required=true description='The account Id needed' label='Account Id')
        public Id accountId;
    }
(Edited)
Photo of Matt Mitchener

Matt Mitchener

  • 150 Points 100 badge 2x thumb
Changing it to "public" didn't seem to do anything, but when I changed it to "accountIds" it is giving me a new error:

(Edited)
Photo of Matt Mitchener

Matt Mitchener

  • 150 Points 100 badge 2x thumb
Ended up fixing this by deleting my remote action and recreating it... I guess it got corrupted somehow. Might have been from changing some of the variable naming in Apex (since they are likely dynamically generated by skuid)
(Edited)