Getting Multi-select Records from a Creatio Freedom UI List via Code

Creatio 8.1 and higher supports multi-selected records in lists. You can add an action for the list, which get’s added to the list’s bulk actions bar at the bottom. You can pretty easily get the selected records in your own request handler code.

The first step is to add your own button to the list’s bulk actions bar.

When you do this, you’ll be setting up the action request handler in code in the same way you do for buttons (see article here). In the handler, the key part is to get the selected records. In order to do that, you’ll need to know what the attribute is that the List stores the selections in. The List will have a “selectionState” property where you’ll see this. Here’s a sample from a list:

{
	"operation": "merge",
	"name": "DataTable",
	"values": {
		"selectionState": "$DataTable_SelectionState",
		// ...
}

In that sample above, you can see the selectionState is bound to the attribute named “DataTable_SelectionState” (the $ is not a part of the name, that is what indicates it is bound to an attribute named that). The list will use an attribute named “DataTable_SelectionState” to store the selections. The value of that attribute will be an object that has a property named “selected” which will be an array of Id’s for the selected records. In the request handler you set up for the bulk actions button, you’d use the following to get the array of selected Id values:

const selectedIds = (await request.$context.DataTable_SelectionState).selected;

Note, in the code above, we’re getting the value of the DataTable_SelectionState attribute (and awaiting the result), then getting the selected property of the object returned. Now you can do whatever is needed with each Id, such as execute a process or perform some other bulk action.

Want content like this delivered to your inbox? Sign up for our newsletter!
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 *