Setting the Default Sort Column and Direction for a Detail in Creatio (formerly bpm’online)

There are a few different options for setting a sort for details in Creatio. You can add a default sort column and direction to a detail added to a page schema,  or you can add the sort in the detail schema so the sort will apply to the detail no matter where it is used. Let’s take a look at both options.

Adding the Sort to the Detail

If you want to always ensure the detail has your sort column and direction, no matter where you use the detail, the best route is to add it in the detail schema. Then, no matter what page you add the detail on, the sort is built into the detail schema itself and will apply anywhere. To do this, we’ll open the detail schema code in the configuration, then override the onGridDataColumns function by adding the following to the methods:

addGridDataColumns: function(esq) {
    this.callParent(arguments);
 
    // add the column we want to sort by to the EntitySchemaQuery passed in
    // We can use any column, whether or not it is in the column layout for the detail
    // in this sample we'll be sorting on the CreatedOn column in descending order
    var createOnCol = esq.addColumn("CreatedOn", "CreatedOn");
    createOnCol.orderPosition = 0;
    createOnCol orderDirection = Terrasoft.OrderDirection.DESC;
}

 

Adding the Sort to the Page the Detail is On

If the detail is on a page and you want to add a sort to it, you can do it in the details page of the page code. This method is useful if you don’t need or want to override the detail schema, for cases when the detail itself is in another package. To do this, open the page code and locate the details section. You’ll see the detail there as follows (this is what is added by the page wizard when you add a detail normally):

details: /**SCHEMA_DETAILS**/{
    "UsrMyDetail": {
        "schemaName": "UsyMyObject",
        "filter": {
            "masterColumn": "Id",
            "UsrAccount"
        }
    }
}

Add the sort column and direction as shown below (again, in our sample we’ll be sorting on the CreatedOn column in descending order):

details: /**SCHEMA_DETAILS**/{
    "UsrMyDetail": {
        "schemaName": "UsyMyObject",
        "filter": {
            "masterColumn": "Id",
            "UsrAccount"
        },
        "sortColumn": "CreatedOn",
        "sortColumnDirection": Terrasoft.OrderDirection.DESC,
        "sortColumnIndex": 0
    }
}

Either method should give you the results you’re after, however, also keep in mind that the user can click on column headers to sort the detail as well. The user’s specified sort will take precedence over what you specify in the code.

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!