Hi everybody, I have the following task:
on some form a "Product" field exists. After it's value had changed, I need to fill two subordinate objects (details) on the same page. Logic:
{ request: "crt.HandleViewModelAttributeChangeRequest", handler: async (request, next) => { if (request.attributeName === "Product" && !request.silent) { const product = await request.$context.Product; console.log(typeof product); if (typeof product === "object" && !Ext.isEmpty(product)) { await FormFunctions.processProductChange(request); const saveResult = await this.handlerChain.handlerChain$.process({ type: "crt.SaveRecordRequest", preventCardClose: true, $context: request.$context }); debugger; if (saveResult) { await FormFunctions.fillOrderItemTopics(request); await FormFunctions.fillOrderItemStructure(request); } } } }
unfortunate result:
if the same task is being solved as some handler on some button, no problem occurs. Any suggestions please?
Like
Hello,
Hard to tell based on the code alone what is exactly wrong, my guess is in the way you call a crt.SaveRecordRequest. Try to replicate the code form this article https://customerfx.com/article/saving-a-page-before-some-action-on-a-cr…
Dmytro Vovchenko,
Hi Dmytro. It was not a code issue at all - when a new page was created in the latest creatio version, and content were transferred there, the problem had gone :) My guess is that the issue was caused smth in the page system hierarchy. But thank you for the answer anyway.