This photograph is taken at Great Barrier Reef, Australia, 2005. 


vTiger Account synchronisation

Today, i tried to synchronize an external system with vtiger using custom fields. It took some time to see through the structure of the vtiger-codebase. But here is the result

ini_set(’/path/to/vtiger/installation/’);
require_once(’config.php’);
require_once(’include/logging.php’);
require_once(’include/database/PearDatabase.php’);
require_once(’modules/Users/Users.php’);
require_once(’modules/Accounts/Accounts.php’);
$username = “YourVtigerUserName”;
$log = &LoggerManager::getLogger(’importer’);
$seed_user = new Users();
$user_id = $seed_user->retrieve_user_id($username);
$current_user = $seed_user;
$current_user->retrieve_entity_info($user_id,”Users”);
// lookup accountId in vTiger
$acid = getAccountID($youridentified);
if($acid) {
echo “– Found: $acid\n”;
$account = new Accounts();
$account->retrieve_entity_info($acid,”Accounts”);
$account->mode = “edit”;
$account->id = $acid;
} else {
echo “– Not Found creating new\n”;
$account = new Accounts();
}
$account->column_fields[accountname] = $newname;
$account->column_fields[phone] = $newphone;
$account->column_fields[fax] = $newfax;
$account->save(”Accounts”);

Make sure to set the mode when you save an existing record, otherwise a new record will be created.

Comments are closed.

 

Klaasjan Tukker

Klaasjan Tukker


Business Development Manager
Adobe Systems Benelux




Chairman
NLJUG
    follow me on Twitter


    Founded in 1998, the Dutch Java User Group consists of business partners, software developers, application architects, technical managers, students, and new media developers that have a common interest in all aspects of Java Technology.

    Klaasjan Tukker is Chairman of the NL-JUG, Dutch Java User Group
    All content including photographs Copyright ©2005 Klaasjan Tukker
    The picture in the header is a photograph taken at Great Barrier Reef, Australia, 2005.