In my previous article I outlined how to invoke a lookup dialog on a Freedom UI page. In this article, we’ll expand on that idea to allow adding to a list from a lookup. For this sample, we have a list on the account page of products owned by the account. We’ll add a button to invoke a lookup to allow the user to select one or multiple products to add to the account’s product list.
The end result will be as follows:

The code to accomplish this will be very similar to the previous article. The main difference will be that instead of flattening out the text values of the selected items, we’ll use a model Insert to add the records.
View Inserting a Record from Client-Side Code Using the Model Class
Note, first make sure you’re adding the Creatio devkit to the page as sdk (see article above). The code for the request of the click of our button will look like this:
request.$context.executeRequest({
type: "crt.OpenLookupPageRequest",
$context: request.$context,
entitySchemaName: "Product",
caption: "Select products to add to the account",
features: {
select: {
multiple: true,
selectAll: false,
resultType: 'lookupValues'
},
create: {
enabled: false
}
},
afterClosed: async function(selectedItems) {
// add each selected item from the lookup to the list
const accountId = await request.$context.Id;
const accountProdModel = await sdk.Model.create("UsrAccountProduct");
selectedItems.forEach(product => {
accountProdModel.insert({
UsrAccount: accountId,
UsrProduct: product.value
});
});
}
});
To make it so the items appear in the list without the need to refresh it, simply enable live data update for the entity you’re adding to.




Information on how to add this custom code to the action of when a button is clicked would be useful. I think there is another CustomerFX article on it that could be used to link to for this purpose.
Yes. The article that shows how to add custom code for the click of a button can be found here: https://customerfx.com/article/adding-a-button-to-execute-custom-code-on-a-creatio-freedom-ui-page/
Ryan
hello!
Could you please provide more detail about where to place the code u provided? I am quite new with creatio platform, and I don’t know what to do with your code, how can i make it work?
Hi Ryan,
I need to filter the page that is opening in OpenLookupPageRequest. I have added filtersConfig : filters, but it’s not working. Can you provide an example on that. Thanks in advance.
You can see that in the comment in this thread in the community:
https://community.creatio.com/questions/filter-crtopenlookuppagerequest
Ryan
Hi Ryan,
Would it be feasible to include a filter feature in the open modal ? This would allow users to customize their results. Thanks in advance.
If you want to customize the lookup window, that is possible. Refer to this Academy article: https://academy.creatio.com/docs/8.x/dev/development-on-creatio-platform/platform-customization/freedom-ui/selection-window/overview
Hi Ryan,
I’ve encountered an issue when setting selectAll: true. Specifically, when I attempt to save the selected items, I receive the following error:
{ resultType: ‘lookupValues’, selectAll: true, … } is not supported. Use { resultType: ‘lookupValues’, selectAll: false, … } or { resultType: ‘filter’, selectAll: true, … } instead.
Could you help me understand the root cause of this issue? Additionally, do you have an example implementation that uses the selectAll setting correctly?
The reason for this is that when you “select all” you don’t get all the Id values, but instead get the filter used for the “all”. What the error is telling you, that instead of using resultType of “lookupValues” (which is the array of selected Id values) you need to use resultType = “filter” so you get the filter used for the “all” records from the lookup. BTW this actually changed since it was originally released (you used to be able to select all, it just turned out to not work for very large lists of data)
The “crt.OpenLookupPageRequest” still works but is deprecated and replaced by “crt.OpenSelectionWindowRequest”, you can see the details of that in the Academy here https://academy.creatio.com/docs/8.x/dev/development-on-creatio-platform/category/selection-window or in the Community here https://community.creatio.com/questions/filter-crtopenlookuppagerequest
Hello,
Do you have any news regarding an update for Freedom UI ?
Thanks a lot
Hi Oliver,
Can you explain more what you mean? This article is for Freedom UI.
Ryan