Forums

Dynamic subject with multiple values

itspetrus 28 Dec, 2011
Hello,

I'm trying to create a dynamic subject with multiple values (in V4). I found some answers at this forum but I can't get it to work. I added a "custom code" event before the "email" event and I added "subject_1" in the "dynamic subject" field. Based on example code on your forum I added in the "custom code":

<?php
$form->data['subject_1'] = 'Melding'.{$form->data['Ringjaar']}  
?>


I tried several different syntaxes because I'm not sure about the quotes but it's sending email with the subject "DEFAULT SUBJECT" so it's obviously not working. I also wonder if the word "Melding" needs to be the name of the form, or that it's just a text.

I would like to get a subject with multiple values, separated by a "at-sign" or a "forward slash". Perhaps strange, but that is how a third party system needs to receive my data.

Can you point me to the right direction in how to create multiple values in a dynamic subject field separated by specific values?

Thanks in advance,
Peter.
GreyHead 28 Dec, 2011
Hi Peter,

A couple of things to check.

First the subject_1 should be in the Dynamic Subject box with no quotes or brackets and the Static Subject box should be empty.

Second, please try this in the Custom Code action:
<?php
$form->data['subject_1'] = 'Melding '.$form->data['Ringjaar']; 
?>

The PHP curly brackets syntax can only be used *inside* double quotes - so this would also work:
<?php
$form->data['subject_1'] = "Melding {$form->data['Ringjaar']}"; 
?>
NB The similar ChronoForms curly quotes syntax {Ringjaar} won't work here.

Bob
itspetrus 28 Dec, 2011
Hello Bob,

Thanks for your quick reply. Now I start to understand how it's working. The subject_1 was okay and the static subject was empty. So far so good. I changed the code like you suggested and it was working immediate! I see now that the dot is concatenating and inside quotes I can add the separator I wanted.

My working code is now:

<?php
$form->data['subject_1'] = 'Melding '.$form->data['Ringjaar'].'/'.$form->data['Ringnummer']; 
?>


Thanks a lot for helping me out!
Regards,
Peter.
This topic is locked and no more replies can be posted.