Skip to content

Instantly share code, notes, and snippets.

@elchele
elchele / detail.hbs
Created June 4, 2021 21:28
Remove "Download All" button from Notes attachments field.
{{!--
File: ./custom/modules/Notes/clients/base/fields/multi-attachments/detail.hbs
--}}
<div class="select2-container select2-container-multi select2-choices-pills-close
select2 span12 multi-attachments-detail-view">
<ul class="select2-choices">
{{#each value}}
<li class="select2-search-choice">
<?php
/* File: ./custom/clients/base/api/MyCustomApi.php */
class MyCustomApi extends SugarApi {
public function registerApiRest() {
return array(
'myCustomMethod' => array(
'reqType' => 'GET',
@elchele
elchele / email.ext.php
Created June 26, 2019 21:10
Example on leveraging PMSE Email Template Engine and Sugar Mailer to send parsed email messages
<?php
/* File: ./custom/Extension/modules/Accounts/Ext/LogicHooks/email.ext.php */
$hook_array['after_save'][] = array(
102,
'Send email test',
'custom/modules/Accounts/pmseSend.php',
'emailTest',
'emailTest'
@elchele
elchele / file.js
Created June 18, 2019 23:06
Debugging file upload issues
({
/* File: ./custom/clients/base/fields/file/file.js */
extendsFrom: 'FileField',
_doValidateFileError: function(fields, errors, callback, resp) {
app.alert.dismiss('upload');
app.logger.fatal(resp);
@elchele
elchele / detail.hbs
Last active August 17, 2018 19:03
Custom Sidecar field component for displaying related data
{{!--
/* File: ./custom/clients/base/fields/related-info/detail.hbs
* Author: Angel Magaña -- cheleguanaco@cheleguanaco.com
* Date: August 17, 2018
*
* Description: Handlebars template for related info field component
*/
--}}
{{#each fields}}
@elchele
elchele / customController.js
Created May 23, 2018 00:57
Invoking code on a successful response
myCustomJSMethod: function(module, guid){
//Instantiate a SugarBean object representing record identified by GUID
var beanObject = app.data.createBean(module, {id:guid});
//Send request to REST v10 API to retrieve the record
beanObject.fetch({
//Define the anonymous function that will execute on a successful response
success: function(data){ //the data parameter represents the JSON response from the API
//Do something with the response upon successful request
@elchele
elchele / CustomFilterAPI.php
Created February 2, 2018 19:37
Custom FilterAPI that hard codes an additional condition to the default "My Accounts" filter
<?php
/* File: ./custom/modules/Accounts/clients/base/api/CustomFilterApi.php */
require_once 'clients/base/api/FilterApi.php';
class CustomFilterApi extends FilterApi
{
public function registerApiRest()
{
@elchele
elchele / hide_panel.ext.php
Created January 31, 2018 10:41
Custom dependency that hides/shows a given panel on RecordView if Sales Stage is set to Closed Lost on an Opportunity
<?php
/* File: ./custom/Extension/modules/Opportunities/Ext/Dependencies/hide_panel.ext.php */
$dependencies['Opportunities']['hide_panel'] = array(
'hooks' => array("edit"),
'trigger' => 'equal($sales_stage, "Closed Lost")',
'triggerFields' => array('sales_stage'),
'onload' => true,
'actions' => array(
@elchele
elchele / set_required.ext.php
Created January 31, 2018 09:30
Custom dependency to set a field as required based on another field's value
<?php
/* This example sets the Status Description field to required
if the Status field is set to 'Dead' within Leads module.
File: ./custom/Extension/modules/Leads/Ext/Dependencies/set_required.ext.php */
$dependencies['Leads']['req_status_desc_dep'] = array(
'hooks' => array("edit"),
'trigger' => 'true',
@elchele
elchele / GetYTDValueExpression.php
Last active February 2, 2018 02:01
Custom Sugar Logic function for retrieving YTD value
<?php
/* File: ./custom/include/Expressions/Expression/String/GetYTDValueExpression.php */
require_once('include/Expressions/Expression/String/StringExpression.php');
class GetYTDValueExpression extends StringExpression
{
function evaluate() {