Hello,

I need to create a custom handler for a button. It is necessary that after the button is clicked, two actions are performed sequentially: first, the record should be saved, and then a process should be triggered. My code isn't working. Could you please help?

 

        handlers: /**SCHEMA_HANDLERS*/[
 {        
     request: "crt.CustomHandler",
     handler: async (request, next) => {
   const result = await next?.handle(request);
   const handlerChain = sdk.HandlerChainService.instance;
   // Спочатку зберігаємо дані
   await handlerChain.process({
       type: 'crt.SaveRecordRequest',
       $context: request.$context,
       dataSourceName: "PDS"
   });
   // Потім викликаємо процес
   await handlerChain.process({
       type: 'crt.RunBusinessProcessRequest',
       $context: request.$context,
       processName: "srProcess_5c65949",
       processRunType: "ForTheSelectedPage",
       showNotification: true,
       recordIdProcessParameterName: "ID"
   });
   return result;
}
}
]/**SCHEMA_HANDLERS*/,
Like 0

Like

2 comments
Best reply

Ігор Роїк,

Hello,

Have you tried importing a "creatio-devkit/common dependecies" as well as passing sdk as a parameter to your schema function? 1

 message: Uncaught Error: Uncaught (in promise): ReferenceError: sdk is not defined
ReferenceError: sdk is not defined

Ігор Роїк,

Hello,

Have you tried importing a "creatio-devkit/common dependecies" as well as passing sdk as a parameter to your schema function? 1

Show all comments