How can we delete a record and update other existing records after clicking Yes from the confirmation message
Hi,
I have a business case to update a field in a detail in other records and then delete the selected record from a detail after clicking "Yes" from the confirmation box.
As of now field is updated to all records on click of delete button in a detail.
{
request: "crt.DeleteRecordRequest",
handler: async (request, next) => {
await next?.handle(request);
console.log("Deleting a record in detail");
//to validate if I clicked Yes or No from the confirmation box
}
Any suggestions is really helpful.
Like
Hi,
Please use a business process in this case to read all remaining records from the detail and update their values that will be triggered upon record deletion from the object of this detail. It's much easier than trying to create a UI logic using DeleteRecordReqeust.
Oleg Drobina,
Hello Oleg,
I have almost implemented functionality in the client schema under deleteRecordRequest handler. Right now the functionality is working irrespective of the confirmation option choosen, It works even when we click No from the confirmation box.
I wanted to make the functionality to work only if I click "Yes" from the confirmation box.
Is it possible to read the option chosen by user while deleting a record(either Yes or No) in the handler?
Thanks
GargeyiGnanasekhar,
What I've observed from the behavior is that the DeleteRecordRequest is called twice: once you click delete button and once you select one of the yes\no options. Then I was trying to find a difference in either requests contexts or in the requests, but there is none or it's not obvious. And finally if we take a look at the initiator of the GetCanDelete method (that is called once you hit the "Yes" option) it's also not obvious who calls it:
I really tried to find a place in the code that could be overriden, but it seems that it's impossible to do in the current version (tested in 8.0.6). That's why I've asked to use a business process instead.
If you want to initiate the delete from your own code, you can use the Model class for that. See https://customerfx.com/article/deleting-a-record-from-client-side-code-…
If you're handling the crt.DeleteRecordsRequest you could simply not call the "next" handler in the chain. Basically, only call this if the answer is yes: await next?.handle(request);
Ryan