Monday, September 27, 2010

Adding a New Call to the SugarCRM through Code

Ass a new Call to the SugarCRM through Code.



                    $call = new Call();

                    $call->direction = 'Outbound';

                    $call->status = 'Planned';

                    $call->contact_id = $contactid;

                    $call->duration_hours = '0';

                    $call->duration_minutes = '15';

                    $call->date_start = $date; // (mm/dd/yyyy hh:mmTT) format

                    $call->name = $subjectstring;

                    $call->assigned_user_id = $current_user->id;

                    $call->team_id = '1';

                    $call->team_set_id = '1';

                    $call->save();

                // Create the relationship to Contact to appear in the Contact Subpanel

                    $contact = new Contact();

                    $contact->retrieve($call->contact_id);

                    $contact->load_relationship('calls');

                    $contact->calls->add($call->id);



Enjoy.