SlideShare a Scribd company logo
How to create a “Lock” record in Salesforce without using Apex code
                       or an approval process

A recent request from a client required Saaspoint to create a record lock
outside the usual approval process. Lead Developer Enda Traynor
identified three potential ways to create the required record lock:

    1. Use Record Types and Page Layouts with an integrated
       Javascript button which “locked” the record when clicked by
       setting all of the displayed fields to read-only.
    2. Use an update Trigger which could set the record to “locked”,
       again by setting fields to read-only.
    3. Create a simple button on the record which updates a new
       field called Locked__c



Method 3 was decided to be the most efficient and flexible solution, which can be implemented as
follows:

       Add the Lock_Record button to an Opportunity:

        {!REQUIRESCRIPT("/soap/ajax/22.0/connection.js")} //adds the proper
        code for inclusion of AJAX toolkit

        var url = parent.location.href; //string for the URL of the current
        page

        var opp = new sforce.SObject("Opportunity"); // Create an Opportunity
        object that will be used to update.
        opp.Id = '{!Opportunity.Id}'; // Set the Id so that we know which
        record we are updating.
        opp.Locked__c = true; // Set the record as ‘Locked’ by setting the
        Locked__c field.

        result = sforce.connection.update([opp]); // update the Opportunity
        record
        parent.location.href = url; //refresh the page
   The code references a simple, read-only checkbox called Locked__C which is displayed on
         the page but which the user cannot change once it is set (the value is set via the page layout
         settings).

         A validation rule is also implemented on the page with logic to allow the Locked__c field to
         be set to true:

         Locked__c && NOT(ISCHANGED(Locked__c))




Screen shots

1. Screen shot showing un-ticked and read-only checkbox and "Lock Record" button:




2.

a. Screen shot showing attempt to edit the record while it is not locked:




b. Screen shot showing record saved with successful change:
3. Screen shot showing after record was locked (see checkbox) that user cannot edit the record any
more




If you’d like to speak to Enda or a member of the Saaspoint team, please feel free to contact us on
+44 0 207 182 4707 and we’d be happy to advise you on your web self-service needs.

More Related Content

What's hot

The best wiki wizard now released
The best wiki wizard now releasedThe best wiki wizard now released
The best wiki wizard now released
alexakennedykrs
 
Laravel website security and performance optimization guide (pro tips to fine...
Laravel website security and performance optimization guide (pro tips to fine...Laravel website security and performance optimization guide (pro tips to fine...
Laravel website security and performance optimization guide (pro tips to fine...
Katy Slemon
 
Selenium Automation in Java Using HttpWatch Plug-in
 Selenium Automation in Java Using HttpWatch Plug-in  Selenium Automation in Java Using HttpWatch Plug-in
Selenium Automation in Java Using HttpWatch Plug-in
Sandeep Tol
 
Progressive web apps
Progressive web appsProgressive web apps
Progressive web apps
Suraj Kumar
 
WordPress, Schema & more
WordPress, Schema & moreWordPress, Schema & more
WordPress, Schema & more
Joost de Valk
 
07.1. Android Even Handling
07.1. Android Even Handling07.1. Android Even Handling
07.1. Android Even Handling
Oum Saokosal
 
Laravel mail example how to send an email using markdown template in laravel 8
Laravel mail example how to send an email using markdown template in laravel 8Laravel mail example how to send an email using markdown template in laravel 8
Laravel mail example how to send an email using markdown template in laravel 8
Katy Slemon
 
Integrate to retrieve data microsoft azure
Integrate to retrieve data microsoft azureIntegrate to retrieve data microsoft azure
Integrate to retrieve data microsoft azure
Son Nguyen
 
Installing the java sdk
Installing the java sdkInstalling the java sdk
Installing the java sdk
Kennedy Kiprono
 
Deploy with maven
Deploy with mavenDeploy with maven
Deploy with maven
Son Nguyen
 
Future of Mobile Web - Coldfront conf
Future of Mobile Web - Coldfront confFuture of Mobile Web - Coldfront conf
Future of Mobile Web - Coldfront conf
Paul Kinlan
 
How to publish ASP.NET Core web application via Visual Studio 2019.pdf
How to publish ASP.NET Core web application via Visual Studio 2019.pdfHow to publish ASP.NET Core web application via Visual Studio 2019.pdf
How to publish ASP.NET Core web application via Visual Studio 2019.pdf
gerardov5
 
The web - What it has, what it lacks and where it must go - Bulgaria Web Summ...
The web - What it has, what it lacks and where it must go - Bulgaria Web Summ...The web - What it has, what it lacks and where it must go - Bulgaria Web Summ...
The web - What it has, what it lacks and where it must go - Bulgaria Web Summ...
Robert Nyman
 
Progressive web apps
Progressive web appsProgressive web apps
Progressive web apps
Fastly
 

What's hot (15)

The best wiki wizard now released
The best wiki wizard now releasedThe best wiki wizard now released
The best wiki wizard now released
 
Laravel website security and performance optimization guide (pro tips to fine...
Laravel website security and performance optimization guide (pro tips to fine...Laravel website security and performance optimization guide (pro tips to fine...
Laravel website security and performance optimization guide (pro tips to fine...
 
32916
3291632916
32916
 
Selenium Automation in Java Using HttpWatch Plug-in
 Selenium Automation in Java Using HttpWatch Plug-in  Selenium Automation in Java Using HttpWatch Plug-in
Selenium Automation in Java Using HttpWatch Plug-in
 
Progressive web apps
Progressive web appsProgressive web apps
Progressive web apps
 
WordPress, Schema & more
WordPress, Schema & moreWordPress, Schema & more
WordPress, Schema & more
 
07.1. Android Even Handling
07.1. Android Even Handling07.1. Android Even Handling
07.1. Android Even Handling
 
Laravel mail example how to send an email using markdown template in laravel 8
Laravel mail example how to send an email using markdown template in laravel 8Laravel mail example how to send an email using markdown template in laravel 8
Laravel mail example how to send an email using markdown template in laravel 8
 
Integrate to retrieve data microsoft azure
Integrate to retrieve data microsoft azureIntegrate to retrieve data microsoft azure
Integrate to retrieve data microsoft azure
 
Installing the java sdk
Installing the java sdkInstalling the java sdk
Installing the java sdk
 
Deploy with maven
Deploy with mavenDeploy with maven
Deploy with maven
 
Future of Mobile Web - Coldfront conf
Future of Mobile Web - Coldfront confFuture of Mobile Web - Coldfront conf
Future of Mobile Web - Coldfront conf
 
How to publish ASP.NET Core web application via Visual Studio 2019.pdf
How to publish ASP.NET Core web application via Visual Studio 2019.pdfHow to publish ASP.NET Core web application via Visual Studio 2019.pdf
How to publish ASP.NET Core web application via Visual Studio 2019.pdf
 
The web - What it has, what it lacks and where it must go - Bulgaria Web Summ...
The web - What it has, what it lacks and where it must go - Bulgaria Web Summ...The web - What it has, what it lacks and where it must go - Bulgaria Web Summ...
The web - What it has, what it lacks and where it must go - Bulgaria Web Summ...
 
Progressive web apps
Progressive web appsProgressive web apps
Progressive web apps
 

Similar to How-to Create a 'Lock' record in Salesforce

( 16 ) Office 2007 Create An Extranet Site With Forms Authentication
( 16 ) Office 2007   Create An Extranet Site With Forms Authentication( 16 ) Office 2007   Create An Extranet Site With Forms Authentication
( 16 ) Office 2007 Create An Extranet Site With Forms AuthenticationLiquidHub
 
( 16 ) Office 2007 Create An Extranet Site With Forms Authentication
( 16 ) Office 2007   Create An Extranet Site With Forms Authentication( 16 ) Office 2007   Create An Extranet Site With Forms Authentication
( 16 ) Office 2007 Create An Extranet Site With Forms AuthenticationLiquidHub
 
Session - 1 Forms and Session management.pptx
Session - 1 Forms and Session management.pptxSession - 1 Forms and Session management.pptx
Session - 1 Forms and Session management.pptx
imjdabhinawpandey
 
Authorization objects a simple guide.doc (1)
Authorization objects   a simple guide.doc (1)Authorization objects   a simple guide.doc (1)
Authorization objects a simple guide.doc (1)
Vikram Polinati
 
R Tanenbaum .Net Portfolio
R Tanenbaum .Net PortfolioR Tanenbaum .Net Portfolio
R Tanenbaum .Net Portfolio
Robert Tanenbaum
 
Setting up an odi agent
Setting up an odi agentSetting up an odi agent
Setting up an odi agent
Dharmaraj Borse
 
Necto 16 training 20 component mode & java script
Necto 16 training 20   component mode & java scriptNecto 16 training 20   component mode & java script
Necto 16 training 20 component mode & java script
Panorama Software
 
Solving anything in VCL
Solving anything in VCLSolving anything in VCL
Solving anything in VCL
Fastly
 
27 - Panorama Necto 14 component mode & java script - visualization & data di...
27 - Panorama Necto 14 component mode & java script - visualization & data di...27 - Panorama Necto 14 component mode & java script - visualization & data di...
27 - Panorama Necto 14 component mode & java script - visualization & data di...
Panorama Software
 
Advanced iOS Debbuging (Reloaded)
Advanced iOS Debbuging (Reloaded)Advanced iOS Debbuging (Reloaded)
Advanced iOS Debbuging (Reloaded)
Massimo Oliviero
 
State management
State managementState management
State managementIblesoft
 
OpenCms Days 2014 - User Generated Content in OpenCms 9.5
OpenCms Days 2014 - User Generated Content in OpenCms 9.5OpenCms Days 2014 - User Generated Content in OpenCms 9.5
OpenCms Days 2014 - User Generated Content in OpenCms 9.5
Alkacon Software GmbH & Co. KG
 
Flex In30 Mins
Flex In30 MinsFlex In30 Mins
Flex In30 Mins
fatbear007
 
How to build a chat application with react js, nodejs, and socket.io
How to build a chat application with react js, nodejs, and socket.ioHow to build a chat application with react js, nodejs, and socket.io
How to build a chat application with react js, nodejs, and socket.io
Katy Slemon
 
CSC PPT 12.pptx
CSC PPT 12.pptxCSC PPT 12.pptx
CSC PPT 12.pptx
DrRavneetSingh
 
Building Websocket Applications with GlassFish and Grizzly
Building Websocket Applications with GlassFish and GrizzlyBuilding Websocket Applications with GlassFish and Grizzly
Building Websocket Applications with GlassFish and Grizzly
Justin Lee
 
SCWCD : Handling exceptions : CHAP : 5
SCWCD : Handling exceptions : CHAP : 5SCWCD : Handling exceptions : CHAP : 5
SCWCD : Handling exceptions : CHAP : 5
Ben Abdallah Helmi
 
Grails and Ajax
Grails and AjaxGrails and Ajax
Grails and Ajax
TO THE NEW | Technology
 

Similar to How-to Create a 'Lock' record in Salesforce (20)

( 16 ) Office 2007 Create An Extranet Site With Forms Authentication
( 16 ) Office 2007   Create An Extranet Site With Forms Authentication( 16 ) Office 2007   Create An Extranet Site With Forms Authentication
( 16 ) Office 2007 Create An Extranet Site With Forms Authentication
 
Chapter 8 part2
Chapter 8   part2Chapter 8   part2
Chapter 8 part2
 
( 16 ) Office 2007 Create An Extranet Site With Forms Authentication
( 16 ) Office 2007   Create An Extranet Site With Forms Authentication( 16 ) Office 2007   Create An Extranet Site With Forms Authentication
( 16 ) Office 2007 Create An Extranet Site With Forms Authentication
 
Session - 1 Forms and Session management.pptx
Session - 1 Forms and Session management.pptxSession - 1 Forms and Session management.pptx
Session - 1 Forms and Session management.pptx
 
Authorization objects a simple guide.doc (1)
Authorization objects   a simple guide.doc (1)Authorization objects   a simple guide.doc (1)
Authorization objects a simple guide.doc (1)
 
R Tanenbaum .Net Portfolio
R Tanenbaum .Net PortfolioR Tanenbaum .Net Portfolio
R Tanenbaum .Net Portfolio
 
Setting up an odi agent
Setting up an odi agentSetting up an odi agent
Setting up an odi agent
 
Necto 16 training 20 component mode & java script
Necto 16 training 20   component mode & java scriptNecto 16 training 20   component mode & java script
Necto 16 training 20 component mode & java script
 
Solving anything in VCL
Solving anything in VCLSolving anything in VCL
Solving anything in VCL
 
27 - Panorama Necto 14 component mode & java script - visualization & data di...
27 - Panorama Necto 14 component mode & java script - visualization & data di...27 - Panorama Necto 14 component mode & java script - visualization & data di...
27 - Panorama Necto 14 component mode & java script - visualization & data di...
 
Advanced iOS Debbuging (Reloaded)
Advanced iOS Debbuging (Reloaded)Advanced iOS Debbuging (Reloaded)
Advanced iOS Debbuging (Reloaded)
 
State management
State managementState management
State management
 
DEVICE CHANNELS
DEVICE CHANNELSDEVICE CHANNELS
DEVICE CHANNELS
 
OpenCms Days 2014 - User Generated Content in OpenCms 9.5
OpenCms Days 2014 - User Generated Content in OpenCms 9.5OpenCms Days 2014 - User Generated Content in OpenCms 9.5
OpenCms Days 2014 - User Generated Content in OpenCms 9.5
 
Flex In30 Mins
Flex In30 MinsFlex In30 Mins
Flex In30 Mins
 
How to build a chat application with react js, nodejs, and socket.io
How to build a chat application with react js, nodejs, and socket.ioHow to build a chat application with react js, nodejs, and socket.io
How to build a chat application with react js, nodejs, and socket.io
 
CSC PPT 12.pptx
CSC PPT 12.pptxCSC PPT 12.pptx
CSC PPT 12.pptx
 
Building Websocket Applications with GlassFish and Grizzly
Building Websocket Applications with GlassFish and GrizzlyBuilding Websocket Applications with GlassFish and Grizzly
Building Websocket Applications with GlassFish and Grizzly
 
SCWCD : Handling exceptions : CHAP : 5
SCWCD : Handling exceptions : CHAP : 5SCWCD : Handling exceptions : CHAP : 5
SCWCD : Handling exceptions : CHAP : 5
 
Grails and Ajax
Grails and AjaxGrails and Ajax
Grails and Ajax
 

Recently uploaded

GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
James Anderson
 
Communications Mining Series - Zero to Hero - Session 1
Communications Mining Series - Zero to Hero - Session 1Communications Mining Series - Zero to Hero - Session 1
Communications Mining Series - Zero to Hero - Session 1
DianaGray10
 
20240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 202420240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 2024
Matthew Sinclair
 
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
James Anderson
 
20240605 QFM017 Machine Intelligence Reading List May 2024
20240605 QFM017 Machine Intelligence Reading List May 202420240605 QFM017 Machine Intelligence Reading List May 2024
20240605 QFM017 Machine Intelligence Reading List May 2024
Matthew Sinclair
 
GraphSummit Singapore | The Art of the Possible with Graph - Q2 2024
GraphSummit Singapore | The Art of the  Possible with Graph - Q2 2024GraphSummit Singapore | The Art of the  Possible with Graph - Q2 2024
GraphSummit Singapore | The Art of the Possible with Graph - Q2 2024
Neo4j
 
Elizabeth Buie - Older adults: Are we really designing for our future selves?
Elizabeth Buie - Older adults: Are we really designing for our future selves?Elizabeth Buie - Older adults: Are we really designing for our future selves?
Elizabeth Buie - Older adults: Are we really designing for our future selves?
Nexer Digital
 
Monitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR EventsMonitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR Events
Ana-Maria Mihalceanu
 
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
Neo4j
 
20 Comprehensive Checklist of Designing and Developing a Website
20 Comprehensive Checklist of Designing and Developing a Website20 Comprehensive Checklist of Designing and Developing a Website
20 Comprehensive Checklist of Designing and Developing a Website
Pixlogix Infotech
 
Climate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing DaysClimate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing Days
Kari Kakkonen
 
PCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase TeamPCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase Team
ControlCase
 
Enchancing adoption of Open Source Libraries. A case study on Albumentations.AI
Enchancing adoption of Open Source Libraries. A case study on Albumentations.AIEnchancing adoption of Open Source Libraries. A case study on Albumentations.AI
Enchancing adoption of Open Source Libraries. A case study on Albumentations.AI
Vladimir Iglovikov, Ph.D.
 
Introduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - CybersecurityIntroduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - Cybersecurity
mikeeftimakis1
 
Building RAG with self-deployed Milvus vector database and Snowpark Container...
Building RAG with self-deployed Milvus vector database and Snowpark Container...Building RAG with self-deployed Milvus vector database and Snowpark Container...
Building RAG with self-deployed Milvus vector database and Snowpark Container...
Zilliz
 
UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5
DianaGray10
 
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
Neo4j
 
Video Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the FutureVideo Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the Future
Alpen-Adria-Universität
 
DevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA ConnectDevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA Connect
Kari Kakkonen
 
A tale of scale & speed: How the US Navy is enabling software delivery from l...
A tale of scale & speed: How the US Navy is enabling software delivery from l...A tale of scale & speed: How the US Navy is enabling software delivery from l...
A tale of scale & speed: How the US Navy is enabling software delivery from l...
sonjaschweigert1
 

Recently uploaded (20)

GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
 
Communications Mining Series - Zero to Hero - Session 1
Communications Mining Series - Zero to Hero - Session 1Communications Mining Series - Zero to Hero - Session 1
Communications Mining Series - Zero to Hero - Session 1
 
20240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 202420240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 2024
 
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
 
20240605 QFM017 Machine Intelligence Reading List May 2024
20240605 QFM017 Machine Intelligence Reading List May 202420240605 QFM017 Machine Intelligence Reading List May 2024
20240605 QFM017 Machine Intelligence Reading List May 2024
 
GraphSummit Singapore | The Art of the Possible with Graph - Q2 2024
GraphSummit Singapore | The Art of the  Possible with Graph - Q2 2024GraphSummit Singapore | The Art of the  Possible with Graph - Q2 2024
GraphSummit Singapore | The Art of the Possible with Graph - Q2 2024
 
Elizabeth Buie - Older adults: Are we really designing for our future selves?
Elizabeth Buie - Older adults: Are we really designing for our future selves?Elizabeth Buie - Older adults: Are we really designing for our future selves?
Elizabeth Buie - Older adults: Are we really designing for our future selves?
 
Monitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR EventsMonitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR Events
 
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
 
20 Comprehensive Checklist of Designing and Developing a Website
20 Comprehensive Checklist of Designing and Developing a Website20 Comprehensive Checklist of Designing and Developing a Website
20 Comprehensive Checklist of Designing and Developing a Website
 
Climate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing DaysClimate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing Days
 
PCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase TeamPCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase Team
 
Enchancing adoption of Open Source Libraries. A case study on Albumentations.AI
Enchancing adoption of Open Source Libraries. A case study on Albumentations.AIEnchancing adoption of Open Source Libraries. A case study on Albumentations.AI
Enchancing adoption of Open Source Libraries. A case study on Albumentations.AI
 
Introduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - CybersecurityIntroduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - Cybersecurity
 
Building RAG with self-deployed Milvus vector database and Snowpark Container...
Building RAG with self-deployed Milvus vector database and Snowpark Container...Building RAG with self-deployed Milvus vector database and Snowpark Container...
Building RAG with self-deployed Milvus vector database and Snowpark Container...
 
UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5
 
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
 
Video Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the FutureVideo Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the Future
 
DevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA ConnectDevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA Connect
 
A tale of scale & speed: How the US Navy is enabling software delivery from l...
A tale of scale & speed: How the US Navy is enabling software delivery from l...A tale of scale & speed: How the US Navy is enabling software delivery from l...
A tale of scale & speed: How the US Navy is enabling software delivery from l...
 

How-to Create a 'Lock' record in Salesforce

  • 1. How to create a “Lock” record in Salesforce without using Apex code or an approval process A recent request from a client required Saaspoint to create a record lock outside the usual approval process. Lead Developer Enda Traynor identified three potential ways to create the required record lock: 1. Use Record Types and Page Layouts with an integrated Javascript button which “locked” the record when clicked by setting all of the displayed fields to read-only. 2. Use an update Trigger which could set the record to “locked”, again by setting fields to read-only. 3. Create a simple button on the record which updates a new field called Locked__c Method 3 was decided to be the most efficient and flexible solution, which can be implemented as follows:  Add the Lock_Record button to an Opportunity: {!REQUIRESCRIPT("/soap/ajax/22.0/connection.js")} //adds the proper code for inclusion of AJAX toolkit var url = parent.location.href; //string for the URL of the current page var opp = new sforce.SObject("Opportunity"); // Create an Opportunity object that will be used to update. opp.Id = '{!Opportunity.Id}'; // Set the Id so that we know which record we are updating. opp.Locked__c = true; // Set the record as ‘Locked’ by setting the Locked__c field. result = sforce.connection.update([opp]); // update the Opportunity record parent.location.href = url; //refresh the page
  • 2. The code references a simple, read-only checkbox called Locked__C which is displayed on the page but which the user cannot change once it is set (the value is set via the page layout settings). A validation rule is also implemented on the page with logic to allow the Locked__c field to be set to true: Locked__c && NOT(ISCHANGED(Locked__c)) Screen shots 1. Screen shot showing un-ticked and read-only checkbox and "Lock Record" button: 2. a. Screen shot showing attempt to edit the record while it is not locked: b. Screen shot showing record saved with successful change:
  • 3. 3. Screen shot showing after record was locked (see checkbox) that user cannot edit the record any more If you’d like to speak to Enda or a member of the Saaspoint team, please feel free to contact us on +44 0 207 182 4707 and we’d be happy to advise you on your web self-service needs.