Skip to content

Instantly share code, notes, and snippets.

<?php
public function exportSanitize($value, $vardef, $focus, $row=array()) {
return $this->formatField($value, $vardef);
}
<?php
$configurator = new Configurator();
if (!isset($configurator->config['test_key1'])) {
$configurator->config['test_key1'] = 'test_value1';
}
$configurator->handleOverride();
<?php
//set up options array
$options = array(
"location" => 'https://site14/sugar6/soap.php',
"uri" => 'http://www.sugarcrm.com/sugarcrm',
"trace" => 1
);
//user authentication array
$user_auth = array(
@jmertic
jmertic / gist:6584335
Created September 16, 2013 18:11
Exporting a report as a PDF using the new RESTful API in Sugar 6.7 and later.
<?php
// specify the REST web service to interact with
$url = 'https://localhost/~jmertic/sugar7/ent/sugarcrm/rest/v10';
// And admin username/password
$username = 'will';
$password = 'will';
// And the report_id you wish to export
@jmertic
jmertic / gist:6584226
Created September 16, 2013 18:02
Exporting a report as a PDF via Web Services
<?php
// specify the REST web service to interact with
$url = '<<your sugar instance URL>>/service/v4_1/rest.php';
// And admin username/password
$username = '<<username>>';
$password = '<<password>>';
// And the report_id you wish to export
@jmertic
jmertic / gist:6555133
Created September 13, 2013 19:40
Examples of usage of sugarcrm7-api-wrapper-class at https://github.com/spinegar/sugarcrm7-api-wrapper-class
/* Instantiate and authenticate */
$sugar = new \Spinegar\Sugar7Wrapper\Rest();
$sugar->setUrl('https://sugar/rest/v10/')
->setUsername('restUser')
->setPassword('password')
->connect();
/* Retrieve all records in the Cases module */
$sugar->search('Cases');
@jmertic
jmertic / gist:6508009
Created September 10, 2013 11:18
Get related records via REST v10
<?php
// specify the REST web service to interact with
$url = 'http://sugarinstance/rest/v10';
// And admin username/password
$admin_username = '<<admin username>>';
$admin_password = '<<admin password>>';
// And account id you want to get the related docs for
@jmertic
jmertic / gist:6385293
Last active December 21, 2015 23:49
Example of how to get a user's timezone information, if you are an admin user
<?php
// specify the REST web service to interact with
$url = 'http://sugarinstance/rest/v10';
// And admin username/password
$admin_username = '<<admin username>>';
$admin_password = '<<admin password>>';
// And username you whom you want to find out thier timezone
<?php
/**
* This function helps generate the name and full_name member field
* variables from the salutation, title, first_name and last_name fields.
* It takes into account the locale format settings as well as ACL settings
* if supported.
*/
public function _create_proper_name_field()
{
global $locale, $app_list_strings;
@jmertic
jmertic / gist:6294266
Created August 21, 2013 13:10
Silent install a package on an instance from the command line in SugarCRM with this script
#!/usr/bin/env php
<?php
function usage()
{
print("usage: -i /path/to/instance -p /path/to/expanded/module -z /path/to/zipfile\n");
exit(1);
}
$opts = getopt('i:p:z:');