Emailing element calc'd by php plugin - odd issue

darkroast

Member
I have a form which has two plugins. The first one generates a number and updates a field element. It does this by taking the rowid, adding a constant to it, then updates the database field with that number. (I know that's the hard way, but using a calc field wasn't working right for some reason). Here's the PHP code for that:

PHP:
$object = new stdClass();
$object->id = {rowid};
$object->caseNumber = 1400000 + {rowid};
$result = JFactory::getDbo()->updateObject('hs_cases', $object, 'id');

It's set to fire onBeforeCalculations, and it works perfectly - when the record is saved, the number is generated and saved.

However... the second plugin for that form is an email plugin. It's supposed to send an email which includes that caseNumber field. Problem is, it works some of the time, but not always. Could this be because of the timing of firing those plugins? As I say, the PHP plugin fires onBeforeCalculations; is it possible that the email plugin fires BEFORE that?

In the plugins tab on the form, I have the PHP plugin first, then the email plugin, then two redirect plugins (one for new, one for edit). Does the order make a difference?

Thanks for the help!
 
Are you sure your code is working? You should always quote placeholders to avoid php errors if the placeholder is empty
I'm not sure if rowid is set in case of a new record.


gesendet mit Tapatalk
 
Yes, it's recording that fueld correctly in the database every time. The problem is that I also use an email plugin, which is supposed to include that element in both the subject line and the body of the email. What I expect to happen is the email to pull that element and replace the placeholder in the subject line and email with the contents of that element. It does - much of the time. The weird thing is it does NOT do it all the time.
 
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top