Hello everyone!
Does anyone know how to call the validation function that is called when saving a record in client side for Freedom UI. In my case i need to check if the all the mandatory fields are filled in and all validators pass , if this succeeds i want to display an area on screen. I also need to do this on page initialization. I could call the save method on init but i do not want to resave the record if the validation succeeds.
Thanks !
Like
1 comments
11:35 Oct 30, 2024
Hello,
Please check the code below and update me if this approach works for you (the logic is that we call a separate request that performs validation when the SaveRecordRequest is executed):
{ "request": "usr.SomeCustomValidationLogic", "handler": async (request, next) => { // sync / async validation return false; //or true based on conditions } }, { "request": "crt.SaveRecordRequest", "handler": async (request, next) => { console.log(request); const requestContext = request.$context; const isValid = await requestContext.executeRequest({type:"usr.SomeCustomValidationLogic", requestContext}); if (isValid) { await next?.handle(request); } else { const dialogConfig = { data:{ title: "Page validation", message: "Object is not valid!", } } await requestContext.executeRequest({type:"crt.ShowDialogRequest", requestContext, dialogConfig}); } } },
This works both sync and async.
Show all comments