Activity Forums Salesforce® Discussions How to unlock the record through Salesforce process builder or through code ?

  • How to unlock the record through Salesforce process builder or through code ?

  • PRANAV

    Member
    September 22, 2016 at 2:38 pm

    Hi All,

    How to unlock the record through process builder or through code ?

    Thanks

  • Mohit

    Member
    September 30, 2016 at 5:53 am

    Hi Pranav,

    You can unlock the records through apex code by enabling Apex code to set and remove approval process lock.This features is avaliable in summer 16 release only. To do this follow these step :-

    1. Goto Setup
    2. .Then search 'Process Automation Settings' in search box. 
    3. There you click the checkbox 'Enable record locking and unlocking in Apex'

    From this you can enable the record locking and unlocking by apex code.

    Then the code for unlocking the record :-
    For(sObject a :[select name From sObject])//Name of the object on which lock is acquire
    {
    if(Approval.isLocked(a.id)){  //To check whether the record is locked or not
    Approval.unlock(a.id);          //Id of the record which you want to unlock
    }
    }

  • Amit Kumar

    Member
    September 20, 2019 at 2:08 pm

    This helped, Thank you.

Viewing 1 - 3 of 3 posts

Log In to reply.

Popular Salesforce Blogs

Popular Salesforce Videos