You need to sign in to do that
Don't have an account?

Validation Rule to Require Attachment when Opp Reaches Probability 100%
Hi,
I need to create a trigger or validation rule that requires a user to attach a document/insertion order to an opportunity when it is changed to 100% or closed won.
Please advise.
I need to create a trigger or validation rule that requires a user to attach a document/insertion order to an opportunity when it is changed to 100% or closed won.
Please advise.
Are you checking in the Production environment ?
If yes, you cannot create or edit Apex classes or triggers in a production organization.
To use Apex classes or triggers in a production organization, you need to write them in a Sandbox or free Developer Edition organization--along with the required automated tests to meet or exceed code coverage requirements--and then use one of our deployment tools (the Force.com IDE or the Force.com Migration Tool for Ant) to push your classes and triggers to production.
The reason for this is that all Apex code must be covered by automated tests in order to be deployed to production. If you tried to write a trigger in production, you wouldn't have a test so it wouldn't save. If you tried to write the test first, the test would fail because your trigger wasn't working, so you couldn't save that either. So instead, you do all of your development work in a non-production organization, where these rules are not enforced, and then you can deploy your code and tests to your production organization to make their functionality available to end users.
All Answers
Your trigger would be simply this
Kindly test it and let me know how it goes !
Are you checking in the Production environment ?
If yes, you cannot create or edit Apex classes or triggers in a production organization.
To use Apex classes or triggers in a production organization, you need to write them in a Sandbox or free Developer Edition organization--along with the required automated tests to meet or exceed code coverage requirements--and then use one of our deployment tools (the Force.com IDE or the Force.com Migration Tool for Ant) to push your classes and triggers to production.
The reason for this is that all Apex code must be covered by automated tests in order to be deployed to production. If you tried to write a trigger in production, you wouldn't have a test so it wouldn't save. If you tried to write the test first, the test would fail because your trigger wasn't working, so you couldn't save that either. So instead, you do all of your development work in a non-production organization, where these rules are not enforced, and then you can deploy your code and tests to your production organization to make their functionality available to end users.
How do I execute this code now or test it? First time running this, any help would be appreciated.
Thanks
You will have put this code in your sandbox environment first and test it there. Once you are confident that everything looks fine, you can deploy the code to your production using a changeset or a deployment tool like ANT. I would strongly recommend to pass this on to your development team if you are doing this for the first time.
Can you help me on the Class for the above trigger.