Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Extending the base Record view in Sugar 7.1.5 (http://developer.sugarcrm.com/2014/02/10/extending-sugar-7-record-view/)
<?php
/*
* By installing or using this file, you are confirming on behalf of the entity
* subscribed to the SugarCRM Inc. product ("Company") that Company is bound by
* the SugarCRM Inc. Master Subscription Agreement ("MSA"), which is viewable at:
* http://www.sugarcrm.com/master-subscription-agreement
*
* If Company is not bound by the MSA, then by installing or using this file
* you are agreeing unconditionally that Company will be bound by the MSA and
* certifying that you have authority to bind Company accordingly.
*
* Copyright 2004-2013 SugarCRM Inc. All rights reserved.
*/
$viewdefs['base']['layout']['record'] = array(
'components' => array(
array(
'layout' => array(
'components' => array(
array(
'layout' => array(
'components' => array(
array(
// Changed from 'record' to 'my-record'
'view' => 'my-record',
'primary' => true,
),
array(
'layout' => 'extra-info',
),
array(
'layout' => array(
'name' => 'filterpanel',
'span' => 12,
'last_state' => array(
'id' => 'record-filterpanel',
'defaults' => array(
'toggle-view' => 'subpanels',
),
),
'availableToggles' => array(
array(
'name' => 'subpanels',
'icon' => 'icon-table',
'label' => 'LBL_DATA_VIEW',
),
array(
'name' => 'list',
'icon' => 'icon-table',
'label' => 'LBL_LISTVIEW',
),
array(
'name' => 'activitystream',
'icon' => 'icon-th-list',
'label' => 'LBL_ACTIVITY_STREAM',
),
),
'components' => array(
array(
'layout' => 'filter',
'targetEl' => '.filter',
'position' => 'prepend'
),
array(
'view' => 'filter-rows',
"targetEl" => '.filter-options'
),
array(
'view' => 'filter-actions',
"targetEl" => '.filter-options'
),
array(
'layout' => 'activitystream',
'context' =>
array(
'module' => 'Activities',
),
),
array(
'layout' => 'subpanels',
),
),
),
),
),
'type' => 'simple',
'name' => 'main-pane',
'span' => 8,
),
),
array(
'layout' => array(
'components' => array(
array(
'layout' => 'sidebar',
),
),
'type' => 'simple',
'name' => 'side-pane',
'span' => 4,
),
),
array(
'layout' => array(
'components' => array(
array(
'layout' => array(
'type' => 'dashboard',
'last_state' => array(
'id' => 'last-visit',
)
),
'context' => array(
'forceNew' => true,
'module' => 'Home',
),
),
),
'type' => 'simple',
'name' => 'dashboard-pane',
'span' => 4,
),
),
array(
'layout' => array(
'components' => array(
array(
'layout' => 'preview',
),
),
'type' => 'simple',
'name' => 'preview-pane',
'span' => 8,
),
),
),
'type' => 'default',
'name' => 'sidebar',
'span' => 12,
),
),
),
'type' => 'simple',
'name' => 'base',
'span' => 12,
);
{{!
* By installing or using this file, you are confirming on behalf of the entity
* subscribed to the SugarCRM Inc. product ("Company") that Company is bound by
* the SugarCRM Inc. Master Subscription Agreement ("MSA"), which is viewable at:
* http://www.sugarcrm.com/master-subscription-agreement
*
* If Company is not bound by the MSA, then by installing or using this file
* you are agreeing unconditionally that Company will be bound by the MSA and
* certifying that you have authority to bind Company accordingly.
*
* Copyright 2004-2014 SugarCRM Inc. All rights reserved.
}}
<div>
<h3>MyRecordView adds a <span style="color: red;">red</span> border around each field.</h3>
</div>
/*
* By installing or using this file, you are confirming on behalf of the entity
* subscribed to the SugarCRM Inc. product ("Company") that Company is bound by
* the SugarCRM Inc. Master Subscription Agreement (“MSA”), which is viewable at:
* http://www.sugarcrm.com/master-subscription-agreement
*
* If Company is not bound by the MSA, then by installing or using this file
* you are agreeing unconditionally that Company will be bound by the MSA and
* certifying that you have authority to bind Company accordingly.
*
* Copyright 2004-2014 SugarCRM Inc. All rights reserved.
*/
({
extendsFrom: 'RecordView',
initialize: function (options) {
this._super('initialize', [options]);
//extend the record view definition, so we include actions and the module specific fields.
this.meta = _.extend({}, app.metadata.getView(this.module, 'record'), this.meta);
},
_renderHtml: function(ctx, options){
this._super('_renderHtml', [ctx, options]);
this.$el.find('.record .record-cell').css('border','1px solid red');
var myAddition = app.template.get("my-record.mine");
this.$el.prepend(myAddition());
}
})
<?php
/*
* By installing or using this file, you are confirming on behalf of the entity
* subscribed to the SugarCRM Inc. product ("Company") that Company is bound by
* the SugarCRM Inc. Master Subscription Agreement (“MSA”), which is viewable at:
* http://www.sugarcrm.com/master-subscription-agreement
*
* If Company is not bound by the MSA, then by installing or using this file
* you are agreeing unconditionally that Company will be bound by the MSA and
* certifying that you have authority to bind Company accordingly.
*
* Copyright 2004-2014 SugarCRM Inc. All rights reserved.
*/
$viewdefs['base']['view']['my-record'] = array(
//Use template from RecordView
'template' => 'record'
);
@shajiuddin

This comment has been minimized.

Copy link

shajiuddin commented Feb 2, 2016

Hi Matt,

I need to change background color of dropdown value

For example I have dropdown "Countries" having more than 100 countries. I need to change background color of 2 countries "United States" and "Canada" only.
I tried to do from this article (Extending the base Record view in Sugar 7 · GitHub) but not working
Any help will be highly appreciable

SugarCRM Professional 7.6.1.0

Regards

@mmarum-sugarcrm

This comment has been minimized.

Copy link
Owner Author

mmarum-sugarcrm commented Feb 2, 2016

The technique from this Gist and the original blog post is not really appropriate for what you are trying to do.

You probably want to create a custom field handler for this Country dropdown. Our out of the box dropdown is the 'enum' field, you'll want to extend that probably.

https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_7.6/UI_Model/Fields/Introduction/
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_7.6/UI_Model/Fields/Examples/Creating_Custom_Fields/

Under the covers, our dropdown fields use the Select2 library. So in particular, you'd probably want to learn about Select2 Templating.

Hopefully this gets you going in the right direction.

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.