Refreshing/Reloading Page or List Data on a Creatio Freedom UI Page

For classic Creatio pages, to refresh or reload a page you used a function on the page named reloadEntity. There was a separate method for reloading a detail on a page. However, in Freedom UI Pages, the structure of the page is different and along with this a new way to refresh anything on the page.

In classic Creatio pages, the details were self contained as a separate schema. It was added to the page, but the logic for the detail was all separate. In a Creatio Freedom UI page, there is no longer separate details from the page itself. Instead, a list is just another element in the page that uses a separate data source on the page. When you create a Freedom UI page, there is a primary data source for the page (on out of the box Account and Contact pages in the Customer 360 package for 8.0.6, this primary data source is named “PDS”, however it can be named anything). When you add a list, or 1:many grid of records, to the page it adds another data source for that list. Refreshing the page or list data is just a matter of telling the appropriate data source to reload.

Data Sources on a Freedom UI Page

In order to reload a data source, you need to first determine the name of the data source you want to reload. To see the available data sources on a page you need to look for the modelConfig element in the page code. In the modelConfig you’ll see a node for dataSources. There you’ll see the page’s dataSource (with scope:page) and also the data source for any lists.

Note for identifying the primary data source: The primary data source is the data for the page itself. You can look at modelConfig.primaryDataSourceName. This will provide the name of the primary, or page’s data source. If you want to get this in a handler in the page code, you can use await request.$context.getPrimaryModelName();

Reloading a Data Source

With the data source name, you can now reload that data source. Obviously, to reload the page data, you’ll use the primary data source. To reload a specific list, you’ll use the name of the data source for the list. To reload a data source, we’re simply triggering a crt.LoadDataRequest request and supplying the name of the data source to reload. The page has a handler for this request, and when received, will reload the specified data source.

The code to reload the data source is as follows:

request.$context.executeRequest({
	type: "crt.LoadDataRequest",
	$context: request.$context,
	config: {
		loadType: "reload",
		useLastLoadParameters: true
	},
	dataSourceName: "DataSourceNameHere"
});

In the code above, obviously, you’ll replace the “DataSourceNameHere” with the name of the data source you want to reload. However, if you’d like to dynamically use the primary data source for the page, without needing to look that up, you can use the following which will read the name of the primary data source, using the getPrimaryModelName function.

// get primary data source using getPrimaryModelName
// this will reload the current page 
request.$context.executeRequest({
	type: "crt.LoadDataRequest",
	$context: request.$context,
	config: {
		loadType: "reload",
		useLastLoadParameters: true
	},
	dataSourceName: (await request.$context.getPrimaryModelName()) 
});
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.

4 Comments

  1. Hi, Ryan.
    Thank you for the article.
    I try to refresh data for the currently opened object and call your code with dataSourceName = PDS, but it reloads all datasources without a filter. I got information from the random row.

    Reply
    • Hello,

      My article was missing the following from the request:
      useLastLoadParameters: true

      Update your code to include that and it should work. I have also updated the article to include that in the request.

      Ryan

    • Great, it works.
      But can you explain to me what is the difference between call through request.$context.executeRequest:

      await request.$context.executeRequest(loadDataRequest);

      and your variant with handlerChain.process.

      Both variants are working :-).

    • Using “request.$context.executeRequest” is the same as executing the request via the handlerChain. Originally the “executeRequest” didn’t exist, so the only way to execute a request was using the handlerChain. The executeRequest function was later added to the base page as shorthand to make executing requests easier and without the need to reference the SDK. That are both the same.

      Ryan

Submit a Comment

Your email address will not be published. Required fields are marked *