How to call Comment log Api Sugarcrm 9.1 EP

How to call Comment log Api Sugarcrm As Respective of case Module 9.1 EP.

  • Sorry, no idea what that means.  You are going to have to be a little more descriptive with your question.

  • I assume you are trying to add a comment in the comment log on a Case using the API.

    If you look at the CommentLogApi in modules/CommentLog/clients/base/api/CommentLogApi.php

    you will see that the Create is disabled.

     

    My suggestion would be to create your own POST API.

     

    Require the comment entry, the name of the module that it relates to, in your example "Cases", and the id of the Cases record that you want the comment to be on.

     

    Then you can create the comment bean, and relate it to the Case.

        //assuming you retrieved the $entry, the $module and the $id of the record to put it on from the API call parameters
        $bean = BeanFactory::retrieveBean($module, $id);
        if(!empty($bean)) {
          //I think all the comment log links added using studio are named 'comment_log" but you will need to check, the easiest way is by looking for commentlog in the cache/modules/<module_name>/<module vardefs>.
          $link = 'commentlog_link';
          if($bean->load_relationship($link)){
            //create the comment record
            $comment = BeanFactory::newBean('CommentLog');
            $comment->entry = $bean->latest_update_c;
            $comment->save();
            //link it to the bean
            $bean->$link->add($comment->id);
            $bean->latest_update_c = '';
            $bean->save();
          }
        }

    Francesca