Results 1 to 8 of 8

Thread: Code snippets

  1. #1
    eitrix's Avatar
    eitrix is offline Sugar Community Member
    Join Date
    Aug 2010
    Location
    Serbia
    Posts
    396

    Lightbulb Code snippets

    Hello everyone,

    since we all love out sugar so much, i would like to propose a topic for sharing well documented code snippets. I have been on forums some time now and i am really disappointed by the organisation and how much effort is putted into this. All interested developers are welcome to submit either here in post or contact me throe my website www.eontek.rs or on private here to exchange email/s, with the code snippet and i will wrap it up and post it here so everyone can understand.

    I will also be deploying to community later on the package of code snippets if idea works out.

    Please follow these guide lines:

    -What we want to achieve
    -Is it upgrade safe
    -Correct path and name of file needed to be changed
    -Pass detailed code snipped with comments of changes and what they actualy do
    -limitations if any

    Please keep this topic organised and don't post help requests. There are forums for that
    CRM Software Engineer
    Eontek - www.eontek.rs

  2. #2
    eitrix's Avatar
    eitrix is offline Sugar Community Member
    Join Date
    Aug 2010
    Location
    Serbia
    Posts
    396

    Cool Re: Code snippets

    Code:
    Goal: make a field in subpanel clickable, to show detailview of that record
    Upgradesafe: Yes
    Files: copy /modules/module_that_is_subpanel/metadata/subpanels/delaut.php to /custom/modules/module_name/metadata/subpanels/default.php
    Add following code to the field you want to be clickable
    PHP Code:
    // sometimes adding 'link' => true works also
    'widget_class' => 'SubPanelDetailViewLink',
    'module' => '<Add Module name here>'
    posted also on http://www.eontek.rs/?p=203
    CRM Software Engineer
    Eontek - www.eontek.rs

  3. #3
    gunni is offline Sugar Community Member
    Join Date
    Aug 2006
    Location
    Cologne, Germany
    Posts
    364

    Default Re: Code snippets

    Make data for custom modules importable (Sugar 5.2), replace <Module Name> with your module name:

    modules/<Module Name>/<Module Name>.php:

    PHP Code:
    class <Module Name> extends <Module Name>_sugar {
    // add this line:
    var $importable true
    Create file with random name in folder: "custom\Extension\modules\<Module Name>\Ext\Menus":

    PHP Code:
    <?php

    if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');

    if(
    ACLController::checkAccess('<Module Name>''import'true)) $module_menu[]=Array("index.php?module=Import&action=Step1&import_module=<Module Name>&return_module=<Module Name>&return_action=index""Import","Import"'<Module Name>');

    ?>

  4. #4
    eitrix's Avatar
    eitrix is offline Sugar Community Member
    Join Date
    Aug 2010
    Location
    Serbia
    Posts
    396

    Default Re: Code snippets

    SugarCRM 6.0 ent

    Goal: create a new record of any module in logic hook

    Steps: Create a logic hook. In the file where you define the function for logic hook use the following code to replicate making a new object (record) and saving it.

    PHP Code:
    <?php
        
    class CreateCall{

    // function we call in the logic hook definition, for our example i used creating call after making contact
        
    function callManager(&$bean$event$arguments) {
        
        
    // as contact you can create any other object of any other module

    // create a new Call object (represents a record)
            
    $call = new Call();
    // fill in record data
            
    $call->assigned_user_id "1";
            
    $call->assigned_user_name "Administrator";
            
    $call->name "call manager";
            
    $call->direction "Outbound";
            
    $call->status "Planned";
            
    $call->date_start "25/08/2010 18:45";
            
    $call->duration_minutes "15";
    // this values can also be taken from db as well as any other value, just example
            
    $call->team_id "3d6f0dab-6e7d-c801-b2e9-4c73b6226647";
            
    $call->team_name "Administrator";
            
    $call->description "please call your manager and superior and report for work!";
            
    // this is called in the end to save entry, and your new record in Calls will be created with data above
            
    $call->save();

      }

    }

    ?>
    It should be upgrade safe unless of course you want to populate fields in Call that does not exist.

    Posted also on http://www.eontek.rs/?p=214
    Last edited by eitrix; 2010-10-22 at 04:22 PM.
    CRM Software Engineer
    Eontek - www.eontek.rs

  5. #5
    eitrix's Avatar
    eitrix is offline Sugar Community Member
    Join Date
    Aug 2010
    Location
    Serbia
    Posts
    396

    Thumbs up Re: Code snippets

    Work is still in progress and there for,

    I invite you all developers and business leaders, join me up www.eontek.rs as well as forum.eontek.rs to exchange ideas and maybe even start some interesting projects for a better world

    If you like to write maybe you can post and article or two, i am more then willing to register you as contributor on the subjects of development, crm and business.

    Hope to see you around to discuss various topics and make nice developers+business community

    www.eontek.rs
    CRM Software Engineer
    Eontek - www.eontek.rs

  6. #6
    eitrix's Avatar
    eitrix is offline Sugar Community Member
    Join Date
    Aug 2010
    Location
    Serbia
    Posts
    396

    Default Re: Code snippets

    Just wrote, create a custom view for a module. Read mroe here:

    http://www.eontek.rs/sugarcrm/creati...garcrm-module/
    CRM Software Engineer
    Eontek - www.eontek.rs

  7. #7
    sts's Avatar
    sts
    sts is offline Sugar Community Member
    Join Date
    Aug 2010
    Posts
    977

    Default Re: Code snippets ('Creating custom view for SugarCRM module')

    Nice article on 'Creating custom view for SugarCRM module'. It works well with my 6.0.1 installation.

    Two things to add:

    1st) Menu.php: The added line needs an additional module-name-parameter at the end:
    if(ACLController::checkAccess('semi_Metadatas', 'edit', true)) $module_menu[]=Array(
    "index.php?module=semi_Metadatas&action=semi_Admin isterMetadata", "Administer metadata",
    "Createsemi_Metadatas", "semi_Metadatas");

    2nd) The system needs a small icon image named "Createsemi_Metadatas.gif" which has to be placed in the custom/themes/default/images directory. Otherwise you get an error in the logfile, e.g.:
    11/10/10 14:59:28 [3072][1][WARN] Image Createsemi_Metadatas.gif not found

    Btw: It would be great if you could add the information to your articles on which SugarCRM version you have tested the code snippets.
    Stefan Ulrich Sauer
    System Analyst

    Devoteam Danet GmbH
    Gutenbergstraße 10
    D-64331 Weiterstadt
    Germany
    email: Stefan-Ulrich.Sauer@devoteam.com
    http://www.devoteam.de

  8. #8
    eitrix's Avatar
    eitrix is offline Sugar Community Member
    Join Date
    Aug 2010
    Location
    Serbia
    Posts
    396

    Default Re: Code snippets

    thank you for interest, i will for sure add your comment to the post
    CRM Software Engineer
    Eontek - www.eontek.rs

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Add SIC CODE
    By oscar3 in forum Help
    Replies: 2
    Last Post: 2011-09-23, 08:25 AM
  2. Help with code
    By kireol in forum Help
    Replies: 1
    Last Post: 2009-09-08, 10:14 PM
  3. Replies: 0
    Last Post: 2008-07-14, 04:40 PM
  4. Code snippets for SugarCRM webervices
    By harysh in forum Developer Help
    Replies: 19
    Last Post: 2007-12-26, 10:23 PM
  5. Zip code plus 4
    By mrcowtipper in forum General Discussion
    Replies: 2
    Last Post: 2007-05-21, 05:13 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •