SugarCRM 6 Installation Error

I noticed that SugarCRM have just released their new version 6.0.0, and since my sugarcrm installation is madly out of date and I’m about to start using it again, I thought I’d just throw the old one away and install from scratch. I had no problems until I reached the final installation stage, when clicking the “install” button would return a 404. This is tedious because then you have to follow the instructions and change config.php so that “installer_locked” is false (but the installer does remember all the information you give it, which makes this less annoying)

After a couple of times around the loop I looked properly at the warnings on that final page before the “install” button, and made some php.ini changes in line with what it requested – increasing the memory_limit and the upload_file_size. I also installed php5-curl (I’m an ubuntu user so this is just an aptitude package for me) and the install ran like a dream at that point. I’m disappointed that SugarCRM couldn’t give me better feedback than just a 404, but it seems like it needed some settings that I didn’t have – so if you see the same behaviour, don’t give up but heed the warnings and it should be able to install itself absolutely fine. Hope this helps!

SugarCRM SOAP API Examples

By popular request, here are some examples that worked for me when using the SOAP API offered by SugarCRM. Its nice that there is an interface, but it isn’t brilliantly documented or nearly as widely used as it should be!

SugarCRM can’t talk to PHP 5 native SOAP libraries in WSDL mode, so connect without it. Find below a series of queries that each worked for me, all just dumped here in succession, don’t try to run this whole piece of code – it is intended as a series of examples. Use each line and then var_dump($response) to see what’s happening.

// set up options array
$options = array(
        "location" => 'http://192.168.1.129/aeat/spm/crm/soap.php',
        "uri" => 'http://www.sugarcrm.com/sugarcrm',
        "trace" => 1
        );
// connect to soap server
$client = new SoapClient(NULL, $options);

// look what modules sugar exposes
$response = $client->get_available_modules($session_id);

// look in more detail at the fields in the Accounts module
$response = $client->get_module_fields($session_id, 'Accounts');

// look for a particular account name and then get its ID
$response = $client->get_entry_list($session_id, 'Accounts', 'name like "%LornaJane%"');
$account_id = $response->entry_list[0]->id;

// create a new account record and grab its ID
$response = $client->set_entry($session_id, 'Accounts', array(
            array("name" => 'name', "value" => 'New Company')
            ));
$account_id = $response->id;

// create a new contact record, assigned to this account, and grab the contact ID
$response = $client->set_entry($session_id, 'Contacts', array(
            array("name" => 'first_name',"value" => 'Geek'),
            array("name" => 'last_name',"value" => 'Smith'),
            array("name" => 'email1',"value" => '[email protected]'),
            array("name" => 'account_id',"value" => $account_id)
            ));
$contact_id = $response->id;
    

I hope this helps – if you have anything to add, or would like to post some examples, please do :)

SugarCRM SOAP API

I don’t know when SugarCRM, the open source CRM tool, first acquired a SOAP API but I missed it completely. I’ve used SugarCRM a few times, on quite a casual level, and only fell across the SOAP API because I needed it.

The first thing to note is that the SOAP API for SugarCRM is advertised as being incompatible with the PHP 5 SOAP client implementation, and they recommend you use nusoap. However this isn’t true and I found it worked fine with PHP 5 in non-WSDL mode.

The second thing to note is that the documentation is rubbish. The best I could find is on their developer wiki and it isn’t enough to write an application with. I had to do a fair amount of fiddling around on the server side to understand when I was making mistakes which isn’t ideal for remote system calls! They do, however, have very good inline documentation so I ran PHPDocumentor over the file which had the stuff I was dealing with in it. I can’t find an equivalent online so you can see my copy over here

Also if you go to your own sugar installation and append /soap.php to the URL, you will see some information there about formats plus a link to the WSDL. The WSDL isn’t very human-readable but the top bit of it defines the custom data formats like “name_value_list” and shows you how to assemble them to submit to SOAP. If I can work out a good way of presenting that information I’ll add it somewhere and link to it.

There will also be a follow-up with the script that worked for me. If this helps, or you have any questions, then add a comment please :)

SugarCRM Custom Fields

‘Tis the week for code snippets it seems – actually its mostly that I’m working with SugarCRM in anger for the first time and falling into a few traps. Due to the unique way in which this product is funded, there is a lot less community support around than I’d expect for a product this size.

Today I attempted to create custom fields for the first time, which should have been much easier than it was. The first problem was that all the tutorials deal with earlier versions of Sugar and the interface has changed. The second problem was that I kept on getting lots of errors when I tried to create a custom field. The errors were Javascript errors but when I looked in my apache error log there were lots of these:

PHP Warning:  LanguageManager::include(cache/modules/ModuleBuilder/language/en_us.lang.php) [function.LanguageManager-include]: failed to open stream: No such file or directory in .../include/SugarObjects/LanguageManager.php on line 91, referer: ...
index.php?module=ModuleBuilder&action=index&type=studio

On closer inspection I realised the cache directory was empty. I made this writeable by the apache user and everything started working after that.

Custom Field Creation

Here’s a very quick run through on the steps that I followed. From the home screen, go into the admin section and then click on “Studio”. In the left-hand pane, expand the folder for the module you want to add things to and click on “Fields”. At this point you should read the help entries in the right hand screen but for the impatient: Click on “Add Field”, enter the field details and click on “Save”. The field name gets saved with a suffix of “_c” and should appear in the central pane under “custom”. If it doesn’t, see above for my comments about the cache directory.

The new field needs to be added to the layout before you will see it – this seems to fool a lot of people and I must admit I would have missed this myself if I hadn’t read it on the forums. Once you have created your field, go back to the tree view on the left and choose which layouts you’d like to be able to see your field in. Again there is help on the right hand panel but basically you drag the “new row” thing from the left hand column in the central panel to the right hand column in the central panel, and then drop your new field on top of it.

Hope this helps, its taken me quite a while to get to grips with what should be fairly simple. I’ll add a final note to say that the custom fields are available through the SOAP API – just remember their names get suffixed with a “_c”.