AnsweredAssumed Answered

Not able to relate contacts and notes custom code

Question asked by jlabuelo on Feb 1, 2019
Latest reply on Feb 8, 2019 by Harald Kuske

Hello

 

I am trying to create a note and related it to a given contact, but I am getting this error message

 

 

Notice: Undefined property: Note::$contacts in /custom_Notes.php on line 55

Fatal error: Call to a member function add() on null in \custom_Notes.php on line 55

And I think I am relating the beans correctly

 

 

  $notas = BeanFactory::getBean('Notes');
      $notas->name = $name;
      $notas->description = $desc;
      $notas->id = create_guid();
      $notas->new_with_id = true;
      $notas->filename = $name.'.pdf';
      $notas->tipo_documento_c = $tipoDoc;

      $notas->load_relationship('contacts');
      $notas->contacts->add($beanContact);
      global $current_user;
      $notas->assigned_user_id=$current_user->id;
      $notas->save();

Is there any other way to relate the note created to the $beanContact??

I am using SugarCRM CE 6.5

 

Thanks a lot

Outcomes