Skip to content

Instantly share code, notes, and snippets.

View orlybg's full-sized avatar

Orlando Briceño Gómez orlybg

View GitHub Profile
@orlybg
orlybg / gist:79bd8e051d02e4d61cffe60fbd761bb0
Created May 10, 2016 12:48 — forked from jmertic/gist:5847575
Sample Node.js script using Restler for connecting to the new RESTful SugarCRM REST API in 6.7 and later.
var sys = require('util'),
rest = require('restler');
var baseurl = "<<instance URL>>/rest/v10"
// get oAuth token
var jsonData = {"grant_type":"password","username":"<<username>>","password":"<<password>>","client_id":"sugar"};
rest.postJson(baseurl+'/oauth2/token', jsonData).on('2XX', function(data) {
if ( data.error ) {
sys.puts("Error: " + data.error_message);
@orlybg
orlybg / update_via_csv.php
Created January 28, 2016 13:20 — forked from bickart/update_via_csv.php
Place this file and your CSV file into the root of your SugarCRM install and you can update data in SugarCRM from a CSV on the command line
<?php
//Use an unlimited amount of memory, we probably shouldn't do this but that is how I roll
ini_set('memory_limit', '-1');
//Our program allows us to skip over rows in the data file and only load a sub-set of rows
if (count($argv) < 3 || ! is_numeric($argv[1]) || ! is_numeric($argv[2])) {
echo "Usage php -f $argv[0] skip max" . PHP_EOL;
echo " skip - number of rows to skip when processing" . PHP_EOL;
echo " max - number of rows to import when processing" . PHP_EOL;