
Creatio 8.1 introduces two new features when it comes to lookups and lists. First, is the addition of a Lookup dialog (instead of the drop-down type lookup that has been the only option for lookups previously for Freedom UI). Second, is the ability to multi-select from lists, which includes the list on the new Lookup dialog. With that said, this article only works for version 8.1 and higher.
NOTE: This technique only works in Creatio 8.1 or higher
We’re going to look at how to programmatically invoke the new Lookup dialog and also how to allow for multiple items to be selected. For this article, we’ll allow multiple account types to be selected and then we’ll place the result in a text field on the page. The end result will be as follows:
To invoke the lookup dialog, we’ll execute a crt.OpenLookupPageRequest. We can pass parameters to this request, such as the entity to lookup and also whether we want the user to be able to select multiple items. For some reason, rather than await the results, we’ll include a callback function that will get invoked when the lookup dialog closes. We’ll be passed an array of the selected items in this function. This article will flatten this out to a string of comma-separated items and place in a text field. Let’s look at the code:
request.$context.executeRequest({ type: "crt.OpenLookupPageRequest", $context: request.$context, entitySchemaName: "AccountType", //filtersConfig: add any filters here features: { select: { multiple: true, selectAll: false, resultType: 'lookupValues' }, create: { enabled: false } }, afterClosed: function(selectedItems) { // flatten out to a comma-delimited string and place in field const textValues = Object.values(selectedItems).map(item => item.displayValue).join(', '); request.$context.StringAttribute_2pp5ptx = textValues; } });
There’s still more to figure out for invoking the lookup. Note you can set a filter for the lookup, however, I am still working out if pre-selecting items is possible in the current version (not sure that is possible quite yet).
Other Lookup Request Properties
A few other available properties that can be included in the request:
- filersConfig: Add additional filters for the lookup
- caption: Provide a different caption for the lookup dialog
- schemaName: Provide an alternative lookup page to use for the requst
- itemsAttributeName: Instead of providing an entitySchemaName proeprty, you can provide the name of an existing datasource on the page. This also allows the data source to be filtered when it requests it’s data for the lookup dialog.
In the near future I will be wrapping this all up as a reusable component for a Freedom UI replacement for my marketplace add-on Multi-Select Text Field.
hi Ryan, excuse my Creatio noobie question, can you explain the difference / benefits between your existing Multi-Select text field and this new Lookup method please?
i.e. which is better for reporting?
Hello Vincent,
Creatio currently has two different page types. The page types that have existed since the beginning of Creatio are now referred to as “Classic” pages. The newer type of page is referred to as “Freedom UI” pages. The two types are both using very different tech behind everything.
My existing Multi-Select text field control works only with classic pages – and will continue to work with classic pages only. This article outlines how to accomplish something similar on the newer Freedom UI page type. I will be creating a version of the Multi-Select text field for Freedom UI pages in the future.
Hopefully that helps.
Ryan
Hi Ryan, thank you for your reply and explanation.
Do your solutions enable reporting for each multiple value selected?
Coming from experience with other CRM’s I’m very surprised Creation hasn’t included multiselect dropdowns/lookups within the core product.
As far as reporting, that is up to the report and how you want to view the data. The data is saved in the database as a comma-delimited string, so the data is there and available – depending on the report needs would determine if the comma-delimited string is useful or not.
Hi Ryan, do you have any guides or info on how to apply the filters mentioned under filtersConfig at the bottom of this article? I can’t see any academy articles on how this should be configured, and it would be quite useful to be able to apply some filters to the lookup being shown.
Hi Harvey,
I have started digging into that. I expect to have an article written up on it soon. Still working out a few details.
Ryan