2

I have a managed package containing a VF page that uses JSForce to deploy a zipped package of metadata when a user clicks a button. Inside the package I'm trying to deploy is 2 classes and a trigger, and a test class for them.

Like I said, my VF page is part of a managed package. When I install the package into a sandbox or developer org, I am able to successfully click the button on the VF page and deploy the package.

But in production, it doesn't work. The API Call for the deploy comes back with a 500 Server Error.

The important part of my code is here.

var emailTrigger = PackService.getEmailTrigger();
JSForceService.conn.metadata.deploy(emailTrigger, { testLevel: 'RunLocalTests' })

PackService.getEmailTrigger() returns a base64 encoded zip file, and JSforceService is a wrapper for the jsforce api.

Is there some kind of block in production orgs which prevents this type of metadata deploy? I found the setting to allow non-certified packages to allow apex metadata deploys and tried that, but it didn't fix anything. Hoping somebody can chime in!

3
  • What is your "Deploy Metadata from Non-Certified Package Versions via Apex" set to? In theory this should only apply to the Metadata via Apex, but you never know. You can find this under "Apex Settings" in Setup. Commented Aug 9, 2017 at 0:47
  • Just re-read you last paragraph, I assume this was the same setting I mentioned? Can you manually create the same trigger in the production org outside the managed package? Commented Aug 9, 2017 at 0:56
  • 1
    Where is JSForce getting the session ID to perform the Metadata API deploy? It might be that it isn't a first class Session ID coming out of Visualforce. At least with respect to production orgs. Commented Aug 9, 2017 at 1:14

1 Answer 1

2

It turns out the answer was simple. In production orgs, you must specify rollbackOnError: true in your deploy options

JSForceService.conn.metadata.deploy(emailTrigger, { testLevel: 'RunLocalTests', rollbackOnError: true })

Works perfectly now!!

You must log in to answer this question.

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