Results 1 to 1 of 1

Thread: create contact record but no automatic relationship

  1. #1
    Join Date
    Feb 2009
    Posts
    13

    Default create contact record but no automatic relationship

    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?
    Last edited by marktaylor5151; 2010-11-01 at 12:59 AM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Sugar Bean - Create/Update record and relationship
    By aureh12 in forum Developer Help
    Replies: 3
    Last Post: 2010-01-08, 09:58 PM
  2. Replies: 10
    Last Post: 2009-02-04, 05:16 PM
  3. Add a relationship record ID
    By Phniux in forum Developer Help
    Replies: 2
    Last Post: 2008-06-24, 07:43 AM
  4. Replies: 2
    Last Post: 2007-01-29, 04:11 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •