2

I am creating Managed package where it takes request from all objects.

For example I have “bucket” Object where it hold all requests coming from different Objects. And requests will be generated on dml actions on object like birthday update on contact. For stranded object I can created triggers and send along with App but I wanted to give provision for user to enable dml actions (trigger/ workflow behaviour) for custom object also.

so my plan for that is I will create Vf page where user select Objects to enable actions and in backend I will create trigger for that object and test class and all which is required.

Is it correct idea/approach ? . where I will get difficulties and can we create triggers in production by using tooling API from APP components.

Suggestions Plz.

2

The Tooling API can't be used to create new Apex classes or triggers directly in production. It wouldn't be possible to create both the class/trigger and corresponding test cases in the same API call. It would be plausible in a sandbox or developer edition org.

Instead you would need to use the Metadata API and have permissions (Remote Site Settings) to make the API calls back to the current Org. See the Metadata Deploy Demo in the Apex Wrapper Salesforce Metadata API by Andrew Fawcett.

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.