Skip to content

Instantly share code, notes, and snippets.

@elchele
elchele / record.js
Created February 21, 2015 03:03
Custom controller for automatically uppercasing last_name value when field loses focus
({
/* Author: Angel Magaña -- cheleguanaco@cheleguanaco.com
* File: ./custom/modules/<Module>/clients/base/views/record/record.js
*
* Custom RecordView controller for automatically converting
* last_name value to upper when focus is lost
*/
extendsFrom:'RecordView',
@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 / subpanels.js
Last active May 16, 2017 21:22
Custom controller for subpanels layout, hides specific subpanels based on parent record data
({
/* Author: Angel Magaña -- cheleguanaco@cheleguanaco.com
* File: ./custom/modules/<Module>/clients/base/layouts/subpanels/subpanels.js
*
* Extended subpanels layout controller for hiding
* subpanels upon record load and based on parent record data
*
*/
extendsFrom: 'SubpanelsLayout',
@elchele
elchele / StockApi.php
Created March 26, 2015 21:01
Custom endpoint for Sugar REST API, uses CURL to interact with external web service.
<?php
/* Author: Angel Magaña -- cheleguanaco@cheleguanaco.com
* File: ./custom/modules/Accounts/clients/base/api/StockApi.php
*
* Custom Sugar REST API endpoint demonstrating use of CURL to
* interact with an external web service.
*
* Useful for circumventing XSS issues one may experience when calling
* a web service via JavaScript (e.g. Sidecar controller)
@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 / module-list.js
Created May 15, 2015 18:55
Customization for adding "alias" NavBar links to Sugar 7
({
/* File: ./custom/clients/base/layouts/module-list/module-list.js */
extendsFrom: 'ModuleListLayout',
_addDefaultMenus: function() {
var moduleList = app.metadata.getModuleNames({filter: 'display_tab', access: 'read'});
moduleList.push('Custom1');
@elchele
elchele / record.js
Created May 20, 2015 03:58
Custom record view controller for setting entire record to read-only conditionally
({
/* Author: Angel Magaña -- cheleguanaco@cheleguanaco.com
* File: ./custom/modules/Opportunities/clients/base/views/record/record.js
*
* Set all fields to read-only conditionally
*/
extendsFrom: 'RecordView',
_renderHtml: function(){
@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 / conversion-stats.js
Last active January 4, 2019 12:34
Custom pie chart for Sugar 7.x, displaying monthly lead conversion statistics.
({
/* Author: Angel Magaña -- cheleguanaco@cheleguanaco.com
* File: ./custom/clients/base/views/conversion-stats/conversion-stats.js
*
* controller for 'Monthly Lead Conversion Stats' custom pie chart
*/
plugins: ['Dashlet', 'Chart'],
className: 'conversion-stats',