This topic contains 1 reply, has 1 voice, and was last updated by shreyas 7 years, 6 months ago.
- Topic
Hi Team,
I have a requirement wherein I need to create an dynamically configurable email template in a process.yml file which consists of email trigger when a new lead is created. i.e required since if an admin needs to change the email template used to send email to leads when they are created then he needs to go to the code to change the template string to a new one.
So, to avoid this i have created an entity called CustomConfig entity with cols as config value & config label where label i would like to keep it constant & the value can be changed.
So ex: a label is kept as : Lead_Creation_Template , it can be given any email template value. So that it has dynamic configuring of when a lead is created which template to be selected.i tried using this entity to fetch the Config – value for a given config label (i.e, Lead_Creation_Template) in the processes but i am getting exceptions while doing so.
i am able to trigger mail when a lead is created when the template set in @send_email_template is set to a email template string format. but when i try to use customconfig’s value variable to get the same email template name , it throws an exception.
Please find the screenshot for CustomConfig Entity Colums containing Config Label & Config Value given below:
Custom Config Entity file given below(Loc: Proj_Dir\src\Custom\Bundle\CustomConfigBundle\Entity\CustomConfig.php):
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127<?phpnamespace Custom\Bundle\CustomConfigBundle\Entity;use Doctrine\ORM\Mapping as ORM;/*** CustomConfig** @ORM\Table(name="custom_config")* @ORM\Entity*/class CustomConfig{/*** @var integer** @ORM\Column(name="id", type="integer")* @ORM\Id* @ORM\GeneratedValue(strategy="AUTO")*/private $id;/*** @var string** @ORM\Column(name="configlabel", type="string", length=255)*/private $configlabel;/*** @var string** @ORM\Column(name="configvalue", type="string", length=255)*/private $configvalue;/*** @var boolean** @ORM\Column(name="isActive", type="boolean")*/private $isActive;/*** Get id** @return integer*/public function getId(){return $this->id;}/*** Set configlabel** @param string $configlabel** @return CustomConfig*/public function setConfiglabel($configlabel){$this->configlabel = $configlabel;return $this;}/*** Get configlabel** @return string*/public function getConfiglabel(){return $this->configlabel;}/*** Set configvalue** @param string $configvalue** @return CustomConfig*/public function setConfigvalue($configvalue){$this->configvalue = $configvalue;return $this;}/*** Get configvalue** @return string*/public function getConfigvalue(){return $this->configvalue;}/*** Set isActive** @param boolean $isActive** @return CustomConfig*/public function setIsActive($isActive){$this->isActive = $isActive;return $this;}/*** Get isActive** @return boolean*/public function getIsActive(){return $this->isActive;}}Please find the process.yml used to trigger email:
12345678910111213141516171819202122232425262728293031definitions:send_mail_lead:label: 'New Lead'enabled: trueentity: OroCRM\Bundle\SalesBundle\Entity\Leadorder: 20actions_configuration:- '@tree':- '@find_entity':class: Custom\Bundle\CustomConfigBundle\Entity\CustomConfigattribute: $customconfigwhere:configlabel: 'Lead_Creation_Template'- @send_email_template:attribute: $.emailfrom: 'madhur.halapeti@izmoltd.com'to: $email#template: 'Avez-vous reçu nos mails?'template: $customconfig.configvalueowner: $ownerentity: $.data- @add_email_activity_target:email: $.emailtarget_entity: $.datatriggers:send_mail_lead:-event: createpriority: 0queued: truetime_shift: 3Once now when i create a lead , i get a job failed message in http://Proj_Dir/app_dev.php/cron/job as shown below:
In the above Process.yml , if i use template: ‘Avez-vous reçu nos mails?’ instead of template: $customconfig.configvalue . It works perfectly fine.I dont know on how exactly to map the Customconfig entity’s Configvalue to the template variable of @send_email_template.
Please need some help in how to solve this problem.
Thanks & Regards,
Shreyas S
The forum ‘OroCRM’ is closed to new topics and replies.