Display error for API4 batch action #32219
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Overview
There doesn't seem to be a way to get/display the error when an API4/angular batch action is executed.
Ideally we'd be able to pass the error through to
ctrl.error();
so that it is available here:https://lab.civicrm.org/extensions/civirulesextras/-/blob/main/ang/triggerCivirule/crmSearchTaskTriggerCivirule.ctrl.js?ref_type=heads#L33
But that doesn't seem to be possible. The error is available in the browser if you look at the response.
Before
Error ignored and not shown to user.
After
Error shown to user.
Technical Details
Note that my code is based on an updated version of https://lab.civicrm.org/extensions/upgraderecur/-/blob/main/ang/updaterecur/crmSearchTaskChangeSubscription.ctrl.js
If you want to test this: Install civirules + civirulesextras. Go to "Manage CiviRules" and make sure you have at least one rule defined. Select it and click the actions menu. Select "Trigger CiviRule(s)".
Comments
@colemanw Any ideas if this is the right approach or if we could instead/and pass through the error?
@artfulrobot for ref as you started this!