[SalesForce] Deploying My First Apex Trigger

Attempting to deploy the trigger from this answer, on another question of mine. This is the second time I've attempted to deploy some apex, but this time I really would like to get it working. After repeatedly be puzzled to by where and what I need to do, it appears that that the version of Salesforce I'm using makes a difference; using EE, Enterprise Edition.

Reason I say that is because I got an error by going to "Setup > Build > Develop > Apex Triggers > Developer Console" then clicking "File > New > Apex Trigger" entering a "Name" and selecting the sObject as "Account" then clicked save. This resulted in an error saying, "ENTITY_IS_LOCKED: cannot create apex trigger on an active organization."

After a few Googles, it appears that to deploy the code above, I must follow these steps:

The Apex classes and triggers should first be written in a Developer
Edition, Sandbox, or Trial organization along with the appropriate
test methods that test at least 1% of triggers and 75% of classes. To
deploy Apex into a production organization, a user with the Author
Apex permission must deploy the triggers and classes using either the
compileAndTest() or deploy() Metadata API methods which can be
accessed with either the Apex Development Tool based on Apache ANT or
the Force.com IDE based on Eclipse.]3

Issue is that that "makes sense" – but is way, way to high-level to be of any use, and the only other docs I've seen that "seem" complete are these: Writing Your First Apex Class and Trigger

Does it seem like those docs as a rough guide to deploying the trigger provided in the answer to my other question would be the fastest way to get this done?

If it matters, I do have access to both Developer & Developer Pro sandboxes, and have gotten the Force IDE loaded before, but just to do a download of the code as a semi-backup of the meta-data.

Best Answer

You need to write the code in a Sandbox (type doesn't matter) that is created from the Production org you want to deploy to. If it's a simple trigger & test class that you're mostly copying and pasting, then the Dev Console is fine, and you needn't worry about the IDE right at the moment.

The easiest deploy method is Change Sets, which lets you select components in your Sandbox and deploy them to your Production org (or another Sandbox). Deploying to Production will run your trigger's test, and any others in your org, and if you meet the code coverage requirements, you should be in business.

Related Topic