To lock all elements on the page you need to install package GlbPageReadOnlyMode and set up page.
-
Initialize readOnly mode:
init: function() { this.subscribeReadOnlyEvent({ excludedDetails: [/*Here add details you want to exclude*/], excludedModules: [/*Here add modules you want to exclude*/], excludedItems: [/*Here add fields you want to exclude*/] }); this.callParent(arguments); }
-
Set up condition to lock a page:
changeReadOnlyMode: function() { if (this.get("Contact")) { // If "Contact" field is filled in, then the page is locked this.setPageReadOnlyMode(this, true); } else { this.setPageReadOnlyMode(this, false); } }
Example: lock page "ContactPageV2" when "Account" field is filled in:
ContactPageV2
define("ContactPageV2", [], function() { return { entitySchemaName: "Contact", methods: { init: function() { this.subscribeReadOnlyEvent(); this.callParent(arguments); }, changeReadOnlyMode: function() { if (this.get("Account")) { this.setPageReadOnlyMode(this, true); } else { this.setPageReadOnlyMode(this, false); } } } }; });