I have a custom action for sending an email via Elastic Email. The action works fine for testing purposes, but when I want to send a notification email to a user email, which is linked through several database relations, the email never gets sent.
My suspicion is, that the value of the email field is not loaded yet when the action is triggered and the Elastic Email API gets called with an empty recipient and rejects the call.
The magic text for the recipient is: Current Meldungen > Fahrzeuge > Werkstatt > User > Email.
Interestingly, when I put the same magic text into a label and wait for it to be loaded, the email gets sent just fine. However, the problem is, that I can’t do this in the use case where I need it because the email should be triggered on the submit button of a create form where the value is not available until the button is pressed.
Could my suspicion be correct and if yes, how can the API call be deferred until the recipient is properly loaded? How else could this issue be resolved? @anon78309838
This is quite interesting. What you describe makes me think that custom actions executions are somewhat asynchronous and don’t require confirmation from the DB… but I have no detailed info on that.
As an option: may be you could try do it in 3-steps? You will need an additional property in Logged-in User collection to store the email, call it TempEmail. Something like:
create a new record with this email via long relationships
update Logged-in User → TempEmail
send email using custom action, but use TempEmail as a recipient’s address.
May be with this you could “simulate” the conditions you see when you use a label.
We do have a card for this internally to be addressed but the current workaround is as already mentioned by having something else load this data in before the custom action is fired so that it is available for that custom action.
Thanks for your responses @Victor and @anon78309838 unfortunately I still haven’t gotten it to work yet.
It seems that none of my actions gets triggered except vor the create action, not even the update of the User to set a Temp field to the desired value. The create comment action doesn’t work, the notification doesn’t work, the custom action doesn’t work. but the Link works.
I think if the first action fails the others don’t take place also.
It’s a bit of a different point to what you discussed, but an issue I see many times with email actions failing is multi-line text, inputted as magic text, being part of the json body. In this case the test usually works but not in the live app when the setup sends a multi-line email body. Probably not your issue but maybe worth checking.
In this case the first action definitely works, since the data is created. The second action should only update the TempEmail value in the Current User object, which doesn’t work. They also don’t work in the test app.
The last action “Link Back” does work however, since the create screen is closed after the button is pressed.
I even completely deleted the form and created a new one, since I already noticed a strange behavior sometimes when copying screens or components that the actions don’t work anymore (which is another bug but apparently not this one) but nothing changed!
With the new form I only tried the workaround suggested by @Victor and left out all other actions, except for the link back.
So now I have:
Create the item itself (works)
update the temp field in the user object (doesn’t work)
okay, so it seems that even a relatively simple link doesn’t work.
I tried a more shallower value (New Meldungen > Fahrzeuge > Kennzeichen … which is the licence plate in case anybody is wondering) but it also doesn’t show up in the user temp field.
Could it be, that not even the referenced vehicle (Fahrzeug) is loaded after the new entry is created?