Hello Community,
I wanted to perform two actions on click of a button
1. Saves the fields in the tab page
2. Navigate to next tab
Right now we are using the crt.SaveRecordRequest. This only saves the page.
Any suggestions is really helpful
Thanks
Gargeyi.G
Like
Hello,
This article will show you how to navigate to a new page on a Freedom UI page:
https://customerfx.com/article/navigating-to-a-page-via-code-in-a-creat…
If you want to open an edit page for a record, or an add page, this article outlines how to do that:
https://customerfx.com/article/opening-an-edit-page-to-add-or-edit-a-re…
Ryan
Also, as far as having the button trigger both - there are two routes you can take.
Route 1 - If you'd always go to this other page after saving, you could just do that when the save request is triggered. This article shows how to listen for when the page is saved, then you could navigate to the other page from there: https://customerfx.com/article/adding-code-to-the-save-event-of-a-creat…
Route 2 - If you're only wanting to save, then go to this other page, when your own button is clicked, and not for all saves, then you can wire up your own handler for your button. This article shows how to to that: https://customerfx.com/article/adding-a-button-to-execute-custom-code-o… In the handler, you'd save the page, then navigate to the other page. If you go this route (creating a custom request for your button). It would look like this:
{ request: "cfx.clickMeButtonClicked", handler: async (request, next) => { // make sure you've added the "@creatio-devkit/common" as mentioned in the articles const handlerChain = sdk.HandlerChainService.instance; // first save the record await handlerChain.process({ type: "crt.SaveRecordRequest", $context: request.$context }); // now navigate to the other page, this navigates to the orders section await handlerChain.process({ type: "crt.OpenPageRequest", schemaName: "OrderSectionV2", $context: request.$context }); return await next?.handle(request); } }
Ryan
Ryan Farley,
Please note that it's best to pass context to each handlerChain.process call. So, in your example, the second call should be:
// now navigate to the other page, this navigates to the orders section await handlerChain.process({ type: "crt.OpenPageRequest", schemaName: "OrderSectionV2", $context: request.$context });
Oleksandr Khardikov,
Thanks for that. I've updated the code in my reply for completeness and also the articles on my website.
Ryan