Article

Set page to ReadOnlyMode

To lock all elements on the page you need to install package GlbPageReadOnlyMode and set up page.

  1. 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);
    }

     

  2. 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);
                }
            }
        }
    };
});

 

Like 0

Like

Share

0 comments
Show all comments