Sugarcrm Tutorial : How to use ajax with SugarCRM

Hello people, I always ask my self how to embed ajax within sugar, it is to look at an EditView of a contact and to do some action without refreshing the browser. Well, after a little study, I could do it, so I will share it with you how to add ajax in sugar.
I will explain how to add to an EditView a buttom that when we click on it, it executes a php application and bring its content. The invocation to that php file will be using YUI (yahoo user interface). The idea is, when we press the button, it will call an external php that will execute its code and it will get a param from sugar.
First at all, we have to install an exelent module developed by patrizio gelosi named EnhancedStudio, This module adds a new type of field named ‘Code’ field, that will help us to add php code and a lot of things more.
After install this module, we have to add the code field to the editview of contacts module, to do this we have to:
1- Go to Admin->Studio->Contacts->Fields. We have to add a new ‘Code’ field name ‘yui_test’
2- We have to add the following code:
PHP Code:
echo ‘
first_name . ‘”, callback);
}
// –>

this will change…


;
3- After add this content, we must save changes and add this field to the editview of contacts. To do this, we have to go to Contacts->Layout->EditView, search for our new field named “yui_test” and drag it to the template.
4- Finally, we must create the file to be invoked. To do this we must create “my_app.php” within sugarcrm root directory. The content is the following:
PHP Code:
echo “

The contact name is: ” . $_REQUEST['name'] . “

”;
for ($i=0; $i < 5; $i++) {
echo “Hello world! $i
”;
}
echo ‘

width=”400″ height=”500″ scrolling=”auto” frameborder=”1″ transparency> </p> <p>Alternative text for iframe.</p> <p>
‘;
5- Ready! It’s done. We were a little more ambitious, because we passed the name of the contact by GET to our application, our app will show the name of the contact, also will print five ‘hello world’ and finally we will show wikipedia within the contact detail.
With all of this, I wanted to show the potential and ease at time to add code in sugar
If you have any problem with the code, let me know and I’ll try to help you.

Posted by: Expertz Web

0 Responses to “Sugarcrm Tutorial : How to use ajax with SugarCRM”



  1. No Comments Yet

Leave a Reply




RSS web design Company in India

  • Fixed Floating Elements October 23, 2009
    On visiting Apple’s web site an putting items in my shopping basket, I noticed (an old effect) where the shopping basket would follow me down the page. We’ll look at how to replicate the fixed floating sidebars or elements with very little jQuery. Watch Watch jQuery Fixed Floating Elements screencast (Alternative flash version) QuickTime version […]
  • Huge Books Giveaway: Comment and Win! October 19, 2009
    We are giving away 14 Web design-related books to the Noupe Community. The winners will be selected randomly among all commenters to this post
  • 55 Adobe Illustrator Icon Design Tutorials October 6, 2009
    By Paul Andrew Every graphic designer will end up, at some point, with a client who needs an icon designed. Going into the project, your first idea would be to use your experience, training and creativity and dive straight into the project gung-ho. In some occasions, doing this could be disastrous.
  • Noupe Has A New Owner: Smashing Magazine October 1, 2009
    Today, I have some very big news at Noupe.
  • Want to learn more about JavaScript? Go Full Frontal! September 29, 2009
    I’m sure you’re familiar with a bit of JavaScript now that you’ve subscribed to my screencasts and hacked and played around with jQuery. Earlier this year I decided that it was time there was a UK conference dedicated to learning JavaScript, and I called it Full Frontal
  • jQuery Tools: The missing UI library for the Web September 27, 2009
    jQuery Tools is a collection of the most important user interface components for the web.
  • Simplicity in Good Web Design : Advantages & How -to September 21, 2009
    Simplicity in website design doesn’t necessarily equate with a minimalist design aesthetic. Simple sites just remove all unnecessary elements from the design, content, and code. While minimalist sites generally fit this criteria, there are plenty of sites that wouldn’t, by any stretch of the imagination, be considered “minimalist” tha […]
  • 40 Creative and Inspiring Website Backgrounds Techniques September 8, 2009
    Web designers compete to impress visitors with distinctive and appealing visual elements.
  • 7 Rules for Mixing Multiple Fonts in Good Web Design September 7, 2009
    Typography can be one of the most creatively rewarding parts of web design, but it can also be one of the most frustrating.
  • 45 Brilliant Examples of Photo Manipulation Art September 2, 2009
    Photo manipulation is probably one of the most popular application areas in which Adobe Photoshop is used extensively. One of the main reasons for that is its ability to blend real photos with vibrant colors and digital painting to emphasize some beautiful details which makes this software ideal for this kind of work.