Hi, community!
Recently noticed that while executing crt.CreateRecordRequest programmatically I cannot pass default values for page attibutes that are not schema fields. I am aware about defaultValues parameters for CreateRecordRequest and it works correctly for page fields so they are filled in, but no such behaviour for attributes. Maybe it possible to access defaultValues array in the opened page in HandleViewModelInitRequest and set a attribute value manually, but I didn't find the way to do it. Any advices on this are much appreciated.
const handlerChain = sdk.HandlerChainService.instance; await handlerChain.process({ type: "crt.CreateRecordRequest", entityName: "MySuperEntity", $context: request.$context, defaultValues: [{ attributeName: "SomeField", //this is MySuperEntity field and it's filled in the form page correctly value: "SomeValue" }, { attributeName: "SomeAttribute", //this is MySuperEntity_FormPage attribute and and it's empty in request.$context.SomeAttribute in HandleViewModelInitRequest value: "SomeAnotherValue" }, });
Like
Hi, Sergejs. You should do it as following:
{ request: "crt.HandleViewModelResumeRequest", handler: async (request, next) => { await next?.handle(request); setTimeout(() => { request.$context.Param1 = someValue1; request.$context.Param2 = someValue2; }, 300); } }
Dmitry S,
Can you please clarify what is someValue1 and someValue2 in your example? As far as I can understand, you are setting attribute value inside same page in the HandleViewModelResumeRequest.
My scenario is slightly different, I am trying to pass the attribute value from another page. So for instance - I have a button on a page1, this button has a custom click handler, where I call CreateRecordRequest with some parameters. In result page2 opens and I want to set it attribute with the value from the parameter i passed in CreateRecordRequest. I hoped it works automatically, but it's not. I tryed your HandleViewModelResumeRequest code with little modification, but attribute value still is null for me.
{ request: "crt.HandleViewModelResumeRequest", handler: async (request, next) => { await next?.handle(request); setTimeout(() => { const a = request.$context.SomeAttribute; //a is null here }, 300); } },