Quantcast
Channel: Urdhva Tech | SugarCRM and SuiteCRM Customization and Development
Viewing all 66 articles
Browse latest View live

Mark a field Required conditionally

$
0
0
Greetings!

To Do: On my custom module "UT_Blogs" I will mark "Description" field required if status of My Blog Post is Publish.

Step 1: Check if you have a file named view.edit.php under custom/modules/<desired_module>/views folder.

  • If you have, skip to Step 2.
  • If you do not have, like me, follow..

Check if you have a file named view.edit.php under modules/<desired_module>/views folder.

  • If you have, copy that file and paste under custom/modules/<desired_module>/views folder and skip to Step 2.
  • If you do not have it, create a file named view.edit.php under custom/modules/<desired_module>/views folder.
Step 2: Write following code in that file.

    <?php

    require_once('include/MVC/View/views/view.edit.php');
    /*
     * replace UT_Blogs with the module your are dealing with
     */

    class UT_BlogsViewEdit extends ViewEdit {

        public function __construct() {
            parent::ViewEdit();
            $this->useForSubpanel = true; // this variable specifies that these changes should work for subpanel
            $this->useModuleQuickCreateTemplate = true; // quick create template too
        }

        function display() {
           
            global $mod_strings;
            //JS to make field mendatory
            $jsscript = <<<EOQ
                       <script>
                           // Change blog_status_c to the field of your module
                           $('#blog_status_c').change(function() {
                                makerequired(); // onchange call function to mark the field required
                           });
                         function makerequired()
                         {
                            var status = $('#blog_status_c').val(); // get current value of the field
                             if(status == 'Publish'){ // check if it matches the condition: if true,
                                    addToValidate('EditView','description','varchar',true,'{$mod_strings['LBL_DESCRIPTION']}');    // mark Description field required
                                    $('#description_label').html('{$mod_strings['LBL_DESCRIPTION']}: <font color="red">*</font>'); // with red * sign next to label
                                }
                                else{
                                    removeFromValidate('EditView','description');                        // else remove the validtion applied
                                    $('#description_label').html('{$mod_strings['LBL_DESCRIPTION']}: '); // and give the normal label back
                                }
                        }
                        makerequired(); //Call at onload while editing a Published blog record
                    </script>
    EOQ;
            parent::display();
            echo $jsscript;     //echo the script
        }

    }

    Read the comments in code carefully and replace the variables as asked.

    P.S. Here, <desired_module> means the module name you see in the url, for example, Contacts, Leads, UT_Blogs, etc.

    You may find the field names and its labels in Admin > Studio > <Your_module> > Fields > <Choose correct field> > Take Field Name and System Label.


    Here is a special mention about custom module: if you have a custom module, we prefer to create/change the file under modules/<my_custom_module>/views


    Step 3: Done! Refresh the page and start testing.



    Before
    After

        Works with 6.5+ Versions as here we have used jQuery, but can easily changed to work with just Javascript for < 6.5 versions. Compatible with all SugarCRM flavors.

    Hide Select and Cancel buttons from Relate type fields

    $
    0
    0
    Greetings!

    To Do: Hide select and cancel buttons from relate type field.


    Before
    After

    Step 1: To make it happen, you first need to check if you have a file editviewdefs.php under custom/modules/<Desired_module>/metadata/ if not, go to Admin > Studio > <Desired_module> > Layout > Edit View > and press Save and Deploy.

    Then you will see that  custom/modules/<Desired_module>/metadata/ has editviewdefs.php in it. Open it and search for the field you want to hide those buttons.

    If the field is defined in following manner,

    0 => '<YOUR_FIELD_NAME>',

    Then you need to change it to,

    0 => array('name' => '<YOUR_FIELD_NAME>',
    'displayParams' => array('hide_Buttons' => true,)),

    If your field is already an array like,

    0 =>
              array (
                'name' => '<YOUR_FIELD_NAME>',
                'studio' => 'visible',
                'label' => '<LBL_YOUR_FIELD_NAME>',
    ),

     just add following line in that array

    'displayParams' => array('hide_Buttons' => true,)

    So it should look like following at the end

    0 =>
              array (
                'name' => '<YOUR_FIELD_NAME>',
                'studio' => 'visible',
                'label' => '<LBL_YOUR_FIELD_NAME>',
                'displayParams' => array('hideButtons' => true),
              ),

    Step 2: Go to Admin > Repair > Quick Repair and Rebuild. And done!

    Feel free to leave comments below.

    Create Date time combo manually

    $
    0
    0
    Greetings!

    In a manual page if you want to give a date time combo field, here is the code snippet you'd need on javascript.


    var now = new Date();
            if (now.getMonth() == 11) {
                var currentTime = new Date(now.getFullYear() + 1, 0, 1);
            } else {
                var currentTime = new Date(now.getFullYear(), now.getMonth() + 1, 1);
            }
            var month = currentTime.getMonth() + 1;
            var day = currentTime.getDate();
            var year = currentTime.getFullYear();
            day = day.toString();
            month = month.toString();
         
            if(day.length == '1')
                day = '0' + day;
         
            if(month.length == '1')
                month = '0' + month;
     
        var defaultDate  = month + '/' + day +'/' + year;
        var datetimecombo = '<tr valign="middle"><td width="25%" valign="top" scope="row" id="date_start_label">LABEL_OF_YOUR_FIELD<span class="required">*</span></td><td nowrap=""><input type="text"  tabindex="102" title="" maxlength="10" size="11" value="' + defaultDate +'" name="date_start" id="date_start" autocomplete="off"><img border="0" align="absmiddle" id="date_start_trigger" alt="Enter Date" src="index.php?entryPoint=getImage&themeName='+SUGAR.themes.theme_name+'&imageName=jscalendar.gif""index.php?entryPoint=getImage&themeName='+SUGAR.themes.theme_name+'&imageName=jscalendar.gif">&nbsp;</td><td nowrap=""><div id="date_start_time_section"><select tabindex="102" id="date_start_hours" size="1" class="datetimecombo_time"><option></option><option value="00">00</option><option value="01">01</option><option value="02">02</option><option value="03">03</option><option value="04">04</option><option value="05">05</option><option value="06">06</option><option value="07">07</option><option value="08">08</option><option selected="" value="09">09</option><option value="10">10</option><option value="11">11</option><option value="12">12</option><option value="13">13</option><option value="14">14</option><option value="15">15</option><option value="16">16</option><option value="17">17</option><option value="18">18</option><option value="19">19</option><option value="20">20</option><option value="21">21</option><option value="22">22</option><option value="23">23</option></select>&nbsp;:&nbsp;<select onchange tabindex="102" id="date_start_minutes" size="1" class "datetimecombo_time"><option></option><option value="00">00</option><option selected="" value="15">15</option><option value="30">30</option><option value="45">45</option></select></div></td></tr>';

    For now the dropdown is hard coded, but you can get it by > Getting dropdown options in Javascript

    Get current date in logged in user's format by

    var todayDate = new Date();
    var todayDateinUserFormat = todayDate.toLocaleFormat(cal_date_format);
    alert(todayDateinUserFormat);

    Add custom module in Site Map

    $
    0
    0
    Greetings!

    To set custom module in site map, you need to follow some steps.

    Step 1: First, check if you have Menu.php under modules/<YOUR_CUSTOM_MODULE>/

    If no, please add it.

    Step 2: Copy modules/Home/sitemap.tpl in custom/modules/Home/ and following line wherever you want to show your module.

    <div>{$<YOUR_MODULE_NAME_ALL_IN_CAPS>}</div>

    We hereby consider, your custom module is visible in module tab.

    Hope it helps. Feel free to drop your comments below.

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

    $
    0
    0
    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.

    Create Controls, Sugar way!

    $
    0
    0
    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! ;)

    Show message after redirection

    $
    0
    0
    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.

    Dealing with multienums with SugarCRM

    $
    0
    0
    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.

    tagMe

    $
    0
    0



    tagMe


    Overview
    Fed up of remembering important clients? Tag them!

    This plugin allows you to tag your records to identify them instantly!!

    Color coded tags make it even simpler to catch them.

    P.S. Color codes are randomly generated.



    How to install?
    You can find plug-in from https://www.sugaroutfitters.com/addons/tagme

    Install plug-in using Module Loader, Admin > Module Loader.

    After successful installation, the custom field type appears in studio and module builder too.

    P.S. This plug-in does NOT support IE 10. It works with Compatibility mode IE 9.

    P.S. Make sure you create just 1 field of this type in a module.




    Does your sales rep hate to search for important client’s details at last minute?
    Do they complain that they have to read description to determine what note says?



    tagMe at rescue!!




    To narrate the functionality of this plug-in, we have created a field of type “TagMe”.




    Add newly created field into edit, detail and list views. And why not, in subpanel too!


    Edit View & Detail View



    Search By Tags

    In addition to visually identifying tags, you can search for any tag by adding the field to your search forms. When searching simply wrap your search terms with the wild card. A search for "Won" would be entered as "%Won%". All records with that tag will then return.

    List View & Subpanel View




    Look at that face again!!








    •  Satisfied with the plugin? Leave reviews as comments!

    sociaLead

    $
    0
    0




    sociaLead  



    Chromeextension





    Overview
    Adding leads to SugarCRM made super easy. One click captures the contact information from Facebook® or LinkedIn® profiles.

    Find it at
    The extension is available at Chrome extension market.
    Search for sociaLead in chrome web store.
    Or click here





    Configuration


    Sugar URL: http://site_urlwithout index.php
    Sugar User Name: Valid user name of system
    Sugar Password: Valid password of user




    LinkedIn

    Go to users profile and click on sociaLead icon in add-on bar.



    When clicked, it will give you confirmation that the lead was created.



    Facebook

    Go to potential lead’s profile, go to about tab and click on sociaLead icon in add-on bar.

    When clicked, it will give you confirmation that the lead was created.

    Go to SugarCRM to verify if the lead created.



    Voila!





    •  Satisfied with the plugin? Leave reviews as comments!

    meeting Map Reminder

    $
    0
    0

    meeting Map Reminder











    Overview 


    Impress your sales rep by reminding them important meetings planned for the day, with map!! Set up a scheduler and you are sorted! Sales Rep receives an email with map and meeting details.


    How to install?


    Download plug-in from http://www.sugarforge.org/projects/mmr/ from downloads tab.

    Install plug-in using Module Loader, Admin > Module Loader.

    P.S. Assumed you have installed cron job already. 


    Create Scheduler

    After successful installation, go to Admin > Scheduler > Create Scheduler > Select “Meeting map reminder” as Job and set the interval to be when you want to send email to sales representatives. And that’s it!



    Surprise!
     
    Sales representative will receive an email on specified time which you have set in scheduler with map and meeting details.



    SugarCRM REST API example with javascript

    $
    0
    0
    Greetings!

    This blog post explains how to login to SugarCRM instance through javascript

    Let's have an example of REST API through JavaScript.


    Create an html file to include javascript, We will require jquery. Provide correct Javascript path in HTML file
    <ANYNAME>.html


    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
    <html lang='en'>
        <head>
            <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
            <title>SugaRCRM REST API Example through Javascript</title>
            <script src='jquery.js'></script>
            <script src='rest.js'></script>
         </head>
    </script>
        </head>
        <body >
            <div class="hd">SugaRCRM REST API Example through Javascript</div>
        </body>
    </html>



    Now create a rest.js


    var api_url = "<SUGAR_URL>/service/v2/rest.php";
    var user_name = '<USERNAME>';    //SugarCRM username
    var password = '<PASSWORD>';    //SugarCRM password

    var params = {
        user_auth:{
            user_name:user_name,
            password:password,
            encryption:'PLAIN'
        },
        application: 'SugarCRM RestAPI Example'
    };
    var json = JSON.stringify(params);
    $.ajax({
            url: api_url,
            type: "POST",
            data: { method: "login", input_type: "JSON", response_type: "JSON", rest_data: json },
            dataType: "json",
            success: function(result) {
                 if(result.id) {
                        //HERE: you will have out put from rest
                    alert("sucessfully LOGIN Your session ID is : " + result.id);
                 }
                 else
                     alert("Error");
                  
            },
            error: function(result) {
               alert("Error");
            }
    });


    On success you will get response of login method, successful or failure.

    Accessing PHP variable in .tpl

    $
    0
    0
    Greetings!

    Sometimes situation may arise when you want some PHP code in tpl. Following piece of code will show how to achieve this.

    {php}
        global $current_user;
        $this->_tpl_vars['current_user_email'] = $current_user->email1;
    {/php}

    Now use 'current_user_email' variable as follows in tpl.

    <input type="text" id = "current_user_email" name="current_user_email" value='{$current_user_email}'>

    Hope it helps.

    Feel free to leave your comments.

    Urdhva Tech web goes Live!!

    $
    0
    0






    And the day arrived when we got our web live! It feels great when your hard work turns into jewel!

    We are best-in-class SugarCRM services provider to SME(s). Think of anything related to CRM system and you will have it when you reach us at contact@urdhva-tech.com! Your vision becomes our aim.

    We are simple. Our aim is simple. We want to impress you. So we listen. We research your industry, your competitors and your market. We make sure we understand your unique challenges and pressures. And then we bring our expertise to the table, designing and delivering compelling, first-class solutions that meet your specific requirements.

    We have been into SugarCRM consulting industry since year 2008.

    We offer,
        >> Installation and configuration
        >> SugarCRM Consulting
        >> Customization of modules and layouts
        >> Implementation of new features
        >> Custom module development
        >> Custom reports development
        >> Integration with other applications
        >> Migration of data from other systems
        >> Support & maintenance

        We started with our professional name, David Boris, and its now so renowned that people call us David! We want to continue with that, and why not?

        We have been listed many times under SugarCRM's official developer blog.


        It is satisfying when our contribution towards SugarCRM community of developers around the globe gets noticed through SugarCRM's official Forum.

        We feel honored when we see how SugarCRM users love our work and contribution on Sugar Forge.
        And it was a privilege when we got listed on SugarOutFitters with our 2 promising add-ons.

        >>> Dynamic Dropdown - Specially for admins
        >>> Not followed opportunities v2 - Not to miss out any Opportunities unattended
        >>> sociaLead - Grab contact details of Leads from social media like Facebook and LinkedIn, a chrome extension
        >>> tagMe - Give tags to Contacts/Leads/any module and easily identify records (Commercial)
        >>> Meeting Map Reminder - Users get Meeting details(Free) everyday with Map and directions (Commercial)

        Feel free to contact us at contact@urdhva-tech.com or Hire us at Elance, CrossLoop!

        Check list to send Email Campaigns from SugarCRM

        $
        0
        0
        Greetings from Urdhva Tech!


        Today I came across very famous head scratching issue of "Email Campaigns sent out from SugarCRM Not working!!"

        Once I did it for a client and did a smart save of the steps I performed! Voila!!

        Check 1 : You have to set up Campaign email from Campaigns > Set up Email. It will take a little time to test the configuration. (Not from Admin panel)

        Check 2 : You need to confirm whether the cron job is set up correctly on server and running timely.

        Check 3 : You should have valid Campaign, which has status = Active, Type = Email. Campaign should have Email marketing set up(It has to set up exactly at hours you want to send email at) for the targeted Target List.

        Check 4 : Target List should not be of type "Test".

        Check 5 : Go to Campaign and Press Send Emails. And follow till end, which will queue up emails and then cron job will do the task.

        Drop comments, they are precious for us!

        Follow us on twitter: @Urdhvatech

        Contact us at contact@urdhva-tech.com for any services related to SugarCRM.

        Get date plus or minus today

        $
        0
        0
        Greetings from Urdhva Tech!!

        Several times I have came across same requirement of getting few days back from today, or few days after today. SugarCRM comes with few very handy date utility functions, and there is one which does the job!

        global $timedate;
        $today = $timedate->getInstance()->nowDbDate(); // Today
        $earlier = $timedate->asDbDate($timedate->getNow()->modify("-30 days")); // 30 days before!
        $later = $timedate->asDbDate($timedate->getNow()->modify("+2 months")); // 2 months later!

        echo "Today:".$today;
        echo "<br />30 days before:".$earlier;
        echo "<br />2 months later:".$later;

        Simple! Isn't it?

        Take a look at include/TimeDate.php for many other suitable date time functions.

        Comments are welcome!

        Follow us on Twitter @urdhvatech

        Glimpse of our plug-ins & products.

        Adding custom fields in edit and detail view through manifest

        $
        0
        0
        Greetings from Urdhva Tech!!

        Creating your own plug-in for SugarCRM? Have custom fields in SugarCRM's existing/OOB modules?

        Yes manifest has a directive which does this job!

        'layoutfields' => array(
                array(
                    'additional_fields' =>
                    array(
                        'Contacts' => '<field_name>'
                    ),
                ),
                array(
                    'additional_fields' =>
                    array(
                        'Accounts' => '
        <field_name>'
                    ),
                ),
                array(
                    'additional_fields' =>
                    array(
                        '<module_name>' => '<field_name>'
                    ),
                ),
            ),

        Done!

        Some issues exist, like, SugarCRM forces the field to be on both views, edit and detail. And no way you can add field in list view, except you create your own script which does it for you in post_install.

        Comments are welcome!

        Follow us on Twitter @urdhvatech

        Glimpse of our plug-ins & products.

        Calls subpanel under Task module

        $
        0
        0
        Greetings from Urdhva Tech!

        Yet another interesting forum post led me dive into code base!

        Aim: Calls subpanel under Task module.

        2 files makes difference!

        Step 1:  Create extended vardef for Tasks module > custom/Extension/modules/Tasks/Ext/Vardefs/calls_subpanel.php add following code in it.

        <?php
        $dictionary['Task']['fields']['calls'] = array(
            
        'name' => 'calls',
            
        'type' => 'link',
            
        'relationship' => 'tasks_calls',
            
        'module' => 'Calls',
            
        'bean_name' => 'Call',
            
        'source' => 'non-db',
            
        'vname' => 'LBL_CALLS',
        );


        $dictionary['Task']['relationships']['tasks_calls'] = array('lhs_module' => 'Tasks''lhs_table' => 'tasks''lhs_key' => 'id',
            
        'rhs_module' => 'Calls''rhs_table' => 'calls''rhs_key' => 'parent_id',
            
        'relationship_type' => 'one-to-many''relationship_role_column' => 'parent_type',
            
        'relationship_role_column_value' => 'Tasks'); 

        Step 2: Create a file under > custom/Extension/modules/Tasks/Ext/Layoutdefs/calls_subpanel.php
        and add following code.

        <?php
        $layout_defs['Tasks']['subpanel_setup']['calls'] = array(
                        
        'order' => 10,
                        
        'module' => 'Calls',
                        
        'title_key' => 'LBL_CALLS',
                        
        'subpanel_name' => 'default',
                        
        'get_subpanel_data' => 'calls',
                    
        'top_buttons' => array(
                        array(
        'widget_class' => 'SubPanelTopCreateButton'),
                    ),
                    );  

        Quick Repair and Rebuild!

        Awesome!!

        Comments are welcome!

        Follow us on Twitter @urdhvatech

        Glimpse of our plug-ins & products.

        tagMe 1.1 version is out now!

        $
        0
        0
        Greetings from Urdhva Tech!

        tagMe grows up!

        You can now import tags along with your normal imports of data into SugarCRM.

        For example, you are importing few accounts into system, you just need to add a column in your excel sheet/CSV, add comma(,) seperated values of desired tags and map the column with your custom tag field!

        Happy tagging!!

        Follow us on Twitter @urdhvatech

        Glimpse of our plug-ins & products.

        tagMe v2 arrived!

        $
        0
        0
        Greetings from Urdhva Tech!

            Announcing tagMe v2's grand launch!

        We, at Urdhva Tech, happy to introduce exciting new features to enhance your tagMe + SugarCRM experience.

        Organizing data made easy! tagMe v2 comes with some really useful features, such as,

        > Mass update add or replace tags
        > Tag Cloud
        > Search data by tags globally from Dashlet
        > Search data by tags module wise from Detail View

        For more information visit Urdhva Tech Tag Management

          Happy Tagging!!

        Viewing all 66 articles
        Browse latest View live