Run Data Source Action Merge Syntax

  • 1
  • Question
  • Updated 3 months ago
  • Answered
I am trying to run an Apex data source action from a row action.  What is the merge syntax to use the current working row to pass as a record to the Apex class?  As of right now, running the row action results in a null-object error.  Below is my Apex class and action setup:



 

Photo of Danny Hartley

Danny Hartley

  • 434 Points 250 badge 2x thumb

Posted 4 months ago

  • 1
Photo of Mike Dwyer

Mike Dwyer

  • 3,390 Points 3k badge 2x thumb
This is working for me:

global class ccmVistationSlotFromTemplate {

    @InvocableMethod( label='CCM Vistation Slot From Template')
    global static void createSlots( List<Parameters> parameterList ) {

        Parameters parameter = parameterList[0];
        
        List<CCM_Visitation_Slot_Template__c> templateList = new List<CCM_Visitation_Slot_Template__c>(
            [select ...  from CCM_Visitation_Slot_Template__c where Id = :parameter.id]);

       ...//rest of my code, using templateList
    }
    
    global class Parameters {
        @InvocableVariable(required=true description='Template Record Id' label='Record Id') 
            public Id id;
    }

The label "Record Id" from that last line appears in the skuid page designer, as a separate field below the Apex Action label. (The description "Template Record Id" is ?/help-text for the field.) I pass the record id as {{Id}}.



The parameter List will support multiple parameters by cloning the @InvocableVariable statement inside the Parameters class. Each parameter will have its own field in the page designer. I my have read that a List is required; if not, it seems it would be a preferred method to easily allow future expansion.

Photo of Danny Hartley

Danny Hartley

  • 434 Points 250 badge 2x thumb
Do you need to add the "Record ID" to the List<Paramaters> parameterList or is that being done automatically?
Photo of Mike Dwyer

Mike Dwyer

  • 3,390 Points 3k badge 2x thumb
That happens automatically. The Parameters class will have whatever properties you include as Invocable Variables. (So maybe you would not need a List to support multiple; I may have stated that inaccurately before.)
Photo of Mark DeSimone

Mark DeSimone, Official Rep

  • 11,050 Points 10k badge 2x thumb
Hi Danny and Mike,

Could you both share which versions of Skuid you're working with? There is a story in our developer's backlog about passing Ids into a datasource action like this, where the Id is being passed as a string, instead of an ID (i.e. incorrect type). Could you be running into this? If so, I wanted to let you know that we do have this on our radar, but there is not yet an ETA on any changes. 
Photo of Mike Dwyer

Mike Dwyer

  • 3,390 Points 3k badge 2x thumb
I am developing on 11.1.14, which is also the Production target. No problems!
Photo of Danny Hartley

Danny Hartley

  • 434 Points 250 badge 2x thumb
We are on 11.1.10.  That may be my issue as I was not able to achieve any results until I set the variable as type ID in the constructor for the related APEX class?
Photo of Mark DeSimone

Mark DeSimone, Official Rep

  • 11,050 Points 10k badge 2x thumb
Hi Danny. Just wanted to check in - were you able to resolve the original issue?
Photo of Danny Hartley

Danny Hartley

  • 434 Points 250 badge 2x thumb
Hi Mark,

Yes I as able to get everything working.  Thank you for following up.