1

I would like to know is it possible to start a Screen Flow using custom trigger?

I tried searching but I'm only seeing samples for auto launched flows.

If it's possible can anyone provide me a sample?

Thank you and Happy Holidays!

7
  • 2
    given that triggers can be executed in non-UI contexts (API, data loader, ...) why would you want a screen flow?
    – cropredy
    Dec 18, 2019 at 1:18
  • @cropredy For example, when an Opportunity has been Closed Won we need to auto create a Project (Custom Object) BUT the currency is very critical and the Opportunity Currency is not always equal to the Project Currency that's why I'm thinking about creating a screen flow wherein users can set the currency before that Project is created. Dec 18, 2019 at 1:23
  • You still need to consider that the API or Apex or REST or Data loader could close an Oppo; hence a better solution is to prevent the Oppo from closing until a user has provided a Project Currency
    – cropredy
    Dec 18, 2019 at 1:32
  • @cropredy I understand that, we don't use Data Loader to change the Opportunity Stage... Dec 18, 2019 at 1:44
  • 2
    sounds like a plan!
    – cropredy
    Dec 18, 2019 at 2:01

1 Answer 1

2

Architecturally, it is incorrect for triggers to do anything that requires user interaction.

  • Triggers execute at the database layer and as such, execute whenever the object is the target of DML. Thus, triggers can fire for plenty of non-UI use cases such as data loader, REST API, ApexRest, Batchables, Queueables, Future, invocable Apex, etc. While you might not be using those use cases now, you may later in time.

A better strategy is to

  • Add a field on the Opportunity called Project_Currency__c that must be present before the Opportunity can close. You can use Validation Rules to enforce.
  • In addition to the above, you can use the before update trigger to default this value for use cases where you don't need user input.
  • In addition to the above, if the decision process for setting the currency involves asking questions, you can add a quick action that invokes a screen flow to guide the user, ending up with a value that goes into Project_Currency__c.

You must log in to answer this question.

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