Custom handler to call a button on progress bar status change

Hello Everyone,

I have a progress bar that changes its status based on approval status. However, it requires a manual page refresh to reflect the changes in the progress bar. To address this, I've added a refresh button. Now, I want this button to trigger automatically whenever the progress bar status changes. Can anyone provide guidance on how I can achieve this using a custom handler?

Currently, I've written this code with the assumption that the record is saved whenever the status changes.

    {

    request: "crt.SaveRecordRequest",

    handler: async (request, next) => {

        const schemaName = "UsrNewProductsOnboardingformpage";  

        const buttonId = "Button_qef55yg";

        const button = request.$record.$Model[schemaName].$Buttons[buttonId];

        if (button) {

            button.instance.execute();

            console.log("Button clicked");

        } else {

            console.log("Button not found");

        }

        return next?.handle(request);

    }

}

Like 1

Like

4 comments

Have you tried turning on "Enable Live Data Update" for the object? Turning that on should make it refresh automatically when the data changes with no code. 

See https://customerfx.com/article/automatically-refreshing-a-creatio-freed…

Alternatively, you could add code to refresh the page: https://customerfx.com/article/refreshing-reloading-page-or-list-data-o…

Ryan

Ryan Farley,

Hi Ryan,

I tried enabling "Live Data Updates" for the object, but it still didn't work out. Will try the alternate approach to see if it's work.



Thanks 

 

Abhishek,

 

Hello,

 

Try this handler in the page (don't forget to add creatio-devkit/common to  your page schema (example define("UsrTest_FormPage", /**SCHEMA_DEPS*/["@creatio-devkit/common"]/**SCHEMA_DEPS*/, function/**SCHEMA_ARGS*/(sdk)/**SCHEMA_ARGS*/ {):

{
				request: "crt.ApprovalActionHandlerRequest",
				handler: async (request, next) => {
					const result = await next?.handle(request);
					const handlerChain = sdk.HandlerChainService.instance;
					await handlerChain.process({
						$context: request.$context,
						type: 'crt.LoadDataRequest',
							config: {
								"loadType": "reload",
								"useLastLoadParameters": true
							},
							"dataSourceName": "PDS"
					});
				}
			}

Worked correctly in my demo.

Oleg Drobina,

Hello,

I tried, but it didn't work, nor did it even trigger after the changes. Do I need to change the request from "crt.ApprovalActionHandlerRequest" to any other request?

Show all comments