Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Customization for pulling external/ad-hoc data into a Sugar subpanel
<?php
/* File: ./custom/Extension/modules/Accounts/Ext/Language/en_us.fake.lang.ext.php */
$mod_strings['LBL_FAKE'] = 'Fake Subpanel';
$mod_strings['LBL_FAKE_NAME'] = 'Fake Name';
$mod_strings['LBL_FIELD_1'] = 'Fake Field 1';
$mod_strings['LBL_FIELD_2'] = 'Fake Field 2';
?>
({
/* File: ./custom/clients/base/fields/fake-name/fake-name.js */
extendsFrom: 'NameField',
buildHref: function() {
//Create the URL that browser will navigate to upon clicking item in fake subpanel
var destinationURL = 'http://www.example.com/';
return destinationURL;
}
})
<?php
/* File: .custom/Extension/modules/Accounts/Ext/clients/base/layouts/subpanels/fake_panel.ext.php */
$viewdefs['Accounts']['base']['layout']['subpanels']['components'][] = array (
'layout' => 'subpanel',
'label' => 'LBL_FAKE',
'override_subpanel_list_view' => 'subpanel-for-fake',
'context' => array (
'link' => 'fake',
),
);
?>
<?php
/* File: ./custom/clients/base/api/FakeLinkApi.php */
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
class FakeLinkApi extends SugarApi {
public function registerApiRest() {
return array(
'filterRelatedRecords' => array(
'reqType' => 'GET',
'path' => array('<module>', '?', 'link', 'fake'),
'pathVars' => array('module', 'record', '', ''),
'method' => 'filterRelated',
'shortHelp' => 'Lists related filtered records.',
'longHelp' => 'include/api/help/module_record_link_link_name_filter_get_help.html',
),
);
}
public function filterRelated(ServiceBase $api, array $args)
{
//We could pull our external data here
$data = array(
'next_offset' => '-1',
'records' => array(
//Array N/V pairing would need to match general Sugar structure and view fields
array(
'id' => 'ABCDEF0123456789',
'name' => 'Static',
'field1' => 'value1',
'field2' => 'value2'
)
)
);
return $data;
}
}
({
/* File: ./custom/modules/Accounts/clients/base/views/subpanel-for-fake/subpanel-for-fake.js */
extendsFrom: 'SubpanelListView',
initialize: function(options){
this._super('initialize', [options]);
}
})
<?php
/* File: ./custom/modules/Accounts/clients/base/views/subpanel-for-fake/subpanel-for-fake.php */
$viewdefs['Accounts']['base']['view']['subpanel-for-fake'] = array(
'panels' =>
array(
array(
'name' => 'panel_header',
'label' => 'LBL_PANEL_1',
'fields' =>
array(
array(
'default' => true,
'label' => 'LBL_FAKE_NAME',
'enabled' => true,
'name' => 'name',
'link' => true,
'type' => 'fake-name', //custom widget used to create a custom route
),
array(
'default' => true,
'label' => 'LBL_FIELD_1',
'enabled' => true,
'name' => 'field1',
),
array(
'type' => 'varchar',
'default' => true,
'label' => 'LBL_FIELD_2',
'enabled' => true,
'name' => 'field2',
),
),
),
),
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.