back to top

Sorting a Dropdown Lookup on a Creatio Freedom UI Page

By default, dropdown lookups on a Creatio Freedom UI page sort by alphabetical order. However, it’s possible to change this sort by modifying an attribute for the dropdown lookup that stores the sort config.

To modify this sort, in the page’s model initialization request, you’ll get the current sort config, then modify it to the sort you’d like. The sort config is stored in an attribute that begins with the name of the attribute that the control is bound to, followed by “_List_Sorting”. So, if the attribute that the control is bound to is “PDS_Stage_l08enh0” the sort attribute will be named “PDS_Stage_l08enh0_List_Sorting”. To be clear, this is the name of the attribute the control is bound to, not the name/Id of the control. Also, this method is for dropdown lookups only, not lookups that open the lookup dialog.

In this sample, I have a dropdown for the Opportunity stage. Normally, this will appear sorted alphabetically. I want it to appear in the order of the stages by the stage Number column in ascending order. To make the control sort in this way, I’ll add the following request to the page:

{
	request: "crt.HandleViewModelInitRequest",
	handler: async (request, next) => {
		const sortConfig = await request.$context.PDS_Stage_l08enh0_List_Sorting;
		const firstSort = sortConfig[0];
		firstSort.columnName = "Number";
		firstSort.direction = "asc";
                    
		return next?.handle(request);
	}
}

In the code above, by dropdown lookup is bound to an attribute named “PDS_Stage_l08enh0”, hence getting the sort config from “PDS_Stage_l08enh0_List_Sorting“. There should already be a sort config at index 0 since it’s the default sort by display value in alphabetical ascending order. The end result will be as follows:

 

Contact Customer FX for your CRM project
We let our expertise speak for itself - let us know how our all-star team can help on your CRM project
About the Author
Ryan Farley
Ryan Farleyhttps://customerfx.com/article/author/ryanfarley/
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.

6 COMMENTS

  1. Hi Ryand

    One question, I add sorting options in accounts to three lookups (Account Type, Annuel Revenue & Number of employees), but just works Annual Revenue. What could be wrong in my code’

    {
    request: “crt.HandleViewModelInitRequest”,

    // 1.- Typo Empresa
    handler: async (request, next) => {
    //await next?.handle(request);
    let sortingConfigList = await request.$context.Type_List_Sorting;
    let firstSortingConfig = sortingConfigList[0];
    firstSortingConfig.columnName = “NdosOrdenarPor”; // New field added to sort
    firstSortingConfig.direction = “asc”; //desc or asc
    return next?.handle(request);
    },

    // 2.- Nro de Empleados
    handler: async (request, next) => {
    //await next?.handle(request);
    let sortingConfigList = await request.$context.EmployeesNumber_List_Sorting;
    let firstSortingConfig = sortingConfigList[0];
    firstSortingConfig.columnName = “Position”;
    firstSortingConfig.direction = “asc”; //desc or asc
    return next?.handle(request);
    },

    // 3.- Annual revenue/Facturacion anual
    handler: async (request, next) => {
    //await next?.handle(request);
    let sortingConfigList = await request.$context.AnnualRevenue_List_Sorting;
    let firstSortingConfig = sortingConfigList[0];
    firstSortingConfig.columnName = “FromBaseCurrency”;
    firstSortingConfig.direction = “asc”; //desc or asc
    return next?.handle(request);
    }

    }

    • Hi Julio,

      The syntax is incorrect. You have two options:

      OPTION 1: Add separate request handlers:

      {
          request: "crt.HandleViewModelInitRequest",
          handler: async (request, next) => {
              // init handler #1
              return next?.handle(request);
          }
      },
      {
          request: "crt.HandleViewModelInitRequest",
          handler: async (request, next) => {
              // init handler #2    
              return next?.handle(request);
          }
      },
      {
          request: "crt.HandleViewModelInitRequest",
          handler: async (request, next) => {
              // init handler #3        
              return next?.handle(request);
          }
      }

      OR

      OPTION 2: Add it all to the same init handler (*this is the route I would recommend):

      {
          request: "crt.HandleViewModelInitRequest",
          handler: async (request, next) => {
              // do everything here
      
              // add filter for lookup #1
      
              // add filter for lookup #2
      
              // add filter for lookup #3
              // etc
              return next?.handle(request);
          }
      }

      Ryan

    • Basically, a request handler has two parts:

      1. request: The name of the request to handle
      2. handler: The function body that will handle the request

      You can’t have multiple handler function bodies for the same request, unless you separate them all as separate requests with the two parts listed above.

    • Hi Damien,

      Whether or not it’s even possible to sort will depend on if it even uses a sort attribute like a normal lookup does. I’ve not tried. To figure out stuff like this, I typically will add a change request handler and output to the console any attribute names that change that contain the name of the quick filter. If that doesn’t reveal anything useful, I’ll write out to the console every attribute name that fired the change handler.

      However, it’s possible, and even likely, that the quick filter lookup doesn’t even support adding a sort.

  2. Ryan, Creatio’s Community won’t let me post for some reason… so instead, I stumbled on this article from another customer and you get to be the direct benefactor of my info! 🙂

    You can sort any/all Freedom UI lists from the viewModelConfig very easily, no handler needed. Simply find whatever lookup DS you want to sort, create a copy with “_List” appended as a new entry in ViewModelConfig, then set your default sorting. With this approach, you can sort pretty much any/all lists, including quick filters.

    The below example is as of version 8.2.1. Not sure whether this works on older versions of Freedom UI, but I would assume anything >8.1.

    “PDS_YourLookup”: { // This is the existing lookup dropdown that we want to filter
       “modelConfig”: {
           “path”: “PDS.YourLookup”
       }
    },
    “PDS_YourLookup_List”: { // Create a new attribute for our _List
       “modelConfig”: {
           “sortingConfig”: {
               “default”: [
                   {
                       “columnName”: “Name”, // Replace with the actual object code to sort by
                       “direction”: “desc” // or “asc” for descending order
                   }
               ]
           }
       }
    }

LEAVE A REPLY

Please enter your comment!
Please enter your name here

AI Readiness Checklist for CRM Teams: Is Your CRM System Ready for AI?

Before using AI in Creatio, make sure your CRM data, users, processes, and automation foundation are ready. Use this practical AI readiness checklist for CRM teams.

Build Your Creatio AI Skills with the 2026 AI Summer Program

Join Creatio’s free 2026 AI Summer Program to learn how to identify, build, deploy, and manage AI agents.

Creatio 10x Is Coming: Join the Webinar to Explore the Future of AI-Native CRM

Learn what's new in Creatio 10x and how AI-native CRM, agentic AI, and no-code automation are shaping the future of customer relationship management. Join the upcoming webinar and discover what's next.

Creatio Unlimited Pricing Explained: AI Packages, Costs, Pros & Cons

Learn what Creatio’s new Unlimited pricing model includes, what it doesn’t include, how AI Action packages work, and the pros and cons for businesses evaluating Creatio.

Using the AI Prompt to Create Dynamic Folders in Creatio

Using Creatio's AI prompt to create the filter for a dynamic folder works best if you specifically ask for that, and if you are as clear and direct as possible about the filtering, conditions.

Related Articles

AI Readiness Checklist for CRM Teams: Is Your CRM System Ready for AI?

Before using AI in Creatio, make sure your CRM data, users, processes, and automation foundation are ready. Use this practical AI readiness checklist for CRM teams.

Build Your Creatio AI Skills with the 2026 AI Summer Program

Join Creatio’s free 2026 AI Summer Program to learn how to identify, build, deploy, and manage AI agents.

Creatio 10x Is Coming: Join the Webinar to Explore the Future of AI-Native CRM

Learn what's new in Creatio 10x and how AI-native CRM, agentic AI, and no-code automation are shaping the future of customer relationship management. Join the upcoming webinar and discover what's next.

Creatio Unlimited Pricing Explained: AI Packages, Costs, Pros & Cons

Learn what Creatio’s new Unlimited pricing model includes, what it doesn’t include, how AI Action packages work, and the pros and cons for businesses evaluating Creatio.

Related Videos