Skip to content

Instantly share code, notes, and snippets.

@elchele
elchele / custom-forecast-pipeline.js
Last active August 29, 2015 14:23
Correction to amounts for currency differences
({
/*
file: ./custom/modules/Forecasts/clients/base/views/forecast-pipeline/forecast-pipeline.js
*/
extendsFrom:"ForecastsForecastPipelineView",
initDashlet: function(view) {
this._super('initDashlet', [view]);
@elchele
elchele / filter.js
Created July 7, 2015 17:35
Filter controller extension to change behavior to utilize OR operand
({
/* File: ./custom/modules/<Module>/clients/base/layouts/filter/filter.js */
extendsFrom: 'FilterLayout',
applyFilter: function(query, dynamicFilterDef) {
var customFilterDef = [{'$or':[{'billing_address_city':{'$starts':query}},{'name':{'$starts':query}}]}];
// TODO: getRelevantContextList needs to be refactored to handle filterpanels in drawer layouts,
// as it will return the global context instead of filtering a list view within the drawer context.
// As a result, this flag is needed to prevent filtering on the global context.
@elchele
elchele / record.js
Last active August 29, 2015 14:27
Custom Record view controller for removing fields not accessible via ACL.
({
/* File: ./custom/clients/base/views/record/record.js */
extendsFrom: 'RecordView',
_render: function(){
var self = this;
this._super('_render');
_.each(this.noEditFields, function(field){
@elchele
elchele / record.js
Last active October 1, 2015 20:40
Custom record controller for dynamically loading view metadata based on current record data.
({
/*
File: ./custom/modules/<Module>/clients/base/views/record/record.js
Requires metadata for other view: ./custom/modules/<Module>/clients/base/views/<view>/<view>.php
*/
extendsFrom: 'RecordView',
/**
@elchele
elchele / record.js
Created January 22, 2016 16:57
Custom record view controller for displaying an alert upon a record being accessed, if it meets a given criteria.
({
/* File: ./custom/modules/Leads/clients/base/views/record/record.js */
extendsFrom: 'RecordView',
initialize: function(options) {
this._super('initialize', [options]);
this.model.on('data:sync:complete', this.showAlert, this);
},
@elchele
elchele / record.js
Created January 29, 2016 19:28
Custom RecordView controller for checking number of records in a subpanel at time parent record is viewed.
({
/* File: ./custom/modules/<Module>/clients/base/views/record/record.js */
extendsFrom: 'RecordView',
initialize: function(options){
/* Check if related module has records linked to current record
* You need the "link" field name from vardefs for the specific
* subpanel you wish to check.
*
@elchele
elchele / CustomSplitAttachFolder.php
Last active January 30, 2016 01:56
(6.6/6.7 Only) Custom UploadStream class extension. Modifies default upload behavior so as to store files using date of upload within directory structure, such as: ./upload/2015/04/02/myfile.txt
<?php
/* Author: Angel Magaña -- cheleguanaco@cheleguanaco.com
* File: ./custom/include/CustomSplitAttachFolder.php
*
* UploadStream extension to add use of date named
* subfolders to ./upload directory.
*
* e.g. ./upload/2015/04/02/<MyApril2nd2015File.docRepresentedAsGUID>
*
@elchele
elchele / LogicHookController.php
Last active March 11, 2016 01:28
Fix to Marketo logic hook correcting issue with dates and users with non-US date format
<?php
/* File: ./custom/include/externalAPI/Marketo/LogicHookController.php */
/*
* Copyright (c) 2014-2015 SugarCRM Inc. This product is licensed by SugarCRM
* pursuant to the terms of the End User License Agreement available at
* http://support.sugarcrm.com/06_Customer_Center/10_Master_Subscription_Agreements/10_Marketo/
*/
@elchele
elchele / UserRoles.js
Last active June 20, 2016 15:57
Sidecar: Retrieving User Roles
/* Author: Angel Magaña - cheleguanaco@cheleguanaco.com
*
* This Gist can be used within a Sugar 7 Controller to retrieve a user's
* security Roles
*
*/
/* To retrieve the Roles, we create a User object then
* retrieve the User's related Role records via the default Users <--> Roles relationship
*/
@elchele
elchele / es_test.php
Last active July 5, 2016 17:56
PHP script for simple querying of Elasticsearch using Sugar default server settings
<?php
/* Author: Angel Magaña - cheleguanaco@cheleguanaco.com
* File: <sugar_root>/es_test.php
*
* Executes simple Elasticsearch query using
* Elasticsearch params from Sugar config files
* Usage: http://<sugar_url>/es_test.php?term=<your_search_term>
*
*/