Thursday, 21 March 2013

Dealing with multienums with SugarCRM

Greetings!

SugarCRM comes with a very handful function to convert multi enum values from ^value_1^,^value_2^,^value_3^,^value_4^ into an array.


$aField = unencodeMultienum($fieldValue);
var_dump($aField);



will give you an array.

In the same manner the reverse is possible. Give an array of values which will be converted into a string which SugarCRM understands.


encodeMultienumValue($arr);


Hope this helps.

Feel free to leave comments.

Tuesday, 19 March 2013

Show message after redirection

Greetings!

To do: Let's alert user a message after redirection to any view.


Following piece of code will show a message at the top of the view you have redirected user to.


SugarApplication::appendErrorMessage('You have been redirected here because ....');



If you dont know how to redirect user to a certain view,


SugarApplication::redirect('index.php?module=<MODULE_NAME>&action=<ACTION>&record=<RECORD_ID>');




Hope it helps.

Feel free to leave your comments.

Monday, 11 March 2013

Create Controls, Sugar way!

Greetings!

Have you ever wondered, how can I create an input/date/dropdown control without manually writing the html tags in SugarCRM?

If you dint find the solution, there you go!! Worth appreciating ;)


require_once("modules/Import/Forms.php");
$moduleName = '<Your_module_name>';
$oModule = BeanFactory::getBean($moduleName);
$fieldName = '<Your_field_name> ';
echo getControl($moduleName, $fieldName, $oModule->getFieldDefinition($fieldName), "");



I can hear the grand Applause! ;)

Tuesday, 5 March 2013

Concate 2 fields in list view without using process record logic hook

Greetings!!

To do: Concatenate values of different fields in one column, without using process record logic hook.

Just a step: Go to custom/modules/<MODULE_NAME>/metadata/listviewdefs.php, if you dont find it there, go to Admin > Studio > <MODULE_NAME> > Layouts > List View > Save and Deploy, which will generate that file for you to modify.

Just for an example, we will here merge, Contact's Office Phone with a custom field named "Extended Phone".

I created the Extended Phone custom field through studio, so I got the field name extended_phone_c.

In listviewdefs in I change the definition of the filed like,

'PHONE_WORK' =>
  array (
    'width' => '15%',
    'label' => 'LBL_OFFICE_PHONE',
    'default' => true,
     'related_fields' =>
    array (
      0 => 'extended_phone_c', // your field name in all small letters
    ),
      'customCode' => '{$PHONE_WORK} | {$EXTENDED_PHONE_C}', // your field name in ALL CAPITAL LETTERS
  ),

And thats it! Refresh list view.

Hope this helps.

Feel free to drop your valuable comments.
Urdhva Tech Pvt. Ltd. Powered by Blogger.

Urdhva Tech

My photo
SugarCRM Consultants Contact us at contact@urdhva-tech.com Skype : urdhvatech

Search This Blog

Stay connected Socially

     

Total Pageviews

Popular Posts