AnsweredAssumed Answered

How do I set Lead email address on view.edit.php?

Question asked by Francesca Shiekh on Nov 21, 2014
Latest reply on Feb 6, 2017 by Dianna Whitt
In 6.5.18 I have a custom button on cases that calls the Leads Edit View with the case_id passed as a parameter.
The idea is that when Customer Service receives a Case that is a product enquiry they will create a Lead for a sales person to follow up on. So I want the Leads Edit View to open with as much data populated as possible.

In custom/modules/Leads/views/view.edit.php

I have a pre-display that populates fields on the Lead based on what was on the Case.
It also copies some information from the primary contact on the case, if there is one, and sets the lead as converted linking it to that Contact.

This all  works well except for the email address which does not get populated.

   function preDisplay() {
      parent::preDisplay();
      if(empty($this->bean->id)){
         // if coming from custom button on Cases
         if(isset($_REQUEST['case_id'])&&!empty($_REQUEST['case_id'])){
            $case_id = $_REQUEST['case_id'];
            $c = new aCase();
            $c->retrieve($case_id);
            if (!empty($c->contact_id_c)){
               $con = new Contact();
               $con->retrieve($c->contact_id_c);
               $this->bean->first_name = $con->first_name;
               $this->bean->last_name = $con->last_name;
               $this->bean->contact_id = $con->id;
               $this->bean->converted = '1';
               $this->bean->email1 = $con->email1;
            }
            $this->bean->license_number_c = $c->case_license_number_c;
            $this->bean->description = $c->description;
         }
         // end handling Cases 

I have verified that $con->email1 is indeed the email address I want to display on the Lead Edit View.
Any thoughts on how I can get the email address populated?

thanks,
FrancescaS

Outcomes