TrackWise Digital - DMS Application - How to Override and make changes to locked EFFECTIVE Document using Flows and Invocable method.
Document management systems (DMS) is one of the known solutions pharma organization use to manage their internal quality processes and store/ track all documentation related to quality.
By using cloud-based product we have advantages over documents getting lost, outdated version rendered to stakeholders, irregular audit tracking like who made the changes and when. These qualities are necessary for good quality software as part of internal adulting process.
The document are uploaded into the DMS system by DMS administrators. The document must go through a pre-defined workflow review process before it is made EFFECTIVE and made available for end users for training reference.
The workflow lifecycle for DMS workflow approval cycle includes a) Draft, b) In Review, c)Under Approval and d) EFFECTIVE. Once the document is EFFECTIVE, the document is locked for further editing. The document is later used for internal training and can be printed and shared with internal users for performing internal duties as SOP reference.
Below is the preview of EFFECTIVE document in DMS application which is in LOCKED state .

From the above document screenshot , we can see the document is EFFECTIVE and we do not have edit icon made available to make further edit to the EFFECTIVE document. To perform edit operation on the record we need to click the CHECKOUT icon which will bring the document back to draft or working version.
Performing CHECKOUT action to re edit the document would have following disadvantages:
a) Checkout the document and bring the document to working state
b) The DMS admin should make the necessary changes and reupload the correct version of the document
c) Ask the reviewers to review the changes and complete review cycle . Admin has to submit the record to approval cycle .
d) Ask approvers to approver the document and complete approval cycle .
e) Wait for X number of days before document become EFFECTIVE based on X value set in Document Auto Effective (days) field
f) Alternatively, DMS admin can make the document EFFECTIVE manually by clicking Make Effective.
Developer console :
We have developer console tool given by salesforce where we can view the record using SOQL ( Salesforce Object Query Language ) and make changes directly via this tool . With this handy tool one can make changes to the record with safety. If we try to make changes to locked EFFECTIVE document via developer console we will be presented with DOCUMENT LOCKED error .
Lets try to make changes to the document name via developer console and see the error . I will fetch the document with following SOQL :
SELECT Id, Name FROM SPARTADMS__Corporate_Document__c where ID='xx';
Where XX is the document ID in the URL .
Lets make direct changes inside developer console and see the error:
As you can see when I tried to make changes to the locked EFFECTIVE document name inside developer console from ‘Override EFFECTIVE document’ TO ‘Override EFFECTIVE document - manual edit via developer console’ . I have been presented with error .
[object Object] Document is locked .
The system presented the error ‘ Document is locked ‘ which is known behavior of the system . There is a backend trigger on the EFFECTIVE document which will stop you from making changes directly via developer console . The same holds true if you try to do it via Postman tool via API or workbench console . The system will not allow you to make changes in backend .
THE SOLUTION
I have designed a workable solution where DMS admin can make changes to EFFECTIVE document without CHECKING out the document which really saves a lot amount of time from amending the document and later making the document EFFECTIVE and make it available for use to stakeholders in short time.
The only solution I did see is via Apex class Invocable method which is called via flows . The apex class will stop the trigger execution responsible for holding lock on EFFECTIVE document via apex class and make changes to the document with inputs received from screen flow element.
The solution to the problem involves:
a) Design a screen flow which will accept input parameters like Document Name , Document Type , Document Status etc which needs to be amended in the EFFECTIVE document
b) Call Apex INVOCABLE action class to do changes via Apex code .
c) Create a new lightning app record page and place the flow component on to the page
d) Run the flow component either via record page or via Quick Action.
Designing the Screens flow:
Variables
Create a resource variable named: recordid ( it should be as mentioned , no other variation) .
Screen Flow input Element
Place the corporate document field : Document Name on the screens flow as shown in below snip. Drag the field from ‘ Fields (beta) section . For demonstration purpose we will only use one field 'Document Name'. We can add as many fields in the screen flow element which needs to be updated on the locked EFFECTIVE document .
Apex Action Element .
Below is the snip of apex element from where we will be calling apex class which is of type Invocable Method.
More about Apex invocable. Please read salesforce developer blog .
Apex Class with Invocable Action :
Below is the Apex Class with logic :
public class CorporateDocumentFlow
{
@InvocableMethod(label='Update DMS Record' description='Adhoc update DMS record fields ' )
public static void updateDMSRecords(List<SPARTADMS__Corporate_Document__c> cdId)
{
// logic hidden due to security purpose .
}
}
VIDEO
DEMONSTRATION
Quick
video in action , which shows by using screen flow we are able to make changes to the LOCKED EFFECTIVE document from ‘ Override EFFECTIVE document ‘ to ‘ Manual Edit Success ‘ .
Again
from Manual Edit Success to Manual Edit Success+1
Again
from Manual Edit Success+1 to Manual Edit Success+2 .
How
about the Audit Trail .?
As
per compliance and auditing requirement, the sparta utility class will track all
document changes in the audit trail history . Attached is the screenshot of the document Audit trail history after the flow has made changes to the document which was in EFFECTIVE locked state .









Comments
Post a Comment