0

I know, how to access to such a method: packageName.MyGlobalClass.doWork(); But what if our method gets a Wrapers parameters? Like this:

    global with sharing class MyGlobalClass{
        global static void doWork(List<WrapperClass> parameters){
            //some logic is here
        }
        global class WrapperClass{
            @InvocableVariable(required=true label='Id') global ID someId;
            @InvocableVariable(required=true) global String stringValue;
        }
    }

How can I get this method? And set to Wrapper my parameter?

10
  • 1
    new packageName.MyGlobalClass.WrapperClass().stringValue = 'Hello'; ? Commented Mar 12, 2020 at 9:40
  • Method does not exist or incorrect signature: void WrapperClass() from the type packageName.MyGlobalClass
    – Dan Dan
    Commented Mar 12, 2020 at 9:47
  • is there any parameterized constructor? Commented Mar 12, 2020 at 9:49
  • Just a few parametrs like a stringValue with labels inside WrapperClass.
    – Dan Dan
    Commented Mar 12, 2020 at 9:56
  • 1
    The () was to call the constructor. Does packageName.MyGlobalClass.WrapperClass wrapper = new packageName.MyGlobalClass.WrapperClass(); work? Is it just that you have only got constructors that take parameters?
    – Phil W
    Commented Mar 12, 2020 at 10:34

1 Answer 1

0

To sum up what has been said in comments and close the question, here is the solution:

packageName.MyGlobalClass.WrapperClass wrapper = new packageName.MyGlobalClass.WrapperClass();

wrapper.someId = 'someId';
wrapper.stringValue = 'stringValue';

packageName.MyGlobalClass.doWork(new List<packageName.MyGlobalClass.WrapperClass>{
        wrapper
});

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .