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

how to lock record ?
Hi,
I want to lock my record using apex coding. I have tried using "Approval.LockResult[] lrList = Approval.lock(recordID);" from the link(https://releasenotes.docs.salesforce.com/en-us/winter16/release-notes/rn_apex_approval_locks_unlocks.htm). But it's locked the record in API version 35 and it's not locking the record in API version 38. How can i acheve this ? Any one can help me ?
I want to lock my record using apex coding. I have tried using "Approval.LockResult[] lrList = Approval.lock(recordID);" from the link(https://releasenotes.docs.salesforce.com/en-us/winter16/release-notes/rn_apex_approval_locks_unlocks.htm). But it's locked the record in API version 35 and it's not locking the record in API version 38. How can i acheve this ? Any one can help me ?
use Belo code for update trigger Record Type
Note: for this Record Type associate new page layout and all field should be in read only and unlock button(custom button) should be place at top of the page
Thanks
karthik
All Answers
kinldy try below method,
You might create two record types, "open" and "locked". Configure them with whatever security setup you wish the users to have.
Then write a simple before update trigger on Opportunity to change the recordtype of the opportunity from one to the other depending on the status of your checkbox.
Hope this will help you,
Mark Best ANSWER if its clear.
Thanks
karthik
There appears to be some issue when using Apex to lock records in Salesforce if your sandbox is on Spring '16 (metadata version 36). To work around the issue the metadata version of Apex classes locking records should be set to 36. This may make production deployments an issue until the issue has been fixed / all production environments have been upgraded to Spring '16.
For additional information check here:
- http://www.slideshare.net/Saaspoint/enda-lock-record-slideshare-post
- http://salesforce.stackexchange.com/questions/105360/why-cant-i-lock-unlock-records-through-apex
Good Luck.Best Regards,
Nagendra.P
Record Locking was introduced in Winter16 Release .It should be compatible with the higher versions.
You can write a workflow rule with no actions , only to track that the lock is working consistently.
Let me know the exceptions or errors which you are getting with higher version 38.
Thanks,
Navan
I am not getting any exceptions. If i run that through Anonymous Window in debug logs it showing like record is locked. But if i go to record and checking means record has not been locked.
Thanks
karthik
I tried this option on account object and i wrote trigger. But record has not locked. Here i am attaching my trigger. Please correct me if is there any mistake in my trigger.
use Belo code for update trigger Record Type
Note: for this Record Type associate new page layout and all field should be in read only and unlock button(custom button) should be place at top of the page
Thanks
karthik