0

I have created a custom apex class that makes an HTTP POST call using callouts. Right now I have it running on a schedule using an @future method. This is working fine, but I actually want to connect this to a screen that a user can enter some parameters and then this class would run on demand and be set up to run on a schedule. Is it possible for me to create a screen to do this?

1
3

The answer is "yes". There are a number of different ways to deal with it, depending on the UX you want, how this process should be initiated and the level of coding you are happy to do.

My immediate recommendation would be to use a Screen Flow (this is covered in the Trailhead for flows), perhaps initiated from a Lightning Action that you add to the global actions or some other place. This avoids writing much code. You can create a screen with the inputs needed for the values you want, and update your code to support an InvocableMethod that takes the inputs from these as its parameters and then invokes your Future method to do the callout (I'm not sure if you need to separate it into a future from an invocable method - you can research this).

The alternatives involve more coding (e.g. a visualforce page or some LWC component you add to an app or home page, for example).

5
  • I tried setting up a screen flow. I just created a screen with 2 inputs and then connected the screen to a lightning action that sets the parameter from the invocable method, which I would then pass through to my future method. Is that the right idea? Also I noticed this invocable method only accepts a list and I want to send 2 input parameters, is there any way for me to send these 2 parameters?
    – MarkC5000
    Jul 26 '19 at 14:05
  • 1
    That's the right idea. Passing multiple parameters is handled as shown in developer.salesforce.com/docs/atlas.en-us.apexcode.meta/… with the InvocableVariable annotation.
    – Phil W
    Jul 26 '19 at 14:32
  • Thanks for sharing the document. Maybe I am not understanding it correctly but I created the Invocable variables but I am just not sure how I can connect that on my flow. I created a list<string> test which is sent to my invocable method, so on my lightning action I can only set 1 screen input variable to that variable. Should I not see the invocable variables here as well?
    – MarkC5000
    Jul 26 '19 at 16:10
  • 1
    I wish I had an example I could share with you to clarify. You should be able to collate your inputs into the invocable variables and pass a list of just the one value (containing the multiple inputs in those variables). Unfortunately I don't have an example to hand.
    – Phil W
    Jul 26 '19 at 16:29
  • 1
    Take a look at this Salesforce developer forum discussion.
    – Phil W
    Jul 26 '19 at 16:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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