Full Version: Import contacts with picture
You're currently viewing a stripped down version of our content. View the full version with proper formatting.

In the CRM contact have picture field.
I would like to import a lot of contacts with the pictures.
Each contact have unique picture name in my disk directory.

I found this document "How to update an image field from code"
Look quit complicated :-(

It there simpler way?
The code you reference can't be easier. Notice that in that example it is generating a QR code before saving and that is where all the work is. In your case you want to get the image from the file system and that is where your work is. it would be something like:

PHP Code:
include_once 'vtlib/Vtiger/Module.php';
$current_user Users::getActiveAdminUser();
// make a query to get all the contacts you want to update
// for each contact
// get the image from the hard disk into a variable
$data file_get_contents(name of file);
// setup array for update
'name'=>'whatever name you want to use' // no slash nor paths in the name
'type'=>' image/png'// change accordingly

$contactData  = array(
'attachments' => array(
'imagename' => $model_filename,
'id'=> '29x4062'// put your contact webservice ID here
// end loop 

let us know how it goes
I manage to add contact + pic using the "coreBOS Web Service Developer Tool"
Now I want to run it from linux cli.
Its not clear to me from the doc what library should I include.

Some example use:

PHP Code:


PHP Code:
include_once 'vtlib/Vtiger/Module.php';
there are two ways to use web service. from outside corebos and from inside corebos

outside means that it is a standalone application, you have to login to the webservice endpoint and use all the methods you need. this is a mobile app, a customer portal and similar applications that connect to corebos and use it as a database.

inside corebos means that you are programming inside the framework, you don't need to login because your script lives inside the corebos application, once you are inside you can use the web service methods normally without having to login (because you already are)