I am updating an external accounting system with information from custom objects like

  • Invoice
  • Credit Note
  • Payment Transaction

The Invoice and Credit Note custom objects have Status picklist fields which has values like:

Draft > Sent > Paid

Once the information has been posted from Salesforce to the external system, the record is updated to Status = Sent and the record in Salesforce cannot be changed. Apart from the record Status which can progress to Paid


What is the best approach to stop users from being able to change the record once the data has been posted into the accounting system?

  • Correct me if I am wrong. You wanted to prevent the users from Editing the Records once they are synced/sent to External System. right? And User Can Edit Status of the records to Final or whatever the value is. Are you using any field which tells that this particular record has been sent to External System? I mean any checkbox. – Amit Singh Jul 12 '18 at 13:35
  • @AmitSingh there isn't a field which identifies the sync has happened other than the Status – Robs Jul 12 '18 at 16:39
  • You can Do it using 2 Diff ways: 1 - With the Help of Record Type and Page layout. Create a Record Type and Page Layout associated with this Record Type which will contain all the Read Only Fields except Status. 2 - Create a Validation Rule and check If any field changed except the Status Field then Though the Error. If you are not using Record Type then I will prefer the second Option as for 1st Option you will need to Create type. also, it will ask the user to select record type while creating the Record. – Amit Singh Jul 12 '18 at 16:52
  • @AmitSingh please don't provide answers as comments – Robs Jul 12 '18 at 17:20

At the UI level, the best approach is to use record types with different layouts. A layout with the editable fields (for the record which has not been posted to the external system), and another one with just the status field editable (when the data has been posted).

At the API/platform level, you are better off using validation rules. You need a field on the record to indicate wether it was posted successfully to the external system or not. If it was, then your validation rule would detect changes on that record's fields, and show an appropriate error message to the user, when she/he tries to update the record.

  • I guess you would dynamically change the record type when the Status is changed? – Robs Jul 12 '18 at 16:38
  • 1
    Exactly. If I'm not mistaken, you can do this using a workflow rule, process builder, or a trigger. – Renato Oliveira Jul 12 '18 at 16:49

Since record is still editable except the status, then display rest of fields in UI as read only format.

You can use lightning:outputField or lightning:outputText for read only view.

Otherwise, you can display error messages if user changes the other fields.

  • 1
    This would involve creating a custom lightning component rather than using the default record details component. Which I would rather not have to do, but is an option. (FYI - I did not downvote you) – Robs Jul 12 '18 at 16:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.