AnsweredAssumed Answered

Add Document to Historical Summary view

Question asked by Autchara Chaiprom on Jan 23, 2018
Latest reply on Jan 23, 2018 by Autchara Chaiprom

Hi,

I tried to add Document module to show in Historical Summary but name of document is missing.

 

How my code working:

I create HistoryCustomApi instead of HistoryApi.

 

clone all clients/base/views/history-summary to custom

 

in custom/clients/base/views/history-summary/history-summary.js

I changed path to use my custom module:

// in function initialize
var url = app.api.serverUrl + '/'
                    + this.baseModule + '/'
                    + this.baseRecord + '/'
                    + 'link/historyCustom';

if(this.baseModule == 'Accounts'){
  this.activityModules = ['Tasks','Calls','Emails','Notes','Meetings','Documents','Opportunities','Cases','Feedback'];
} else if (this.baseModule == 'Cases') {
  this.activityModules = ['Tasks','Calls','Emails','Notes'];
} else if (this.baseModule == 'Opportunities') {
  this.activityModules = ['Tasks','Calls','Emails','Notes','Meetings'];
} else if (this.baseModule == 'Leads') {
  this.activityModules = ['Tasks','Calls','Emails','Notes','Meetings'];
}

 

and in HistoryCustomApi.php

in function filterModuleList  if field is status could be get from status_id, this field is working properly

but for field name it doesn't work while call api with other module because sugar store name in field document_name

but if I call api only Documents module it working(see example return data below).

 

////////////// Custom ///////////////
if($module == 'Documents' && $field == 'status'){
   $field = 'status_id';
}else if($module == 'Documents' && $field == 'name'){
   $field = 'document_name';
}
/////////////////////////////////////
$q->select()->field($field);
                    }
                }
            }

            $q->select()->field('id');
            $q->select()->field('assigned_user_id');
            $q->limit = $q->offset = null;
            $q->select()->fieldRaw("'{$module}'", 'module');
            $query->union($q);
            $query->limit($options['limit'] + 1);
            $query->offset($options['offset']);
            $args['fields'] = $savedFields;
        }

 

Example:

call api only Documents module ------> name is shown correctly

{{url}}/rest/v10/Accounts/96bd2480-f5ff-11e7-91ec-c4b301c94055/link/historyCustom?view=list&fields=&max_num=25&order_by=date_modified%3Adesc&module_list=Documents

return

{
    "next_offset": -1,
    "records": [
        {
            "id": "d3dcae38-df0e-11e7-a1b2-c4b301c94055",
            "name": "aTestData.vcf",
            "date_entered": "2017-12-12T08:33:54+01:00",
            "date_modified": "2017-12-12T08:33:54+01:00",
            "description": "",
            "status": "Active",
            "assigned_user_id": "ca2f29e0-96b8-11e7-9c1f-005056a7993d",
            "assigned_user_name": "Test User",
            "assigned_user_link": {
                "full_name": "Test User",
                "id": "ca2f29e0-96b8-11e7-9c1f-005056a7993d",
                "_acl": {
                    "fields": [],
                    "_hash": "654d337e0e912edaa00dbb0fb3dc3c17"
                }
            },
            "_acl": {
                "fields": {}
            },
            "_module": "Documents",
            "moduleNameSingular": "Document",
            "moduleName": "Documents",
            "date_format": "12.12.2017 08:33"
        }
    ]
}

 

call rest 2 modules -------> name is missing

{{url}}/rest/v10/Accounts/96bd2480-f5ff-11e7-91ec-c4b301c94055/link/historyCustom?view=list&fields=&max_num=25&order_by=date_modified%3Adesc&module_list=Documents,Notes

return

{
    "next_offset": -1,
    "records": [
        {
            "id": "d3dcae38-df0e-11e7-a1b2-c4b301c94055",
            "name": "",
            "date_entered": "2017-12-12T08:33:54+01:00",
            "date_modified": "2017-12-12T08:33:54+01:00",
            "description": "",
            "status": "Active",
            "assigned_user_id": "ca2f29e0-96b8-11e7-9c1f-005056a7993d",
            "assigned_user_name": "Test User",
            "assigned_user_link": {
                "full_name": "Test User",
                "id": "ca2f29e0-96b8-11e7-9c1f-005056a7993d",
                "_acl": {
                    "fields": [],
                    "_hash": "654d337e0e912edaa00dbb0fb3dc3c17"
                }
            },
            "_acl": {
                "fields": {}
            },
            "_module": "Documents",
            "moduleNameSingular": "Document",
            "moduleName": "Documents",
            "date_format": "12.12.2017 08:33"
        }
    ]
}

 

 

Any idea ?

SugarPro 7.9.1.0

Thanks,

M

Outcomes