Tech Tips

Asterisk
  • Asterisk Dial Plan Patterns
          From  http://www.voip-info.org/wiki/index.php?page=Asterisk+Dialplan+Patterns

  1.  X          matches any digit from 0-9
  2.  Z          matches any digit from 1-9
  3.  N          matches any digit from 2-9
  4.  [1237-9]   matches any digit or letter in the brackets (in this example, 1,2,3,7,8,9)
  5.  [a-z]    matches any lower case letter (introduced in which Asterisk version?)
  6.  [A-Z]    matches any UPPER case letter (introduced in which Asterisk version?)
  7.    .          wildcard, matches one or more characters
  8.    !          wildcard, matches zero or more characters immediately  (only Asterisk 1.2 and later, see note) 

SugarCRM

I have found SugarCRM to be a solid product with a robust architecture that tries to enforce a disciplined approach to customizing the application through a well thought out metadata file system leveraging the Smarty template language. While a lot of information is available in the forums and various blogs, I have found myself wishing there was a single comprehensive source of developer information available on line.  As I learn the path to customising this product I will document those tips here.

While the product comes with a very nice module builder that allows you to create a new module and relate it to existing modules; such as skill sets and relate it to the accounts module; I quickly found the default templates lacking and wanted to change somethings. An example is adding a JQuery Data grid to a subpanel. I have found bits and pieces but no comprehensive how - to; these are issues that I will share and provide the how-to here.

SugarCRM Tips:
  1. Getting data for a SugarBean Object - SugarCRM modules typically represent Business Objects that read and and write data to the DBMS, the object that represents that data store is the SugarBean, the SugarBean will represent the table in the data store and contains the properties and methods to manage records in the data store; that is it manages the CRUD activities. My requirement was to obtain data for my module from a view. This is done by passing a function to the get_subpanel_data array property in the metadata array in layout_defs metadata file. The function  would be a method available in your bean class inherited from the SugarBean. (got this from cmcassity on the developers forum). This function will return a select query for the datasource.

    Syntax: 'get_subpanel_data' => 'function:get_my_view',
  2.  Using jQuery library with SugarCRM - I wanted to call a web service provided on one of my servers to retrieve data and populate fields in a subpanel. These fields were not editable, when the create button was clicked I would make my web service call, retrieve the data for the field and update the field for the view before displaying the UI. This is done in my sugarbean constructor method for the module.

    As usual info about this could be found in several posts on the forum, the first step was getting the library installed in my SugarCRM instance. The method I chose was to create an include directory under custom and locate the minified jquery file there as follows:
    1. create the folder structure custom/include/jquery    
    2. download the jquery library from here  
      1. http://docs.jquery.com/Downloading_jQuery#Current_Release
    3. copy the downloaded jquery library to the folder
    4. put an includes section in the templateMeta section of your editviewdefs.php or other metadata file as follows:
      1. 'includes' =>
              array (
                0 =>
                array (
                  'file' => 'custom/includes/jquery/jquery-1.4.2.min.js',
                ),
              ),
    5. Use as desired in your javascript snippets 
  3. Accessing Related Beans  - I needed to access the email address of the parent bean (a contact object) from my derived SugarBean. As usual digging through the forums and online docs I found get_linked_beans as a method of the SugarBean object. This method returns an array of beans related to the current bean. The call syntax is a sfollows:
    1. $l_linked_mods = $this->get_linked_beans('tsp_portal_resource_tsp_client','tsp_client'); where 
      1. 'tsp_portal_resource_tsp_client' is the relationship name from './custom/modules/tsp_portal_resource/Ext/Vardefs/vardefs.ext.php' and 
      2. 'tsp_client' is the parent module name 
    2. This returned an array of related beans (1 in my case) and I was able to reference the parent field as $l_linked_mods[0]->email1

1 comment:

  1. Can you provide an example of the jquery usage?

    ReplyDelete