Open ecolui opened 5 years ago
Thanks! Yeah, this does use the Tooling API. So I think that does mean this won't work in a prod org. As an alternative maybe there is a way to automate creation in a sandbox and then deployment to prod. But I've never looked into that.
The Salesforce Streaming API might be an alternative to triggers. You could build a bus app that'd receive the streaming event and then call an http endpoint. But I'm not sure how far you can go dynamically configuring streaming in a prod org.
Thanks for the feedback! Take it easy!
Hi James,
Does this mean that it will no longer work in production environment? I am encountering the same issue as Issue #30 where it works in sandbox but not in production. Do you know of any workarounds to fix this? I did deploy to sandbox then migrate. I could potentially do it in production, but then the tests in #24 fail, but not sure if this matters or not. Should it work if I deploy straight to production or do I need to create a streaming API? I am using opportunity creation and opportunity won as my webbook triggers if that matters.
Any thoughts?
Thanks so incredibly much!
This should work fine with creating the classes in a sandbox and then migrating to prod. I added a note to #24 with a possible item that was missed in migration. Hopefully that helps.
Hi James! Thanks for your reply. Here is the Apex class and Apex triggers that was transferred to the production org. They don't seem to be doing anything at all in the production where it works perfectly in Sandbox. If you are willing to take a look that would be so appreciated! I modified the URL in the triggers to sample URL, but otherwise this is exactly what I migrated to production.
WebhookSF.txt Opportunity Created Webhook.txt Opportunity Won Webhook.txt
Can you check the Apex logs to see if there are errors? Also, I think you need to migrate the RemoteSiteSetting but I'm not sure.
You are correct!!! It was the RemoteSiteSettings. I just went into the production org and added the remote site and it works perfectly!
Thank you very much for your quick responses and help!
Great job James! On line 144 in ForceUtil.scala, I noticed that you are using the tooling api to create Apex classes and triggers. The api docs indicate that you'll get an error if you attempt to use those methods on a "live" organization. Does this tool only work for Salesforce developer environments and sandboxes?
https://developer.salesforce.com/docs/atlas.en-us.api_tooling.meta/api_tooling/intro_crud_operations.htm
PS: I need to dynamically create triggers on objects that user's select at runtime (on a live environment), so I was just looking through your code to see how you pulled it off.
Also - it seems that the Salesforce Streaming API is pretty new. Would you recommend using the Streaming API (over webhooks)? It seems that the benefit of using the streaming API is that you can create push notifications and subscribe / unsubscribe at runtime.