Yes, copy the attributes to a related record in the @delete workflow actions.
Select action Update Related Record where you have some temp fields to store values.
description=workflow\targetEntity\attributeFetched ('id'); <-- will save the ID of the deleted record to description field of the related entity.
Access record after @delete event
Collapse
X
-
I just thought having such capacity would allow the (admins) to design a workflow that can recover info from deleted records or even have ability to restore them if they are deleted for certain reason. Adding more statuses sometimes work but sometimes it doesn't depends on what we are trying to achieve. -
If we make record\findOne to return deleted records by default, it would be a breaking change. It will never happen. Adding new functions, maybe. But I wouldn't hurry with it. The system was not designed to work with deleted records at all.Last edited by yuri; 07-04-2023, 01:53 PM. -
Both BPM and Workflow were not designed to work with deleted target records. Moreover, the concept was that it's supposed that regular users don't have access to delete action. Better to use some status for that.Leave a comment:
-
that is weird it used to work and i have used it in different workflows/bpmn script formula. not sure but i think this could be important hence it would allow the user to access data. what about a formula like record\findDeleted() alongside with record\restoreDeleted() these will come handy which will allow the user to access deleted records when needed. -
It never worked.
> most formula function has been rewritten and use a different approach.
I don't think this is correct. I don't see any changes besides code style and some refactoring.Leave a comment:
-
Hey Maarten
You are right, this seems to be working fine in older version. i have checked it again and it is not working anymore. double checked and code for most formula function has been rewritten and use a different approach. Maybe a request to double check with the team if they want to consider this again. This could be achieve just by calling a method on the query builder like below:
PHP Code:$builder->withDeleted();
Leave a comment:
-
Rabii, I see in the forum you make a lot of reference to this formula that should work to retrieve a deleted record:
$travel = record\findOne('Travel', 'createdAt', 'DESC', 'id=', '64a24fea1f9d88514', 'deleted', true);
However, it doesn't work for me. When I restore the record I can find it with:
$travel = record\findOne('Travel', 'createdAt', 'DESC', 'id=', '64a24fea1f9d88514', 'deleted', false);
When I delete the record, I cannot find it with:
$travel = record\findOne('Travel', 'createdAt', 'DESC', 'id=', '64a24fea1f9d88514', 'deleted', true);
Can someone double check that with espo v 7.5.5 this is actually working for them?Leave a comment:
-
"[2023-07-03 19:52:08] ERROR: Workflow[6489e19bddfe58373]: Action failed [executeFormula] with cid [2], details: Formula: Entity required but not passed..
"
This is what I get when I do entity\attribute('id') in a formula script in a workflow that triggers on @delete event.
So it seems that the deleted entity is not passed to formula scripting environment in the workflow.
However it does seem to be accessible in a prescripted action, such as update related records -
Ok, I found a workaround for now. Since in my particular case, when I delete a Travel record, I want all related Traveler records to be deleted. So now, instead of the above BPM loop, I delete all related traveler records when the Travel is deleted. Then I catch the @delete of the Traveler, and perform the API calls to delete the traveler from the sharepoint list.
Leave a comment:
-
I use a BPM because my full flow is much more complex:
I don't think I can loop over an array of IDs in a workflow?
I'm still unclear why I get this error in BPM. Even if I don't use any attributes of the record (as shown above), it fails.
It seems that the workflow can access a deleted record by ID, but if that same record is used to call a BPM flow, then it fails.
I don't think this should happen?
Leave a comment:
Leave a comment: