PHP, SugarCRM, Javascript, Cool Web Apps Developer

Blog

Customize the export functionality for a module

Posted by swapnil shinde on January 31, 2012 at 3:30 PM Comments comments (0)

The easiest way to do this is by providing your own query to use in the module’s bean method create_export_query(), but this isn’t upgrade-safe for any of the out of the box modules. However, there is an upgrade-safe way to do this, although it’s a bit more indepth, which our resident Sugar Hero andopes points out below ( from this post ):

 

You can create the script custom/modules/Leads/entry_point_registry.php containing something like that:

 

if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');

 

$entry_point_registry['export'] = array('file' => 'custom/modules/Leads/export.php', 'auth' => true);

?>

 

The script custom/modules/Leads/export.php should be similar to default export.php. Inside this script you need to call a customized export (defined in include/export_utils.php). You can defined then which fields to export.

Credit :http://developers.sugarcrm.com/wordpress/2011/09/13/howto-customize-the-export-functionality-for-a-module/

Disable SugarCRM AjaxUI

Posted by swapnil shinde on January 31, 2012 at 3:10 PM Comments comments (2)

In version 6.3 of SugarCRM we are introducing a new method for loading pages that uses AJAX to load the html content rather than doing a full page refresh. This has some major impacts on performance.

You also have the option of totally disabling the AjaxUI with the following line. In config_override.php

$sugar_config['disableAjaxUI']=true;

just add line above in config_override.php

Using a relate field to populate a custom field

Posted by swapnil shinde on January 31, 2012 at 2:50 PM Comments comments (1)

 

In edit view of your module  once you select any record in relate field, if you want to populate any other field from same module then follow the following steps.

There are times a client requests, or common sense usability dictates the need to use a relate field to populate information related to a record. Often times, you can get away with an address or phone number; but there are times where you need to use a custom field.

 

The situation for our client required the use of an Account relate field and a field containing an account number that comes from another system our client uses. The requirement was that when the Account relate field is filled in that the account number field be populated with the number for that account. That leaves two situations we had to account for; the use of the Sugar Quick Search and the use of the Account popup.

 

The first example is how to complete this task using the Sugar Quick Search:

 

1. In your FTP client, navigate to your /custom/Extensions/modules/{MODULE NAME}/vardefs

2. From here you can either create a new file, or edit an existing file. Look for a file name sugarfield_{name_of_your_field}.php that’s the best place to add new code and maintain organization

3. Open that up and add the following lines:

 

$dictionary['{YOUR MODULE NAME}']['fields']['{YOUR FIELD NAME}']['populate_list'] = array('id','name','{NAME OF DB FIELD YOU WANT TO ADD}');

 

$dictionary['{YOUR MODULE NAME}']['fields']['{YOUR FIELD NAME}']['field_list'] = array('account_id_c','account_name','{THE ID OF YOUR FIELD ON THE EDITVIEW LAYOUT}');

 

4. You’ll want to replace anything contained in curly brackets with the specific information for your application. The populate_list is a list of the database field names that you are going to be pulling from the database. The field_list is the list of fields that you are going to be placing these values.

5. Once you have this in place, go to Admin/Repair/Quick Repair and this process will rebuild the vardefs file in /custom/modules/{MODULE NAME}/Ext/vardefs/vardefs.ext.php.

 

That’s all there really is to it from a technology standpoint, you can add fields to the arrays to populate more than 1field as well.

 

The Popup is where things are a little bit more tricky, at least until you know what you need to do. Setting it up in the code is easy enough.

 

1. Open /custom/modules/{YOUR MODULE}/metadata/editviewdefs.php

2. Field your field definition in the file, our full example is included below:

 

array (

'name' => 'accounts_hdsmi_nym_customer_service_name',

'displayParams' => array (

'field_to_name_array' => array(

'id'=>'accounts_h66a5ccounts_ida',

'name'=>'accounts_hdsmi_nym_customer_service_name',

'accountnum_c' => 'account_number_c',

),

'additionalFields' => array(

'accountnum_c' => 'account_number_c',

),

),

),

),

 

This is really all the code you need to get this set up. In the field_to_name_array and additionalFields array the key is the database field and the value is the Sugar field you are going to be populating. Pretty straight forward.

 

This next part is very important regardless of whether it’s working or not. Go into Studio and click on the module that corresponds to the relate field you are working with. (Account relate field requires you to open the Accounts Module). Go into your layouts and find the layout for your Popup List View. If it’s already working, then the custom field that’s being populated is already in that list view. If it’s not working, you’ll want to add that custom field to the list view. This is very important if it is working, because if that custom field is removed from the layout, it will stop working.

Credit: http://developers.sugarcrm.com/wordpress/2011/08/31/howto-using-a-relate-field-to-populate-a-custom-field/


 

Repair Rebuild through Code

Posted by swapnil shinde on January 31, 2012 at 2:40 PM Comments comments (10)

PHP Code:

require_once("include/entrypoint.php");

require_once("modules/Administration/QuickRepairAndRebuild.php");

$rac = new RepairAndClear();

$rac->repairAndClearAll(array('clearAll'),array(translate('LBL_ALL_MODULES')), false,true);