2

We have a requirement were all customer orgs should get approval process. So we are planing to create a post installation script and use salesforce meta data api to create a approval process. Is my plan is right will I be able to call metadata API from within apex code ?

Thanks in adavance

4

1 Answer 1

5

Calling Apex Metadata API from Post Install Script: Actually calling the metadata API from an Apex Post Install script is going to be problematic, since in order to call the Metadata API (which is a web service) you need to setup a Remote Site setting the customer org to permit the outbound call (which ironically is back to Salesforce servers). While you can package Remote Site settings you probably don't want to include one for every possible Salesforce instance your package can be installed on.

Alternative to Automating Post Install Task via Apex Metadata API. If you want to call the Metadata API post install, i would recommend providing a short post install process, to add the appropriate remote site, then have the admin navigate to a Visualforce page which contains any required post install org configuration changes you want to automate. You could use the Package Configuration link (see package definition) for this perhaps.

4
  • Andrew do you mean we have to do the metadata api call from VF? Nov 12, 2013 at 13:13
  • You can yes, though if you want to make a Batch Apex job you can also do this. Examples of both approaches are included in the library. Nov 12, 2013 at 13:17
  • Thanks for your quick reply. If i use VF then I need to use javascript to call metadata api or do you mean after admin creating the remote site setting we have to do the metadata call using the above mentioned apex code ? Nov 12, 2013 at 13:21
  • You can call the Metadata Api from Apex via an Apex Visualforce apex controller without using JavaScript. If you are wanting to deploy Apex or Apex Trigger or retrieve information, you will need a JavaScript component (also included) to manipulate the Zip data the API uses in these case. Otherwise you can use purely Apex callouts to the Metadata API without JavaScript. Nov 12, 2013 at 13:34

You must log in to answer this question.

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