Add notes to custom module

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

Parents Reply Children
  • Hi there

    This is a customization to be accomplished by hand, without Studio stuffs.

    1. Add an entry in the dropdowns record_type_display_notes and parent_type_display
    2. In the parent module create an extended vardefs and set the link field notes, just like it is defined in Accounts module, mind you have to update the value of 'relationship' attribute. Also set the relationship between parent module and Notes, just like defined in the Accounts module, mind you also have to replace string 'Accounts' by the appropriate one
    3. In the parent module create an extended language and seet the label for LBL_NOTES
    4. In th Notes module create an extended vardefs and set the id field <parent_module>_id, just liked the one defined for Accounts. Also set the link field <parent_module>, which has a relationship the one you just created in the parent module
    5. In the Notes module create an extended language and set the label for LBL_<PARENT_MODULE>_ID
    6. In the parent module create an exended client/base/layout an in there set the subpanel notes, just like the one in Accounts. Make sure you properly setup the link name and label

    Go to Admin -> Repair and run:

    • Quick Repair and Rebuild
    • Rebuild Relationships

    Clear browser cache and enjoy it!!

    Regards

    André Lopes
    Lampada Global
    Skype: andre.lampada
  • thank André Lopes will give this a try over the weekend on our testing sugar cloud, Also thank you Francesca Shiekh, you method using a custom code worked fine for my local deploy of sugar  and will use it on our cloud if I get no joy with Andres solution.

    thank you all for helping with this