0

I've written a pretty simple Apex Trigger and Class which sends and HTTP request to an external service when a Salesforce Contact is updated. I developed this in our local dev environment and seems to be working.

I have an app in which users can oAuth into Salesforce, and my end goal here is to have the Apex Trigger I wrote run for each org that oAuths. So, my question is what are some different options, or the best way, to accomplish this?

One thought I've had is to somehow programmatically deploy the Apex code to each organization after an initial admin oAuth (or something like that) - however I'm brand new to Salesforce and am currently not sure A.) how to do this and B.) if it's even feasible.

Is this a good idea? Are there other ways to accomplish this goal? I would really appreciate any insight, recommendations, or resources pointing towards some things that could help. Thank you so much!

2
  • Are you building a paid product whose OAuth clients will be customers, or are you managing multiple orgs within a single company?
    – David Reed
    Commented Oct 27, 2022 at 21:55
  • Hi @DavidReed, the oAuth clients are paying customers
    – jerfp
    Commented Oct 27, 2022 at 22:03

1 Answer 1

1

You can't run Apex, Triggers, Components, Visualforce, etc outside of your own org without having it installed first. This is a security feature that you shouldn't try to circumvent, nor should you be installing code directly without consent (e.g. logging in shouldn't be enough). You can do this by providing an Installation URL, an AppExchange listing, or use the awesome Deploy to Salesforce button.

Note that if you plan on charging for the actual package, you need to become a Salesforce Partner, go through the Security Review process, and do some packaging. This is all laid out in the ISVForce guide, so I'm not going to list every step here. This process takes a bit of time, but I've been through it a few times, it's not too onerous.

If this is just a free app that you want to distribute to connect your service to Salesforce, and you've determined that this is the best path, you should still read the ISVForce guide and go through the process. This enables you to list your app on the AppExchange and gets rid of a rather intimidating message that appears when subscribers try to install such a package. Free packages don't cost as much as the full process.

You must log in to answer this question.

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