You need to sign in to do that
Don't have an account?
Akash Choudhary 17
Apex Class and Trigger for Opportunity Record Lock
Hello Everyone,
I have a requirement wherein I need to make a Opportunity record read only when the opportunity stage reaches to Closed won or either Closed Lost.
Any help is much appreciated.
Thanks
I have a requirement wherein I need to make a Opportunity record read only when the opportunity stage reaches to Closed won or either Closed Lost.
Any help is much appreciated.
Thanks
Use a record type(Read only ) assign a page layout with all fields set to read only .
Thanks for the reply but I mentioned it in the title that I want to achieve this requirement through Apex class and trigger.
Why not any OOB feature ?
Even you can go for validation rule, something like below,
AND(
IsClosed = TRUE ,
NOT($Profile.Id = "xxxxxxxxxxxx" ),
NOT(RecordTypeId = "xxxxxxxxxxx")
)
Thanks,
Govindaraj.S
I want to achieve it via Apex class and trigger only as when you use validation rule the user have the error message once he saves it not before also in case of assigning a page layout to a record type then calling it through workflow also doesn't help because you still can change the required fields like opportunity name that's why I wanted to use Apex class and trigger for it . If you can help me achieve it via code that will be of great help
Thanks for the reply
With a standard trigger you will have no luck doing this. If we think about the "events" for triggers, they are "insert" or "update" (and "delete"). Delete not quite relevant in this case.
For the trigger to fire, one of the events of insert or update will need to execute. By their nature, this would mean that the record is in edit mode.
If you don't want to use recordtypes, then you are going to have to try doing something in Visualforce with a controller.
Regards
Andrew