Archive for the ‘Tip’ Category

Adding/Modifying the Shortcuts Menu

Monday, June 29th, 2009

Adding/Modifying the Shortcuts Menu

Suppose you want to modify the Opportunities Shortcuts menu to add a shortcut to create a new Lead (not tied to the existing opportunity).

Create a custom file called:

/custom/Extension/modules/Opportunities/Ext/Menus/CustomMenu.php

The filename is not very important.  Add the following contents:
<?php

if(ACLController::checkAccess(‘Leads’, ‘edit’, true))$module_menu[]=Array(“index.php?module=Leads&action=EditView&return_module=Opportunities&return_action=ListView”, “New From Canvass Form”,”CreateNotes”, ‘Leads’);

?>

Lets’s look at this code to see what it does.
if(ACLController::checkAccess(‘Leads’, ‘edit’, true))

This line of code checks to see if the user has access to the Leads module.  If they do then the system will all another shortcut menu.  This is not strictly required, but good coding practice so users don’t see menu items for modules they can’t create or edit.

The variable $module_menu contains the items the information used to create the menus.  The format is

$module_menu[]=Array($url,$menu_title,$image_icon,$module)

$url – this is where you want to go.  You can look at <install dir>/<ModuleName>/Menu.php to see the shortcuts for the existing modules

$menu_title – In this example, I hard coded the name to “New from Canvass Form”.  If you want the application to be multi-lingual and conform to Sugar standards, you should add a custom string and use something like $mod_strings['LNK_NEW_FROM_CANVASS_FORM']

$image_icon – The images are found in themes/default/images.  If you want to add a new icon, put it there.

$module – The name of the module

You must do a Quick Repair and Rebuild for this to take effect.

If you want to not show the out of the box shortcut menu items, you can just redeclare the array.  Putting the following code in your cusotm file:

<?php

$module_menu= array();

if(ACLController::checkAccess(‘Leads’, ‘edit’, true))$module_menu[]=Array(“index.php?module=Leads&action=EditView&return_module=Opportunities&return_action=ListView”, “New From Canvass Form”,”CreateNotes”, ‘Leads’);

?>

will have only 1 shortcut item.

SugarCRM’s Resource Limits

Wednesday, April 22nd, 2009

This post is for SugarCRM system administrators developers.

System Administrators  –  If you’re running a SugarCRM system, keep some of these tips in mind.

Developers – These are just good things to know.

Sometimes “user initiated processes” turn into runaway processes on the server.  For example, someone may create a tool that iterates through a result set from the database query, only to do additional queries based on the result. The tool may work well for the developer on their dev environment, but it may not scale well.  These kind of actions turn into runaway processes.

Many different platforms impose quotas/limits.  SugarCRM is no different.  In the 5.1 release we created database query limits.  As a developer, you should be aware of these so that you can develop code accordingly.

In config.php you’ll find a section of the $sugar_config array that looks like and is controlled like this:

'resource_management' =>
array (
'special_query_limit' => 50000,
'special_query_modules' =>
array (
0 =>'Reports',
1 => 'Export',
2 => 'Import',
3 => 'Administration',
4 => 'Sync',
),
'default_limit' => 1000,
),

This is the “out of the box” configuration – of course you can change this (c’mon this is SugarCRM, you can modify anything!).

Some intentionally resource intensive features such as Reports, Exports, Import, Offline Client, and anything in the Admin section are allowed to have 50,000 queries.  Otherwise, the default is 1000 queries.  You can modify this to fit your needs.

The best way to modify this is in config_override.php using $sugar_config['resource_management']

Another feature that allows you to manage access to some key administrative areas of your Sugar system is the following setting:


$sugar_config['admin_access_control'] = true;

Some of the actions that this setting will disable are features in the admin panel:

  1. Backups
  2. Upgrade Wizard
  3. Module Builder

The full list is detailed in files_access_control_map.php and is easily expanded in custom/include/MVC/Controller/file_access_control_map.php.

A final security control allows you to restrict Module Loader to read modules from only a specific directory on the server and disables the ability to upload new modules into the Module Loader.


$sugar_config['use_common_ml_dir'] = true ; // to enable or disable the feature.

$sugar_config['common_ml_dir'] = '/path/to/your/directory'; // modules will be loaded from this directory.

Remove a Tab, keep the Subpanel

Tuesday, April 21st, 2009

I was speaking with one of Sugar’s stellar Customer Support Engineers today when we came up with this little tid bit…

The problem:

The customer wanted to remove the Opportunities tab, but keep it as a subpanel in a detailview – oh and make it upgrade safe.

The solution:

The modules that are displayed or hidden are (for the most part) by include/modules.php

If you view include/modules.php, you’ll notice that there are multiple arrays.  Most importantly, there is a way (at the very end) to override this file:


if (file_exists('include/modules_override.php'))

{

include('include/modules_override.php');

}

if (file_exists('custom/application/Ext/Include/modules.ext.php'))

{

include('custom/application/Ext/Include/modules.ext.php');

}

I prefer to keep all customizations in the “custom” directory – so let’s use .custom/application/Ext/Include/modules.ext.php

After creating the file, this is the code we added:


<?php

$modulekey = array_keys($moduleList, 'Opportunities');

foreach($modulekey as $key =&amp;amp;gt; $value){

unset($moduleList[$modulekey[$value]]);

}

$modules_exempt_from_availability_check['Opportunities'] = 'Opportunities';

$modInvisList[] = 'Opportunities';

?>

The critical array here is “$modules_exempt_from_availability_check”.  This array adds the subpanel back into the view.

Also, it’s worth noting the gymnastics we used to unset the array.  That’s because you need to unset it by the array’s index….  Because it’s possible that we someone else could put “Opportunities” in the moduleList array multiple times, we loop through it.

Finally, to date (the 5.2.0c), modules.ext.php would get over-written by Module Builder if you deploy a module.  That means, if you make a module, this custom code would get destroyed.  The simple solution, is to put it in the other place -> include/modules_override.php.  While that’s safe, it’s keeping custom code out of the custom directory.  A bug has been filed and we’ll see a fix in future releases.

If you can think of ways that will help create better hooks for customizations in the custom directory, please let us know!  We’re always looking for ways to make Sugar even more upgrade safe with customizations.

How To Exclude Archived Emails from Outlook To-Do List

Friday, April 3rd, 2009

If you are an Outlook Plug-in user, you may have noticed that the act of archiving emails into Sugar will add a flagged task to your To-Do list in Outlook 2007.  The task will have the subject of the email, and will have a category of SugarCRM. (Note: This is expected behavior for the Outlook Plug-in)

This is the mechanism that we use to denote whether or not an email has already been archived to Sugar, but you may find that it’s cluttering up your To-Do list.  If this is disrupting your normal use of the To-Do list, you can customize your Outlook views to filter out these tasks.

These are the basic steps, and please consult with Microsoft’s documentation for further detail.

1. Right-click within the To-Do Bar, and select the customize “Current View” option.

screen-capture-2
2. Choose the Filter button, then the Advanced tab.

screen-capture-3

3. Select the Field dropdown under the “Define more criteria” heading, and choose All Task Fields >> Categories from the 4. dropdown.

4. Set the Condition to “doesn’t contain”, and set the Value to “SugarCRM”.  Click the “Add to List” button.

screen-capture-4

5. Click OK in the Filter dialog window, and then click OK in the Customize View: To-Do List dialog.

6. Your To-Do Bar will no longer display the task for the email that was archived to Sugar.

screen-capture-5

You can repeat these steps for the Tasks view within Outlook.

The original email message will retain the flag in the Mail view, to indicate that you’ve already archived the message to Sugar.

screen-capture-6

Secret Configuration Settings To Make Your Life Easier

Wednesday, April 1st, 2009

It’s been awhile since I’ve blogged.  It’s nice to be back and I am going making it a much more regular thing – I promise.

I thought for my comeback post, I would share some of the deepest secrets of SugarCRM configuration.  These options are sooo l33t that I feel like I can only share them on my comeback post.  You’ll be amazed.

However, I *must* add this disclaimer:  Your mileage may vary.  Use at your own risk.  Test in a development version first.  DO NOT PUT IN PRODUCTION without testing.

Seriously, please make sure it works in your dev environment first. I don’t want to crash the forums or overburden Support with requests if this doesn’t work for you.

Ok here it goes:

In ./config_override.php try these out:


$sugar_config['make_me_coffee'] = true;

$sugar_config['do_my_laundry'] = true;

$sugar_config['donuts_yum_yum'] = true;

So try them out.  If they don’t work for you, you probably have set something up wrong.  Try file permissions or something like that.  Don’t bother submitting a case, support doesn’t support these options.  You can try your luck on the forums, good luck!

Quick ListView customization

Monday, March 23rd, 2009

As the next installment in the Sugar Tips and Tricks series from the Sugar engineering team, I will perform a quick and simple ListView customization which leverages the Carousel widget from the Yahoo UI (YUI) library. This customization completely changes the look and feel of the Contact ListView from a “rows and columns” view of your search results to a Yahoo UI Carousel view. The YUI library is included in SugarCRM and provides a ton of UI features beyond what we use in the core application.

Carousel Widget on Contacts Listview

I will only need to customize two files:

  1. view.list.php in the Contacts module
  2. ListViewContacts.tpl – a new smarty file which I have added to be used within the view.list.php file

Create a new file view.list.php file in custom/modules/Contacts/views. The beginning of the file including the constructor should look like:

require_once('include/MVC/View/views/view.list.php');
class ContactsViewList extends ViewList {

function ContactsViewList(){
parent::ViewList();
}

You can see that I am extending from the ViewList class as defined in ‘include/MVC/View/views/view.list.php’ so that I can take advantage of the methods which are already implemented and only override what I need. Since I only want to change how the ListView looks, I will do most of that in Smarty so I need to only override the method in ViewList which deals with rendering the template.

listViewProcess()

should do the trick.
Here is the full listing for the ContactsViewList class below:

require_once('include/MVC/View/views/view.list.php');
class ContactsViewList extends ViewList {

function ContactsViewList(){
parent::ViewList();
}
function listViewProcess(){
$this->processSearchForm();
$this->searchColumns = $this->searchColumns;
if(!$this->headers)
return;
if(empty($_REQUEST['search_form_only']) || $_REQUEST['search_form_only'] == false){
$this->lv->setup($this->seed, 'custom/modules/Contacts/tpls/ListViewContacts.tpl', $this->where, $this->params);
$savedSearchName = empty($_REQUEST['saved_search_select_name']) ? '' : (' - ' . $_REQUEST['saved_search_select_name']);
echo get_form_header($GLOBALS['mod_strings']['LBL_LIST_FORM_TITLE'] . $savedSearchName, '', false);
echo $this->lv->display();
}
}
}

Now that we have provided a way to get my own custom smarty template loaded on the Contacts ListView, I will create my Smarty file in custom/modules/Contacts/tpls/ListViewContacts.tpl. My goal here will be to remove most of the table rendering logic defined in ListViewGeneric.tpl and replace it with my own rendering logic to display the carousel.


link rel="stylesheet" type="text/css" href='{sugar_getjspath file='include/javascript/yui/build/fonts/fonts.css'}'>
<link type="text/css" rel="stylesheet" href='{sugar_getjspath file='include/javascript/yui/build/carousel/assets/skins/sam/carousel.css'}'>
<script src='{sugar_getjspath file='include/javascript/yui/build/utilities/utilities.js'}'></script>
<script src='{sugar_getjspath file='include/javascript/yui/build/carousel/carousel-beta-min.js'}'></script>
{literal}

<style type="text/css">
.yui-carousel-element li {
height: 158px;
text-align: left;
}

#container {
font-size: 13px;
margin: 0 auto;
}

#container a {
text-decoration: none;
}

#container .intro {
display: inline;
margin: 0px 14px 0px 4px;
width: 202px;
}

#container .item {
display: inline;
margin: 0 22px 0 12px;
overflow: hidden;
padding-right: 80px;
width: 106px;
}

#container .item .authimg {
bottom: 2px;
margin-left: 61px;
position: absolute;
z-index: 1;
}

#container .item h3 {
line-height: 85%;
margin-top: 4px;
}

#container .item h3 a {
font: 77% Arial, sans-serif;
position: relative;
text-transform: uppercase;
z-index: 2;
}

#container .item h3 a:link {
color:#35a235;
}

#container .item h4 {
margin-top:5px;
}

#container .item h4 a {
font: 100% Georgia, Times, serif;
position: relative;
z-index:2;
}

#container .item h4 a:link {
color:#00639b;
}

#container .item cite {
color: #888;
display: block;
font-size: 77%;
line-height: normal;
margin-bottom: 30px;
}

#container .item p.all {
bottom: 25px;
position: absolute;
z-index: 2;
}

#container .item p.all a {
font-weight: bold;
font-size: 85%;
}
</style>
{/literal}
<div  class="yui-skin-sam">
<div id="container">
<ol id="carousel">
{foreach name=rowIteration from=$data key=id item=rowData}
<li class="item">
<a href='index.php?module={$pageData.bean.moduleDir}&amp;action=detailview&amp;record={$rowData.ID}'>
{foreach from=$displayColumns key=col item=params}
{if $params.link &amp;!$params.customCode}

<{$pageData.tag.$id[$params.ACLTag]|default:$pageData.tag.$id.MAIN} href="#" onMouseOver="javascript:lvg_nav('{if $params.dynamic_module}{$rowData[$params.dynamic_module]}{else}{$params.module|default:$pageData.bean.moduleDir}{/if}', '{$rowData[$params.id]|default:$rowData.ID}', 'd', {$offset}, this)"  onFocus="javascript:lvg_nav('{if $params.dynamic_module}{$rowData[$params.dynamic_module]}{else}{$params.module|default:$pageData.bean.moduleDir}{/if}', '{$rowData[$params.id]|default:$rowData.ID}', 'd', {$offset}, this)">{$rowData.$col}</{$pageData.tag.$id[$params.ACLTag]|default:$pageData.tag.$id.MAIN}>

{elseif $params.customCode}
{sugar_evalcolumn_old var=$params.customCode rowData=$rowData}
{elseif $params.currency_format}
{sugar_currency_format
var=$rowData.$col
round=$params.currency_format.round
decimals=$params.currency_format.decimals
symbol=$params.currency_format.symbol
convert=$params.currency_format.convert
currency_symbol=$params.currency_format.currency_symbol
}
{elseif $params.type == 'bool'}
<input type='checkbox' disabled=disabled class='checkbox'
{if !empty($rowData[$col])}
checked=checked
{/if}
/>
{elseif $params.type == 'multienum'}
{if !empty($rowData.$col)}
{counter name="oCount" assign="oCount" start=0}
{assign var="vals" value='^,^'|explode:$rowData.$col}
{foreach from=$vals item=item}
{counter name="oCount"}
{sugar_translate label=$params.options select=$item}{if $oCount !=  count($vals)},{/if}
{/foreach}
{/if}
{else}
{$rowData.$col}
{/if}
{/foreach}
</a>
</li>
{/foreach}
</ol>
</div>
</div>
{literal}
<script>
(function () {
var carousel;

YAHOO.util.Event.onDOMReady(function (ev) {
var carousel    = new YAHOO.widget.Carousel("container", {
animation: { speed: 0.5 }
});

carousel.render(); // get ready for rendering the widget
carousel.show();   // display the widget
});
})();
</script>
{/literal}

You can see from the above I have stripped out the table HTML and now the meat of the display is done here:


<div id="container">
<ol id="carousel">
{foreach name=rowIteration from=$data key=id item=rowData}
<li class="item">

We simply loop through each of our rows and output it into the <li> tags and then once this has rendered the JavaScript:


(function () {
var carousel;

YAHOO.util.Event.onDOMReady(function (ev) {
var carousel    = new YAHOO.widget.Carousel("container", {
animation: { speed: 0.5 }
});

carousel.render(); // get ready for rendering the widget
carousel.show();   // display the widget
});
})();

will render the widget.

New vCal Updates Setting in 5.2.0c

Monday, March 23rd, 2009

In the Sugar 5.2.0c patch that was released last week, we included a new setting in the System Settings page that allows administrators to set the vCal time period.  Administrators can specify the number of months in advance of the current date that Free/Busy information for calls and meetings is published for each user. 

The new field in the System Settings page is titled “vCal Updates Time Period:”, and the default value is two months. Administrators can now enter the preferred number of months, from one to 12, as well as turn off Free/Busy publishing altogether by entering “0″.

The reason for this setting is to allow administrators to control VCal efficiency on saves of calls and meetings.  When calls and meetings are saved, queries are run to fetch vCal data for the assigned user.  Prior to 5.2.0c, the time period of information that the query was sent to retrieve was set to two months in advance of the current date, and entire VCal data was re-constructed for the next two months for each user/attendee.  The two month time period could not be changed, and vCal could not be disabled through the application UI, even if vCal was not being used.

Using vCal and retrieving data for a longer time period can have an impact on application performance when users have a lot of data to retrieve, or can unncessarily slow down the time to save a record if vCal is not being used and the queries are still run.

$tip = new TipsAndTricks(2, ‘New SugarFields In Studio’);

Monday, March 16th, 2009

In the last tip we showed how to add a new SugarField to the application. This time we’ll show you how to add that SugarField to Studio so administrators can add it as a custom field to layouts. It should be noted that we will be patching some core files. These same patches will be available in the next release of SugarCRM. As a side note empty() is getting rendered as emptyempty in this post. We are looking into the issue, but just make a mental note that if you see !emptyempty it should read just !empty.

Step 1:Patching Dynamic Fields

The first file we need to patch is modules/DynamicFields/FieldCases.php. This file is essentially a switch statement for Module Builder and Studio to retrieve the appropriate Sugar Field class. We’ll be changing to allow for supporting custom SugarFields.

Change the code inside the function get_widget from

default:
    $local_temp = new TemplateText(); break;

to

default:
	$file = false;
	//CHECK IF THERE IS A CUSTOM TEMPLATE
	if(file_exists('custom/modules/DynamicFields/templates/Fields/Template'. $type . '.php')){
		$file  =	'custom/modules/DynamicFields/templates/Fields/Template'. $type . '.php';
	//CHECK IF THERE IS A STANDARD TEMPLATE
	}else if(file_exists('modules/DynamicFields/templates/Fields/Template'. $type . '.php')){
		$file  =	'modules/DynamicFields/templates/Fields/Template'. $type . '.php';
	}
	//IF THERE WAS A CUSTOM OR STANDARD TEMPLATE USE IT
	if(!empty($file)){
		require_once($file);
		$class  = 'Template' . $type ;
		$customClass = 'Custom' . $class;
		//CHECK FOR A CUSTOM CLASS
		if(class_exists($customClass)){
			$local_temp = new $customClass();
		}else{
			//DEFAULT TO THE STANDARD CLASS NAME Template{$type}
			$local_temp = new $class();
		}
		break;
	}else{
		$local_temp = new TemplateText(); break;
	}

Step 2:Creating a YouTube Template Field

Now our code can load custom templates, so let’s create our custom YouTube template. We want it to behave like a normal text field, but when it’s creating it’s vardef it should have the type set to YouTube. To do this we create a new template in custom/modules/DynamicFields/templates/Fields/TemplateYouTube.php and we’ll create a TemplateYouTube class that extends TemplateField. Our code should look something like this

<?php
require_once('modules/DynamicFields/templates/Fields/TemplateField.php');
class TemplateYouTube extends TemplateField{
	//SET TYPE TO YouTube
	var $type='YouTube';

	//THIS FUNCTION GENERATES THE VARDEF
	function get_field_def(){
		//CALL ON PARENT FUNCTION TO RENDER VARDEF
		$def = parent::get_field_def();

		//IF WE HAVE A DEFAULT VALUE SET IT
		$def['default'] = !empty( $this->default) ? $this->default : $this->default_value;

		//LET'S SET THE MAX LENGTH
		$def['len'] = 50;

		//STILL HAVE THE DB THINK OF THE FIELD AS A varchar
		$def['dbType'] = 'varchar';

		return $def;
	}
}

Step 3:Adding YouTube to the custom field Drop Down

Now that we have a template class for our YouTube field we need it to actually show up in Studio and Module Builder. To do this we simply create a file custom/modules/ModuleBuilder/language/en_us.lang.php and put the following code in it

<?php
	$mod_strings['fieldTypes']['YouTube'] = 'YouTube';

You will need to delete the cached language file for Module Builder and Studio which is located in cache/modules/ModuleBuilder/langague/en_us.lang.php
Once you have done this you should be able to go to studio and add a custom field of type YouTube. Now your administrators can take advantage of all the new SugarFields you create.

$tip = new TipsAndTricks(1, ‘Creating a YouTube Sugar Field’);

Monday, March 16th, 2009

We just finished a great SugarCon event in San Francisco, and the engineering team really did a great job conveying a lot of tips and tricks to the community. We wanted to continue this momentum, and after discussing the idea with a few developers we have decided to release a new tip/trick every week up to next year’s SugarCon.  That’s 52 tips and tricks a year for those of you doing the math. As some of you may note SugarCon was actually 2 weeks ago, so we are already a week behind. Don’t fret, we’ll be releasing 2 tips and tricks this week.

Creating A YouTube Field

Sugar ships with several types of fields out-of-the-box including but not limited to – text, iframe, phone, link, enum …, but every now and then you want to have a new field type. In this article, we shall describe how to create a field for displaying YouTube© videos.

To begin with, let’s review the code that drives field behavior.  If you look into the base SugarField directory (include/SugarFields/Fields/Base), you will see the following files

  1. DetailView.tpl
  2. EditView.tpl
  3. SearchForm.tpl
  4. SugarFieldBase.php

The SugarFieldBase class defined in SugarFieldBase.php handles the processing of the SugarField and loads the appropriate Smarty template (.tpl) file for rendering the field.

Now if you open up any of the .tpl files you will notice that we use the double curly braces (e.g. {{ and }} ) instead of standard Smarty template syntax which uses single curly braces (e.g. { and } ). This is because the Smarty code these templates will create is based upon resolving EditView.tpl or DetailView.tpl with the metadata defined in editviewdefs.php and detailviewdefs.php respectively. For example the base DetailView.tpl code looks like the following:


{{sugarvar key='value'}}
{{if !empty($displayParams.enableConnectors)}}
{{sugarvar_connector view='DetailView'}}
{{/if}}

However, the runtime code that this would generate for the Accounts module (cache/modules/Accounts/DetailView.tpl) looks like:


{$fields.employees.value}

If we wanted to get the value of a field that is different from the one currently being rendered we could do the following:


{{sugarvar memberName='name' key='value'}}

And this would generate the following smarty code


{$fields.name.value}

The reason for the double curly brace ( {{ ) versus the single curly brace ( { ) is that this approach allows us to put a certain level of logic in the code so you could do something like changing the color of the text based on the value of a field:

{if {{sugarvar memberName='employees' key='value' stringFormat='false'}}>1000}

<span style='color:green'>

{else}

<span style='color:purple'>

{/if}

{{sugarvar memberName='employees' key='value'}}</span>

This is rendered at runtime as:


{if $fields.employees.value  > 1000}

<span style='color:green'>

{else}

<span style='color:purple'>

{/if}

{$fields.employees.value}</span>

One of the nice things about SugarFields is that they can inherit from parent fields – this is true for both the rendering class and the templates. Even better yet if there is no custom code that needs to be added to our rendering class, the base class can handle the rendering for us and we don’t even need to subclass it. For our YouTube example we will just need to create a custom DetailView.tpl

Step 1: Create the Sugar Field Directory

Create the directory:  include/SugarFields/Fields/YouTube

We could actually use the YouTube field in the code right now, but it would render using the base SugarField which is just a text input box.

Step 2: Create DetailView.tpl

Create the File:  include/SugarFields/Fields/YouTube/DetailView.tpl

Step 3: Edit DetailView.tpl

I went over to YouTube and grabbed the embed code that is displayed next to one of my favorite videos. We will be expecting users to enter in a YouTube video id in the edit view and based on that id we will render the appropriate video.

<object width="425" height="344">
<param name="movie"
value="http://www.youtube.com/v/{{sugarvar key='value'}}">
</param>
<param name="allowFullScreen" value="true">
</param>
<param name="allowscriptaccess" value="always">
</param>
<embed
src="http://www.youtube.com/v/{{sugarvar key='value'}}"
type="application/x-shockwave-flash"
allowscriptaccess="always" allowfullscreen="true" width="425"
height="344">
</embed>
</object>

Step 4: Using the YouTube Field

There are two ways that the YouTube field may be used, first you may specify a specifc field in the detailviewdefs.php of a module with type set to ‘YouTube’ for example in Accounts you can change website to be a YouTube video field:

array('name'=>'website', 'type'=>'YouTube')

The other way is in the vardefs where you need to set two parameters of a fields vardefs, type and dbType.

'website' =>array (
'name' => 'website',
'vname' => 'LBL_WEBSITE',
'type'=>'YouTube',
'dbType' =>'varchar'
),

Step 5: Don’t Render YouTube Fields That Don’t Have IDs


{if !empty({{sugarvar key='value' stringFormat=false}})}
<object width="425" height="344">
<param name="movie"
value="http://www.youtube.com/v/{{sugarvar key='value'}}">
</param>
<param name="allowFullScreen" value="true">
</param>
<param name="allowscriptaccess" value="always">
</param>
<embed
src="http://www.youtube.com/v/{{sugarvar key='value'}}"
type="application/x-shockwave-flash"
allowscriptaccess="always" allowfullscreen="true" width="425"
height="344">
</embed>
</object>

{else}

No YouTube Video Available

{/if}

Now you have a fully functioning “Custom SugarField”.   Stay tuned for this week’s 2nd tip on how to add your new SugarField to Studio.

Note: As of the writing of this article, Sugar 5.2.0a is the current patch version generally available.  In the upcoming Sugar 5.2.0c patch, you will be able to place the SugarField files in the custom directory (custom/include/SugarFields/Fields/) in order to override the default behavior in an upgrade-safe manner. However, it is okay to place these changes in the include/SugarFields/Fields/ for this exercise as long as your field names don’t conflict with default field names.

Writing a Cloud Connector for Sugar 5.2

Thursday, January 22nd, 2009

A new item in the 5.2 release is the Cloud Connector framework. The framework allows developers to integrate data from external Web Services and widgets into their SugarCRM installation.   Data from existing modules such as accounts, contacts, and leads may act as inputs to retrieve external data.

For the Community Edition, the framework will allow the placement of what we call Cloud View Icons on fields in a record’s detail view. When you place your cursor over the icon, it activates the code in the Connector, typically a search of an external data provider. These icons may link to external web services or widgets to retrieve additional information. For Sugar 5.2 we included support for LinkedIn©’s Company Insider widget in the Community Edition release which can be used as an example connector to learn the framework and create your own.

In Sugar Professional and Enterprise the system will also contain additional connectors (e.g. Hoovers© and Jigsaw©) and have the ability to merge the data into existing records.

The main components for the framework are the factories, source and formatter classes.

The factories are responsible for returning the appropriate source or formatter instance for a connector. Sources are responsible for encapsulating the retrieval of the data as a single record or a list or records of the connectors. Formatters are responsible for rendering the display elements of the connectors.

For more details on the framework and getting started writing your own connectors check out the updated 5.2 developer guide.

Have feedback for us? Drop us a line.
Terms & Conditions | Privacy | Trademark Info | Contact Info | FAQs | SugarCRM Inc.© 2004 - 2009 All rights reserved.