I have a custom module - loans. in the loans modules i have a relate field to the contact module (as a result of 1-many relationship with loans module), which i use to keep track of the broker who introduced the loan or the primary contact of the loan.
Now within loans i have a subpanel called Applicant. In Applicants i am trying to create a NEW contact record from the applicants details entered, when the user ticks a box to convert to applicant details into a contact record. However i DO NOT want the new contact record to be linked to the loan.
Contact has a 1 to many relationship with Loans
Loans has a many to many relationship with Applicant
Applicant doesn't link to contacts only to the loan
I have the follow code in a before_save logic hook in the Applicant module
PHP Code://get id...if not set then it is a new record so create an id here
if(empty($bean->id)) {
$bean->id = create_guid();
$bean->new_with_id = true;
}
//check if the primary contact is empty and if some basic lead contacts fields are completed.
if ( ($bean->convert_to_contact_c == 1) && (strlen($bean->last_name) > 0)){
/// Create Contact from the Lead Fields on the Short Term Loan
$contactbean = new Contact();
$contactbean->status_c = "Active";
$contactbean->first_name = $bean->first_name;
$contactbean->last_name = $bean->last_name;
$contactbean->assigned_user_name = $bean->created_by_name;
$contactbean->assigned_user_id = $bean->created_by;
$contactbean->save();
}
Once this logic hook runs and saves the applicant record, creates the new contact record as i want BUT IT is placing the newly created contact in the Contact relate field on the loan module, i do not want this as it is overwriting my existing value i have there say the broker.
Can any one assist with this?


LinkBack URL
About LinkBacks



Reply With Quote
Bookmarks