Iterating Through All Properties Bound to a Page in Creatio (formerly bpm’online)

There might be times when you need to iterate through all properties bound to a page in Creatio. I recently needed to implement a reset/clear button for a form where all entered values would be cleared. I didn’t want to hard-code all the properties since there were many, also, that would mean I’d have to update the code anytime a new property was added.

Luckily, this is pretty easy to do. Note, the method I’ll be describing here will iterate through all the properties of the object the page is bound to, not just the ones added as elements to the page itself. The page has a object called model, which has all the attributes for the bound object. Note, there are other types of attributes for the page, not just the object columns. What I typically do is look for my prefix (such as “Usr”) and only get those properties since they will represent the columns for the bound object.

Let’s take a look at the code:

for (var property in this.model.attributes) {
    // make sure we're only getting the object properties by using our prefix
    if (property.length > 3 && property.indexOf("Usr") !== -1) {

        // if you want to exclude certain properties, you could check for them here
        if ( property !== "UsrSomePropertyId" && property !== "UsrOtherProperty") {

            // if you want to clear the properties you could set all to null
            this.set(property, null);
            // etc...
        }
    }
}

Again, this is iterating through the properties of the model, or bound entity object, not only the ones added to the page. When using this approach, be aware that there are many more attributes on a page than just the bound object properties, so be sure to take a look at what you’re getting back from this.model.attributes so you’re sure it is what you’re after.

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!