Go Back   SugarCRM Forums > Community Forums > Developer Help
User Name
Password
 Create an account


Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 06-11-2008, 11:58 AM
clint's Avatar
clint clint is offline
Sugar Team Member | Forums Lead Moderator
 
Join Date: Aug 2004
Location: Silicon Valley
Posts: 1,656
Default Enabling import on a custom module in Sugar 5.0

For those of you working with Sugar 5.0, attached is a sample module where I enabled the import function.

Unzip the package and take a look at the contents. The EnableImport directory is where I put the necessary code to enable the import function.

Required Files


  1. EnableImport\menus\Import_zz_Work.php - This file is used by the manifest.php to add the Import item to the Work module's shortcuts menu.
  2. EnableImport\modules\Import\config.php - This file registers the Work module (zz_Work) as a module that can be imported.

    NOTE:
    This is the one out-of-the-box file that you must modify which means this change is not upgrade-safe. You will need to manually merge the one-line change in this file back into your code when ever you do upgrades in the future.
  3. EnableImport\modules\Import\Importzz_Work.php - Contains the logic for actually doing the import. If you need to do any special logic (data manipulation, creating special relationships, etc), you will create special functions in this file that get executed at import.
  4. EnableImport\modules\zz_Work\field_arrays.php - This file is necessary but unfortunately a relic from the past. Up until Sugar 5.1, the Import module does not use the standard vardefs for defining a module's required fields but rather keys off of this field_arrays.php file that we used back in Sugar 1.0 and 2.0. So you will need to register all of your module's required fields in this file otherwise your import will fail. Thankfully Sugar 5.1 finally puts this dependency to rest.
  5. EnableImport\modules\zz_Work\Import.php - This file actually calls the Import module code when you click on the Import button.
On a final note, be sure to take a look through the manifest.php file for this package to see how I modified it to install these required files.
Attached Files
File Type: zip SampleModule_IncludesImport_v2.zip (53.1 KB, 33 views)
__________________
Sugar Developer Zone - developer resources | Sugar University - user and admin training
Sugar Wiki - developer and admin knowledgebase | Sugar Docs - user and admin documentation
SugarForge- open source modules, themes, lang packs | SugarExchange
- commercial extensions
Sugar Bug Tracker - Enter or view bugs

Clint Oram, SugarCRM Co-Founder
Open Source Community Relations

Last edited by clint : 07-21-2008 at 09:51 PM. Reason: uploaded new version of sample module with small fix
Reply With Quote
  #2  
Old 06-11-2008, 05:17 PM
DragonflyMaster DragonflyMaster is offline
A Sugar Hero
 
Join Date: Dec 2007
Location: Rimini, Italy
Posts: 1,182
Default Re: Enabling import on a custom module in Sugar 5.0

Thank you Clint! I'll look at the code tonight or tomorrow and I'll try to adapt it to my modules
__________________
What do you think the cookie monster eats ?
Reply With Quote
  #3  
Old 06-18-2008, 03:15 AM
URtech URtech is offline
Member
 
Join Date: Oct 2006
Posts: 10
Default Re: Enabling import on a custom module in Sugar 5.0

Clint, this is awesome! I'm going to try it out immediately. I'm so thankful you've put this together!

Cheers, Sean
Reply With Quote
The Sugar Developer Wiki contains valuable information on customizing, scaling, and configuring your Sugar installation.

  #4  
Old 06-18-2008, 07:15 AM
URtech URtech is offline
Member
 
Join Date: Oct 2006
Posts: 10
Default Re: Enabling import on a custom module in Sugar 5.0

Hi Clint,

I followed all your instructions. I wasn't totally sure about how to complete the field_arrays.php file declarations based on the file you provided didn't appear to match with the zz_Work syntax. In any case, I can now see the "Import" in the menu on my custom module, but when I click it, I get a blank area under "Import Step 1: Select the source" where I'd normally see the options to choose the format to upload.

Any thoughts on why that would happen or what I might be missing?

Thanks!
Cheers, Sean
Reply With Quote
  #5  
Old 06-18-2008, 08:26 AM
clint's Avatar
clint clint is offline
Sugar Team Member | Forums Lead Moderator
 
Join Date: Aug 2004
Location: Silicon Valley
Posts: 1,656
Default Re: Enabling import on a custom module in Sugar 5.0

Quote:
Originally Posted by URtech
I followed all your instructions. I wasn't totally sure about how to complete the field_arrays.php file declarations based on the file you provided didn't appear to match with the zz_Work syntax. In any case, I can now see the "Import" in the menu on my custom module, but when I click it, I get a blank area under "Import Step 1: Select the source" where I'd normally see the options to choose the format to upload.
So let's step through this.

Menu Item
When you install the zz_Work sample module, the Module Loader creates a menu item file based on the entries in manifest file. Specifically the custom/Extension/modules/zz_Work/Ext/Menus/Work.php file gets created. When you run Quick Repair, this file generates your menu entry in your mdoule. So you need a comparable file for your custom module.

Since you have a menu item, it sounds like this is covered.


Import.php in your custom module directory
As you see in the sample module, we install a file called modules/zz_Work/Import.php. This file is necessary to redirect from the zz_Work module to the Import module and carry the zz_Work module reference along with it.

Since you are seeing the Import module when you click on the menu item, it sounds like you have the proper Import.php file in your custom module directory.

Import config.php
Have you modified the modules/Import/config.php file to register your module in the $import_bean_map[] array? It needs to point to the prefix for the file that will do the actuall import logic.

For example in the zz_Work sample module, you will see in the modules/Import/config.php file on line 54 that I added the following:
PHP Code:
 ,'zz_Work' => 'Importzz_Work' 


The syntax here is very important. The array entry key "zz_Work" (left side) has to match the module name (not the bean name, but the module name). The array entry value "Importzz_Work" (right side) has to match the file prefix for the new file you will create that contains the actual import logic for your new module. In this case, Importzz_Work maps to the modules/Import/Importzz_Work.php file.

My guess is that you have either not properly registered the new modle in the $import_bean_map[] array or your have not created the modules/Import/Import<your_module>.php file.
__________________
Sugar Developer Zone - developer resources | Sugar University - user and admin training
Sugar Wiki - developer and admin knowledgebase | Sugar Docs - user and admin documentation
SugarForge- open source modules, themes, lang packs | SugarExchange
- commercial extensions
Sugar Bug Tracker - Enter or view bugs

Clint Oram, SugarCRM Co-Founder
Open Source Community Relations
Reply With Quote
  #6  
Old 06-18-2008, 07:06 PM
URtech URtech is offline
Member
 
Join Date: Oct 2006
Posts: 10
Default Re: Enabling import on a custom module in Sugar 5.0

HI Clint,

I just double-checked each of the things you mentioned and no luck. I'm attaching the zip here and would appreciate if you could take a quick look.

Thanks!
Cheers, Sean
Attached Files
File Type: zip Institutions.zip (45.6 KB, 33 views)
Reply With Quote
For descriptions of the various Sugar editions (Community, Professional and Enterprise), please visit this page or listen to this podcast.

  #7  
Old 06-20-2008, 10:40 AM
clint's Avatar
clint clint is offline
Sugar Team Member | Forums Lead Moderator
 
Join Date: Aug 2004
Location: Silicon Valley
Posts: 1,656
Default Re: Enabling import on a custom module in Sugar 5.0

Hi Sean -

I suggest turning on php error notices in your development instance. When I clicked on Import in your Institutions module, I get the following php error:

Fatal error: Cannot redeclare ImportURMOD_Institutions::$related_modules in C:\Inetpub\wwwroot\sugarpro\modules\Import\ImportU RMOD_Institutions.php on line 63

Once I commented out line 63 in your file, the import screen appeared properly.


Best,
Clint
__________________
Sugar Developer Zone - developer resources | Sugar University - user and admin training
Sugar Wiki - developer and admin knowledgebase | Sugar Docs - user and admin documentation
SugarForge- open source modules, themes, lang packs | SugarExchange
- commercial extensions
Sugar Bug Tracker - Enter or view bugs

Clint Oram, SugarCRM Co-Founder
Open Source Community Relations
Reply With Quote
  #8  
Old 06-20-2008, 06:18 PM
URtech URtech is offline
Member
 
Join Date: Oct 2006
Posts: 10
Default Re: Enabling import on a custom module in Sugar 5.0

Thanks Clint! I had actually just now figured that syntax error out and have a simple test working. I appreciate the php error logging reminder. Thanks again for this "how to" and for the thoughtful follow up.

Cheers, Sean
Reply With Quote
  #9  
Old 06-26-2008, 07:19 PM
nckman nckman is offline
Junior Member
 
Join Date: Nov 2006
Location: Huntersville, NC
Posts: 3
Default Re: Enabling import on a custom module in Sugar 5.0

Are there resources that might help to install this? I'm converting from Salesforce and have several custom modules / data that need to be imported. Outside of this tool, are there any other recommendations on how to import to a custom module?
Reply With Quote
Developers- check out our new developer website, filled with tutorials, code samples, and lots of links to useful information.

  #10  
Old 06-27-2008, 07:28 AM
sanjeev1225 sanjeev1225 is offline
Senior Member
 
Join Date: May 2008
Posts: 60
Default Re: Enabling import on a custom module in Sugar 5.0

Hi clint


I download the u r zip file and i installed through module loader .I got a another tab name Work .

when i create a wrok in that module all the button like save ,cancel are not working

and in shorcuts work icon was error image showing .I don't know that much of knowledge of this works module.Will u plz explain the feautures of this perticular module compare with other.

Iam using SugarCE-Full-5.0.0b

Thanks in Advance
Attached Images
 
__________________
Sanjeev Thummala
E-Mail :sanjeev_1225@yahoo.com
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Import custom field structure in 5.0? spectheintro Help 2 01-23-2008 02:30 PM
Import into Custom Module zemon Developer Help 6 05-29-2007 05:17 AM
Custom Sugar Module Work Requested anderscliqk Classifieds 2 12-22-2006 06:31 PM
After running repair custom fields in 4.5GA data missing dseaton Help 1 09-11-2006 03:38 PM
Asterisk Patch 1.1.0 Crash on logon skyracer Help 6 07-08-2006 06:30 AM


All times are GMT. The time now is 01:38 AM.

Powered by: vBulletin
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SourceForge.net Logo