0

I need to pass a reference to a string variable to a method that implements (SchedulableContext sc) I tried:

 global void execute(SchedulableContext sc, loginstring){

but I'm getting a compile error "Compile Error: unexpected token: ')'" What am I missing here?

1
  • Not sure if you can (in fact I do not think you can), but you are missing the type declaration (i.e. String, Integer). Regardless what is it you are trying to accomplish?
    – Eric
    Aug 25 '15 at 12:55
1

Instead passing value to execute you can use member variable and parameterized constructor to pass the value you wanted and it can be used in execute method as:

public MyScheduleClass implements Schedulable
{

    public String loginString;

    public MyScheduleClass(String whatyouwanthereStr)
    {
       // Any complex logic before
       this.loginString = whatyouwanthereStr;
    }

    public void execute(SchedulableContext SC)
    {
       System.debug(' LoginString '+this.loginString);

       // Perform other logic, create new String and then reschedule if need

       this.loginString = 'http://maNeuURLisThiss';

       MyScheduleClass sjob= new MyScheduleClass(this.loginString); 
       System.schedule('Scheduled with New URL', cronExpression, sjob);
    }
}

You cannot pass extra arguments in execute method.

Not the answer you're looking for? Browse other questions tagged or ask your own question.