Wednesday, 30 January 2013

Make field Importable Required

How to make importable required in custom field
It will be done by one step only! You need to extend vardefs to make importable required.
Let's see how

To extend vardefs we need to create a file.

custom/Extension/modules/<module_name>/Ext/Vardefs/<anyname>.php

<?php
$dictionary["<MODULE_OBJECT_NAME>"]["fields"]["<FIELD_NAME>"]["importable"]='required';

Now go to Admin > Repair > Quick Repair and Rebuild. 
You are done!

Feel free to leave comments.

Export Workflows (PRO+)

At times it happens to developers that they create workflows on their working copy and find it difficult to export to client's copy.

Workflows are managed by files and entries in database tables.

Files can be found at

custom/modules/<module_name>/workflow


and database table entries to export are

expressions
workflow
workflow_actions
workflow_actionshells
workflow_alerts
workflow_alertshells
workflow_triggershells


If you have created workflow email template then filter records in table email_templates where type = workflow and point out which template you just created for the workflow.

Hope these instructions are useful for developers out there!

Feel free to leave comments.

Monday, 14 January 2013

Filter by related module's field

At times we have clients asking for similar requirement, that they want to filter results by related module's field.

Lets take basic modules and achieve similar goal by coding. Here, one needs to have idea about creating basic mysql query.

We have Accounts and Contacts module in SugarCRM. Accounts has one-many relationship with Contacts. We will add Accounts module's type field in Contacts search.


Create non-db field in Contacts module named as account_type_search. Write following code into custom/Extensions/modules/Contacts/Ext/Vardefs/<anyname>.php

<?php
 $dictionary["Contact"]["fields"]["account_type_search"]= array(
   'name' => 'account_type_search',
   'vname' => 'LBL_ACCOUNT_TYPE_SEARCH',
   'query_type' => 'default',
   'source' => 'non-db',
   'type' => 'enum',
   'options' => 'account_type_dom',
   'studio' => array('searchview'=>true,'visible'=>false),
);

Write following code into search field definition. Copy modules/Contacts/metadata/SearchFields.php to custom/modules/Contacts/metadata/SearchFields.php if doesn't exist and write following code into it. If it exists at custom/modules/Contacts/metadata/SearchFields.php then add following code with <?php.

'account_type_search' => array (
            'db_field' =>
            array (
              0 => 'id',
            ),
            'query_type' => 'format',
            'operator' => 'subquery',
            'subquery' => 'SELECT accounts_contacts.contact_id FROM accounts_contacts
                           INNER JOIN accounts ON accounts.id = accounts_contacts.account_id AND accounts.deleted = 0
                           WHERE accounts_contacts.deleted = 0 AND accounts.account_type IN ({0})',
        ),


Create custom/modules/Contacts/metadata/metafiles.php and write following code into it. If it exists at custom/modules/Contacts/metadata/metafiles.php, then do changes as per your needs.


<?php
$metafiles['Contacts']['searchfields']='custom/modules/Contacts/metadata/SearchFields.php';

Add account_type_search field for searching into custom/modules/Contacts/metadata/searchdefs.php through studio.

Do "Quick Repair And Rebuild" from admin.

And voila!

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