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

How to unlock the record
Hi All
how to unlock the record through code or through process builder , could you please advise me
thanks
how to unlock the record through code or through process builder , could you please advise me
thanks
Using Code:
if you have your code written directly in the trigger or in a class designated without sharing, then the apex code can update records that are locked, regardless of the user who caused the trigger to fire. I tested by creating a trigger on Contact that updates a field on the Contact's Account. When the Account is locked, I can edit the contact record with a non admin user and the field on the Account gets updated.
If you use code in a class marked with sharing that is called by the trigger, then you will get an exception. If the trigger was executed by an Administrator, then the code will always run
For Example I have added to code unlock Opp
Admin View:
Setup->Create-> Workflows and Approvals -> Process Automation Settings
and set checkbox Enable record locking and unlocking in Apex as true
Mark Best ANSWER if its Solved.
Thanks
karthik
All Answers
Using Code:
if you have your code written directly in the trigger or in a class designated without sharing, then the apex code can update records that are locked, regardless of the user who caused the trigger to fire. I tested by creating a trigger on Contact that updates a field on the Contact's Account. When the Account is locked, I can edit the contact record with a non admin user and the field on the Account gets updated.
If you use code in a class marked with sharing that is called by the trigger, then you will get an exception. If the trigger was executed by an Administrator, then the code will always run
For Example I have added to code unlock Opp
Admin View:
Setup->Create-> Workflows and Approvals -> Process Automation Settings
and set checkbox Enable record locking and unlocking in Apex as true
Mark Best ANSWER if its Solved.
Thanks
karthik
nice but is there any otherway to unlock the record by using simple process builder.
we can use process builder for record lock.but we can't use process builder or flow to unlock the records.
This is the idea about unlock the record using process builder and flow share in idea exchange. Kinldy have a look.
https://success.salesforce.com/ideaView?id=0873A000000PU1hQAG
Hope it's clear.mark solved if it's clear.
thanks
karthik
you are awesome . I will follow ur apex code and am new to development , it would be nice if i get test code for apex i will use trigger after update and call your class .
Test class with code coverage screenshot has been sent your mail id. please check
Thanks
karthik
Can you please send the test code for your apex class to me at hrustagi1991@gmail.com