October 27, 2008

Simple Create Defect Button in SugarCRM

Helix ALM

Works with TestTrack 2008

Works with SugarCRM 5.1

This article includes the steps to add a simple Create Defect button to your SugarCRM interface, which will automatically generate a defect in TestTrack.

[toc]

Overview

This integration requires that you modify core files in the Cases module of your SugarCRM installation. Doing so incorrectly can render SugarCRM unusable, which will almost certainly upset a lot of the people you work with. Please be careful!You'll need:
  • Your TestTrack Web server to be accessible from the SugarCRM deployment.
  • The path to your TestTrack Web server installation. If you're familiar with how web servers work and your IT environment, you can probably guess this. If not, ask the TestTrack administrator or IT staff for help.
  • A valid TestTrack projed id. This can be obtained from the TestTrack Admin Utility, or by contacting your TestTrack administrator.
  • Necessary permissions & knowledge to customize the back-end source code.
You'll get:
  • A Create Defect button on the Case Detail screen. When clicked, a new defect will be created in TestTrack, populated with information from the case in SugarCRM.
What we'll do:
  • Add a custom button to the Detail view.
  • Associate the button with a custom script we're going to write.
  • Hook the script into your TestTrack Web interface.

Download

The download contains the source files needed for this sample integration. Download the Create Defect Button Source zip file.
  • CreateTTDefect.php - Custom script that handled creating the defect in TTP, called when the custom button is clicked.
  • detailviewdefs.php - SugarCRM core source code that defines the Cases Detail view. This is where the button code goes.
  • detailviewdefs.php (DIFF) - Diff file of changes made between default SugarCRM CE v5.1.0a (Build 4837).
  • en_us.lang.php - Language file, with button labels.
  • en_us.lang.php (DIFF) - Diff file of changes made between default SugarCRM CE v5.1.0a (Build 4837).

Add the Button

The first order of business is to add a button to the Case Detail view. This is the dangerous part, where you copy the downloaded code into your SugarCRM installation.
  1. Browse to your SugarCRM installation directory.
  2. Go to ...modulesCases directory.
  3. Copy CreateTTDefect.php into this directory.
  4. Make the necessary changes to detailviewdefs.php in the metadata sub-directory.
  5. Make the necessary changes to en_us.lang.php in the language sub-directory.
Lastly, you need to tell SugarCRM to update the cache. Within the SugarCRM interface, go to Admin > Repair > Quick Repair and Rebuild then select the Cases module and click Repair.

Update CreateTTDefect

Next up, we need to make a couple minor changes to the defect creation script.
  1. Line 7 - Update yourserver with the location of your SugarCRM installation.
  2. Line 13/14 - Update the user/pwd to a SugarCRM account with permissions to login through Soap and pull Case data.
  3. Line 40 - Update yourserver/cgi-bin with the location of your TTP web installation.
  4. Line 40 - Update databaseid=?? with the id of the TTP project you want to insert data to.
    • This project must have SoloSubmit access enabled.

Try it Out!

The only thing left to do is try it out.
  1. Log into your SugarCRM account.
  2. Open the Cases module.
  3. Open a case, and you should see a new button, titled Escalate.

Select the Escalate button, which should trigger the call to SoloSubmit. If everything works as expected, you'll have a new entry in the Case's History panel.

Troubleshooting

I don't see a button on the Detail view

If you don't see a button, then you did something wrong when you added the button. Go back through and double-check that you made the changes exactly as they were made in the downloaded files.

I see the button, but it doesn't have a label

The button should still work, the issue here is a language pack issue. Try clearing some more cache, using the Admin > Repair features. SugarCRM caching can get a little flaky at times.

I click the button and nothing happens

You have an issue with the CreateTTDefect.php. If it's a php issue, you'll typically get an error when you click it. If you don't get an error or a defect, then your problem is in connecting to TTP. To resolve, comment out the header redirect at the bottom of that file and start adding debug statements to see what's happening. Also make sure your URL updates were made correctly, and everything is pointed where it should be.

It works great, how do I customize it further?

If you don't have the time or expertise to do it yourself, Seapine Services can assist with customizations. If you want to try it on your own, be sure to read up on the basics of SoloSubmit URLs along with details on finding the relevant field id's. Note: These instructions are provided as is; Seapine does not provide support for samples.