Wednesday, 1 October 2014

Reverse the ListView Action buttons.

Greetings from Urdhva Tech!!

Interesting question asked on community forum, would love to share its solution!

Question : Can we do a reversal of ListView Action buttons ?

I have done the code for Accounts module. Change it as per your requirement.

(1) Write the following code into custom/modules/Accounts/views/view.list.php
  if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');   

  require_once('include/MVC/View/views/view.list.php');
  class AccountsViewList extends ViewList {
    public function preDisplay()
    {
      parent::preDisplay();
      require_once('custom/include/ListView/ListViewSmartyAccounts.php');
      $this->lv = new ListViewSmartyAccounts();
    }
  }

(2) Write the following code into custom/include/ListView/ListViewSmartyAccounts.php
  if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');   

  require_once('include/ListView/ListViewSmarty.php');
  class ListViewSmartyAccounts extends ListViewSmarty {
    function buildActionsLink($id = 'actions_link', $location = 'top')
    {
      $link = parent::buildActionsLink();
      $link['buttons'] = array_reverse($link['buttons']);
      return $link;
    }
  }

(3) Refresh the Accounts Listview page and see the effect.



Monday, 22 September 2014

Add field in subpanel through Manifest in SugarCRM7.

Today I came across the requirement in which I have to add the field in subpanel using manifest.

I have "Student" module which is related with the "Subject" module. Subject subpanel is displayed under the "Student" module. I have requirement to add field in "Subject" subpanel through Manifest.

(1) Write the following code into post_install.php.
  function post_install()
  {
    require_once('modules/ModuleBuilder/parsers/ParserFactory.php');

    //Define all the fields for subpanel
    $addFieldsToSubpanel = array(
         'subject_short_code' => array(
            'name' => 'subject_short_code',
            'label' => 'LBL_SUBJECT_SHORT_CODE',
            'enabled' => true,
            'default' => true,
            ),
    );

    $subpanelLayoutFields = array();
    //Loop through all the fields we want to add in subpanel
    foreach ($addFieldsToSubpanel as $key => $field) {
        $subpanelLayoutFields[$key] = $field;
    }
    addField2Subpanel('UT_Student','ut_student_ut_subject',$subpanelLayoutFields);
  }

  /**
   * This function add field into subpanel.
   * @param string $parentModule. Name of the module in which subpanel exist.
   * @param string $subpanelName. Name of the relationship field.
   * @param array $layoutFields. Array of the field(s) defination to include in subpanel.
   * @param string $view. Name of the view, by default it is "listview".
   * @save field in subpanel.
  */
  function addField2Subpanel($parentModule,$subpanelName,$layoutFields,$view='listview')
  {
       echo "Updating subpanel $subpanelName under the $parentModule module.";
       $parser = ParserFactory::getParser($view, $parentModule, null, $subpanelName);

       if (!$parser) {
          $GLOBALS['log']->fatal("No parser found for $module | $view");
       }

       foreach ($layoutFields as $field => $field_def) {
          $parser->_viewdefs['panels'][0]['fields'][] = $field_def;
          echo ("$field field added to $subpanelName subpanel under the $parentModule module.");
       }

       $parser->handleSave(false);
  }


(2) Do "Quick Repair & Rebuild" from admin.

Friday, 27 June 2014

Filter records based on parent module's dropdown field in SugarCRM7.

Filter records based on parent module's dropdown field in SugarCRM7.For example, filter the Contacts module record on the Accounts module's Industry field. Please look at attached screenshot.

(1) create file at custom/Extension/modules/Contacts/Ext/Vardefs/accountIndustryType.php and write the following code into it.

$dictionary['Contact']['fields']['account_industry_type'] = array (
'name' => 'account_industry_type',
'source'=>'non-db',
'massupdate' => false,
'type' =>'enum',
'options' => 'industry_dom'
);

(2) Write the following code into custom\modules\Contacts\language\en_us.lang.php

$mod_strings['LBL_ACCOUNT_INDUSTRY_TYPE'] = 'Account Industry Type';

(3) write the following code into fields array of custom/modules/Contacts/clients/base/filters/default/default.php file
'account_industry_type' => array (
'dbFields' =>
array (
0 => 'accounts.industry',
),
'type' => 'enum',
'vname' => 'LBL_ACCOUNT_INDUSTRY_TYPE',
),

(4) Do "Quick Repair and Rebuild".

(5) Open Contacts ListView and search on Accounts Industry Type.




Wednesday, 11 June 2014

Disable duplicate check on fields in Sugarcrm 7

Out of some requirements and many requests on forum about how to Disable duplicate check on fields while saving the record.


Lets look at the scenario of what we are trying to achieve. For an example we are taking Contacts module and removing its "First Name" and "Last Name" field from duplicate check.

If you go to the Vardefs file you will see a "duplicate_check" array, within that you need to remove the "first_name" and "Last Name" field from "filter_template" array.
Now lets take a look of how we can do that upgrade-safe way.

Extend the contact's Vardef file at
custom/Extension/modules/Contacts/Ext/Vardefs/duplicate_check_disable.php

And then redefine the "filter_template" array in that. See the below example to get more idea.
This will remove the duplicate check on "First Name" and "Last Name" when you try to save contact's record.
<?php
$dictionary['Contact']['duplicate_check']['FilterDuplicateCheck']['filter_template'] =
array(
    array(
        '$and' => array(
           // array('first_name' => array('$starts' => '$first_name')),
            // array('last_name' => array('$starts' => '$last_name')),
            array('accounts.id' => array('$equals' => '$account_id')),
            array('dnb_principal_id' => array('$equals' => '$dnb_principal_id')),
        )
    ),
);
?>

After this changes go to Admin -> Repair and perform "Quick Repair and Rebuild". Go back and try saving contact records and check for the duplicates on First Name.

We hope this blog has helped you to some extent. Feel free to ask question or get back to us.

 

Friday, 6 June 2014

How to add Subpanel top button on SugarCRM 7

This blog will explain in detail how to add a button on Subpanel in SugarCRM 7. We will be adding a “Add Exams” button on Exams Subpanel (Custom module) of Contact detail view.



We will require to extend the View “panel-top” for the module on which you want to add subpanel top button. Create a file at following path  
custom/modules/UT_Exams/clients/base/views/panel-top-for-contacts/panel-top-for-contacts.php

Copy the code from clients/base/views/panel-top/panel-top.php and paste into panel-top-for-contacts.php file the we just created.

Add the following code in the button array of panel-top-for-contacts.php file.

array(
    'type' => 'examforcontacts',
    'name' => 'select_exam_button',
    'label' => 'LBL_ADD_EXAM',
),


Create the label in custom/include/language/en_us.lang.php and write the following code into it.
$app_strings['LBL_ADD_EXAM'] = "Add Exams";

We will require to create a field type named as  “examforcontacts”.  For that create custom/clients/base/fields/examforcontacts/examforcontacts.js file and write the logic there for the behavior of the button. For reference you may check the subpanel (Accounts,Contacts etc...) under "Target Lists" module, there is "Select from Reports" button.

Perform "Quick Repair and Rebuild" from Admin -> Repair. And remove browser's cache.

Refresh the Contact’s Detailview and check the subpanel for the button to appear.

Sunday, 2 March 2014

Head bang series (iii)

Greetings from Urdhva Tech!!

Are you catching up with us with this series? If not, here you go with archive of the series.

Bangggg (i)

Bangggg (ii)

Lets check out a new bang! This time its "Developer's head" which banged badly (This is from the issue I faced on fine Monday morning today!!)


I was working on Project X - just logged in - so was on Home page. Suddenly had to move to Project Y and to my regular practice, I opened a new tab and logged myself in on other SugarCRM - all was good.

As soon as I hit any of the links, I was getting kicked out! And that happened for quite sometime till the time I concentrated on why it was actually happening!

The issue was - Project X - Home screen - having auto refresh dashlets!!
Each time the dashlet got refreshed and found no active sessions, it killed session of Project Y's session and kicking me out from other project!

Solution - close Project X's Home screen tab! :P

If you ever had such issue, leave comment below with the expression you had on your face and what was your next move!

For me, I had head bang, yeah, with an evil laugh!!

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