Conditionally Making a Detail Read-Only in Creatio

I wrote an article before about how to make a detail read-only. The method in the article stubbed out the functions to add the edit, copy, and delete menu items. What if you want to use a detail in several different sections but only allow add, edit, delete from one of these sections? We can do this by checking to see what column is being used to connect a detail and then only calling the parent of those functions when it’s the column for the section we want to allow these functions in.

In this example, I have a detail for “connected inventory” which is connected to accounts, opportunities, contacts, etc. I only want to allow records to be added, edited, or deleted if the detail is being used in the Inventory section (and these functions aren’t available if the detail is being used in the account, opportunity, or contact sections). The column in this detail that connects to “Inventory” is called “UsrInventory”, so we’ll check to see if that is the column being used in the detail to connect it to the page, and if so we’ll allow the functions to be used by basically calling their parent implementations. Let’s take a look at the code:

getAddRecordButtonVisible: function() {
    return (this.get("DetailColumnName") === "UsrInventory");
},
          
getEditRecordMenuItem: function() {
    if (this.get("DetailColumnName") === "UsrInventory") {
        return this.callParent(arguments);
    }
},
          
getCopyRecordMenuItem: function() {
    if (this.get("DetailColumnName") === "UsrInventory") {
        return this.callParent(arguments);
    }
},
          
getDeleteRecordMenuItem: function() {
    if (this.get("DetailColumnName") === "UsrInventory") {
        return this.callParent(arguments);
    }
}

The code above is similar to the original article, but instead of just stubbing out, or replacing with an empty function, the functions to create the menu items, it instead checks the column the detail is connected with and then only calls the parent when it’s the column we want.

Note, in the example above, we’re using the column the detail is connected to the page/record with. If wanted, we could also use the page the detail is on, such as the following:

if (this.get("CardPageName") === "ContactPageV2") {
    //...
}
ABOUT THE AUTHOR

Ryan Farley

Ryan Farley is the Director of Development for Customer FX and creator of slxdeveloper.com. He's been blogging regularly about SalesLogix, now Infor CRM, since 2001 and believes in sharing with the community. His new passion for CRM is Creatio, formerly bpm'online. He loves C#, Javascript, web development, open source, and Linux. He also loves his hobby as an amateur filmmaker.

Submit a Comment

Your email address will not be published. Required fields are marked *

Subscribe To Our Newsletter

Join our mailing list to receive the latest Infor CRM (Saleslogix) and Creatio (bpm'online) news and product updates!

You have Successfully Subscribed!