Skip to content

Instantly share code, notes, and snippets.

@AjayKumar01
AjayKumar01 / panel-top.js
Created April 9, 2016 07:24
Disabling create and link existing button action in subpanel based on parent module and parent module field value
({
/* Disabling create and link existing button action in subpanel based on parent module.
* Ajay Kumar
* Path : sugar/custom/modules/Leads/clients/base/views/panel-top/panel-top.js
*/
extendsFrom: 'PanelTopView',
initialize: function(options) {
this._super('initialize', [options]);
var parentModule = this.context.parent.get('model').module;
var parentCollection = this.context.parent.get('collection');
@AjayKumar01
AjayKumar01 / hidetabs.php
Created April 9, 2016 07:28
Hiding tabs using dependency in Record view
<?php
/* Hiding tabs using dependency in Record view
* Ajay Kumar
* Path : custom/Extension/modules/Opportunities/Ext/Dependencies/hidetabs.php
*/
$dependencies['Opportunities']['hide_tabs'] = array(
'hooks' => array(
"edit",
"view"
),
@AjayKumar01
AjayKumar01 / header.php
Created April 9, 2016 07:34
Removing import menu option from Accounts module menu.
<?php
/* Removing import menu option from Accounts module menu.
* Ajay Kumar
* Path : /custom/modules/Accounts/clients/base/menus/header/header.php.
*/
$moduleName = 'Accounts';
$viewdefs[$moduleName]['base']['menu']['header'] = array(
array(
'label' =>'LNK_NEW_ACCOUNT',
'acl_action'=>'create',
@AjayKumar01
AjayKumar01 / record.js
Created April 9, 2016 07:41
Making field required dynamically based on condition
({
/* Making field required dynamically based on condition
* Ajay Kumar
* Path : custom/modules/Opportunities/clients/base/views/record/record.js
*/
extendsFrom: 'RecordView',
initialize: function(options) {
this._super('initialize', [options]);
this.on('render', this.testFunc, this);
this.model.on('change:probability', this.testFunc, this);
@AjayKumar01
AjayKumar01 / selection-headerpane.js
Last active October 3, 2016 20:33
Removing 'Create' Button from relationship select field based on parent module and current module
initialize: function(options) {
/* Removing 'Create' Button from relationship select field based on parent module and current module
* Ajay Kumar
* Path : custom/modules/Accounts/clients/base/views/selection-headerpane/selection-headerpane.js
*/
var moduleMeta = app.metadata.getModule(options.module),
isBwcEnabled = (moduleMeta && moduleMeta.isBwcEnabled),
buttonsToRemove = [],
additionalEvents = {};
if (isBwcEnabled) {
@AjayKumar01
AjayKumar01 / create-actions.js
Created April 9, 2016 08:39
Hiding fields in create view of module
({
/* Hiding fields in create view of opportunities module
* Ajay Kumar
* Path : custom/modules/Opportunities/clients/base/views/create-actions/create-actions.js
*/
extendsFrom: 'CreateActionsView',
initialize: function(options) {
this._super('initialize', [options]);
this.on('render', this.hideField, this);
},
@AjayKumar01
AjayKumar01 / alert
Last active October 3, 2016 20:32
Making Alert Close after 10 seconds
app.alert.show('success', {
level : 'success',
messages : 'Successful',
autoClose : true,
autoCloseDelay : 10000,
});
@AjayKumar01
AjayKumar01 / enableAudit.php
Created April 9, 2016 08:52
Enabling 'View Change Log' Button in record view of module or Enabling Audit for module
<php
/*
* Enabling Audit for module
* Ajay Kumar
* Path : /crm//custom/Extension/modules/Project/Ext/Vardefs/enableAudit.php
*/
$dictionary['Project']['audited'] = true;
?>
@AjayKumar01
AjayKumar01 / record.js
Last active October 3, 2016 20:32
Email Validation through api(Note : this will work in both record.js and create-actions.js as well)
var emailAddress="[email protected]";
var self = this,
data = {
results: [],
},
options = {},
callbacks = {},
url;
// add the search term to the URL params
options.q = emailAddress;
@AjayKumar01
AjayKumar01 / recordlist.js
Last active October 3, 2016 20:32
Adding button in list view
({
extendsFrom:'RecordlistView',
initialize:function(options){
this._super('initialize',[options]);
this.context.on('list:updatecurrentsize:fire',this.mass_update_currentsize,this);
},
/**
* Function to mass update the current size
* for all selected accounts
* Written by: Ajay Kumar