Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
[Bots] Loop/Records before sending only sends original message #842
We've got a bot that adds the previous messages in to the response sent via email. This has been working fine until 9.1 where now instead of saving the message and sending the history to the recipient, it ignores what message you enter, re-saves the first message in the ticket and sends that to the recipient.
Bot code below.
It looks like this happens when the behavior uses a temporary variable with the same name as a placeholder. For instance, you're using
If you rename the variable to something like
This has to do with how we merge our placeholders into the template builder (Twig) scope for conditions/actions. I'm still testing a few alternative approaches. But tweaking your behavior (above) will resolve the issue in the meantime.
Yeah. Most behaviors just get a copy of the values. Normally, temporary variables within a template wouldn't conflict with placeholders. They'd be thrown away after the template compiles to text.
This is a special case where the 'Before sending worker message' events retain a reference/pointer from the original properties (To/Cc/Subject/Headers/Content) all the way through the behaviors. That allows the behavior to change the properties of the original message without adding a bunch of new actions. So changes to those placeholders do flow back up to the objects behind the placeholders.
I can see where this is happening, and I'm going to go about it a better way.