AnsweredAssumed Answered

Add notes to custom module

Question asked by john Fieldsend on Jul 29, 2019
Latest reply on Aug 2, 2019 by Francesca Shiekh

Hi all, we had a developer add a custom module Feature Keys (holo_FeatureKeys)  to our Sugar Ent 9.0. I now need to add notes support to this module.

 

Using studio I created a relationship one-to-many in the feature key module to notes (see attached) however when I try and create a note and attach it to the feature-keys module  it does not show in the related to field. I understand the related to field in notes is a flex relate field so I don't understand why I cant see my Feature Key module. I trie a quick repair and rebuild but this did not fix it.

 

I tried adding a note via the api 

 

    public function createNote($api, $args) {
      $db = $GLOBALS['db']->getConnection();
      $result = [
        'totalSize'   => 0,
        'done'        => true,
        'success'     => false,
      ];

      $note = BeanFactory::getBean('Notes');
      $note->description        = 'Custom Holokote Image: '.$args['file_ext'];
      $note->id                 = create_guid();
      $note->new_with_id        = true;
      $note->filename           = $args['file'];
      $note->parent_type        = $args['parentType'];
      $note->modified_user_id   = $args['contact'];
      $note->created_by         = $args['contact'];
      $note->parent_id          = $args['parentID'];
      $note->file_mime_type     = $args['file_mime_type'];
      $note->file_ext           = $args['file_ext'];
      $note->file_size          = $args['file_size'];
      $note->save();

      if (isset($note->id) && !empty($note->id)) {
        $result['success'] = true;
        $file = $GLOBALS['sugar_config']['upload_dir'] . '/' . $note->id;
        sugar_file_put_contents($file, base64_decode($args['file_content']));
      }
      return $result;
    }

where $args['parent_type'] = holo_FeatureKey and the parent_id is set to the id of the newly created feature-key.

 

Am i missing a step or is there some custom code that is stopping this module showing in the notes related to field. All our other custom modules show.

 

I have also tried to add this to the dropdown list record_type_display_notes

Outcomes