Is it possible to pass only one record of model or many records to invocable method

  • 1
  • Question
  • Updated 8 months ago
  • Answered
Hi,

Currently, we have faced difficulties when trying to pass a list of params with Invocable Methods of Apex Class via Skuid Page.


We have a Custom Object A, and when inserting a record, we need to set many values for the record of Custom Object A. Till now, we couldn't find any way to transmit multiple values. Please note that inserting a record in apex code is not avoidable, it is a must for our case because it is required on user's side. 


Please help giving advice to us to achieve this idea. 


Thank you.
Photo of Charlotte

Charlotte

  • 320 Points 250 badge 2x thumb

Posted 8 months ago

  • 1
Photo of Shiva Chervirala

Shiva Chervirala

  • 200 Points 100 badge 2x thumb
Hi Charlotte ,

You can use wrapper class to send multiple values to a Invocable Method . Please find the syntax below. 
public class <className>{

        @InvocableMethod
       public static <MethodName>(List<WrapperClassName > inputList){

        ----Use the wrapper class---
        }
  class <WrapperClassName > {
       @InvocableVariable 
       public string variable1

       @InvocableVariable 
       public string variable2

       @InvocableVariable 
       public string variable3
   }
}

You can set variable values in SKUID configuration set up.

Thanks,
Shiva Kumar CH
Photo of Charlotte

Charlotte

  • 320 Points 250 badge 2x thumb
Hi Shiva,

Thank you for your replying. 

We need to insert a record which has many fields values to input, so to declare more than 20 variables like this, is not expecting solutions for us. We are looking for the method to pass model data (a record of an object with many fields values) to Invocable class. 

 
Photo of Shiva Chervirala

Shiva Chervirala

  • 200 Points 100 badge 2x thumb
Okay can you then convert all the values to JSON format in javascript and stringify the JSON and pass it to InvocableMethod as a single string