Tuesday, 30 July 2013

Sugar Developer Guide 6.5

The Sugar Developer Guide is designed for developers who are new to Sugar, or to CRM and Web-based applications. This guide introduces you to some basic CRM concepts and helps you get familiar with the Sugar system. It describes how to configure and customize the Sugar platform for a broad range of tasks applicable to companies, government agencies and other organizations that have a need to manage business relationships with people.
Readers are expected to have basic programming and software development knowledge, be familiar with the PHP programming language and the SQL database language.
Topics

Monday, 29 July 2013

Sugar Community Edition 6.5.0 Administration Guide

This guide describes options that enable Sugar administrators to configure the application to meet their organization’s requirements.
Topics
  • The Admin Wizard displays when you log into Sugar for the first time after installation. This wizard guides you through the process of branding, localizing, and configuring email settings in Sugar that will be applicable to all users in your organization. You can skip this step if you prefer to do it at a later time.
  • This section describes how to manage teams, users, and roles.
  • Connect to the various SugarCRM services where you can access the SugarCRM forums and Sugar Wiki, search FAQs (Frequently Asked Questions), download the latest Sugar version, file and research reported bugs, request new features and more.
  • This section includes options to configure system-wide settings that apply to all users in your organization.
  • Administrators can setup and manage mail accounts for inbound and outbound emails, including campaign emails, using the options defined in this section.
  • The Developer tools section displays options that enable you to build new modules and customize existing ones. The Module Builder enables you to build custom modules; Studio enables you to customize existing modules. To create relationships between modules, see Creating Relationships. After you build a module in Module Builder, you can deploy the module directly within the current instance, or you can use the Module Loader to install it in another Sugar instance. For more information, see Module Loader.
  • This section provides the Releases option that enables you to maintain a list of releases for your product. This list will be available in the Release drop-down box that is displayed when reporting a new bug in the Bug Tracker module.
  • As an administrator, you can create and manage employee records. When you create an employee record, it is automatically added to the Employees list as well as the Users list. Similarly, when you delete an employee, the associated user record is also deleted.
  • Advanced Configuration options enable you to exercise tighter control over user actions in your Sugar instances.

Sugar Community Edition 6.5.0 Application Guide

The Sugar Community Edition Application Guide introduces you to some basic CRM concepts and helps you get familiar with the Sugar system. It describes how to access Sugar through a personal computer and a web browser. It also describes how to perform a broad range of customer relationship management tasks and related administration tasks.
Readers are not required to have any programming or software development knowledge, but should be generally familiar with the use of a personal computer and a web browser such as Mozilla Firefox.

Topics
  • Welcome to Sugar Community Edition, a commercial open source Customer Relationship Management (CRM) application.
  • This guide assumes that you have the required resources to access the Sugar application and you are familiar with how to use them. Contact your system administrator for issues and concerns.
  • The Sugar user interface consists of various modules designed to help you manage customer-related records such as contacts and accounts. Each module, representing a record type, groups the tools and functions needed to perform specific tasks. This enables you to work more efficiently.
  • When you log into Sugar, you will see your Home page. Tabs for other modules display alongside the Home tab. Other users do not have access to your Home page. The Home page displays a collection of Sugar Dashlets that display information related to your activities such as meetings and calls. It also displays records assigned to you, such as Accounts, Opportunities, and Cases. Sugar Dashlets are user-configurable panels that you can add, remove, and move as needed. For more information, see Managing Sugar Dashlets.
  • Leads are early contacts in the sales process. Use the Leads module to create, manage, and track sales leads or unqualified opportunities along with related activities, sales campaigns, and history. You can associate a lead with any type of campaign to track the effectiveness of the campaign in generating opportunities for your organization.
  • Use the Contacts module to create and manage contacts for your organization. A contact is any individual who is a valid sales lead; a lead that has been evaluated and assessed for a possible sales opportunity. You can associate a contact with any record such as an Account, Opportunity, or Campaign. Associating a contact with a campaign enables you to track the effectiveness of the campaign in generating opportunities for your organization.
  • Use the Accounts module to create and manage customer Accounts for your organization. An Account contains your customer information such as name and address. Each Account can be associated with other records such as Opportunities and Contacts.
  • Use the Opportunities module to create and manage sales opportunities, qualified leads, and view related records. An opportunity specifies the estimated amount of a sales deal and is tied to a sales stage. A sales stage, such as Qualification, Closed Won, or Closed Lost identifies how close you are to making the sale. The administrator defines and sets the sales stage depending upon the requirements in your organization. The estimated amount can vary depending on the sales stage.
  • Use the Documents module to create and manage files that you share with users and contacts.
  • The Calendar Module has been introduced as a separate module in Release 6.2.0 to allow for ease of use and access. Use the Calendar module to schedule and manage activities such as calls, meetings, and tasks.
  • The Calls Module has been introduced as a separate module in Release 6.2.0 to allow for ease of use and access. Use the Calls module to log, view, and import calls.
  • The Meetings Module has been introduced as a separate module in Release 6.2.0 to allow for ease of use and access. Use this module to schedule, view, and manage meetings.
  • The Emails module enables individual users to send and receive emails from within Sugar.
  • The Tasks Module has been introduced as a separate module in Release 6.2.0 to allow for ease of use and access. Use the this module to schedule and manage tasks.
  • The Notes Module has been introduced as a separate module in Release 6.2.0 to allow for ease of use and access. Use the this module to create, view, and import Notes and attachments to records in Sugar.
  • Use the Targets Module to track and manage targets as part of mass marketing campaigns. You can create many types of campaigns as described in Creating a Campaign.
  • Use the Target Lists Module to track and manage mass marketing campaigns. You can create many types of campaigns as described in Creating a Campaign.
  • Use the Campaigns Module to track and manage mass marketing campaigns. You can create many types of campaigns as described in Creating a Campaign.
  • Use the Cases module to track and manage services-releated problems reported by your users and customers. After you create a case, you can associate it with related bugs.
  • Use the Bug Tracker module to report, track, and manage product bugs.. Bugs are defects or features associated with a particular revision of a product. The administrator populates the drop-down list of product releases. After you create a bug, you can associate it with the related case. Note: This module is hidden by default. The administrator must display it for your use.
  • Use the Projects Module to create and manage projects for your organization.
  • You can export Sugar records in .csv format to your local machine. Use Microsoft Excel, Notepad, or other text editors to open .csv files. The .csv file displays column titles, including the Record ID (a long string of letters and numbers used as a unique reference to each account record) and all the other fields in the module. Note: When exporting values for drop-down list options, Sugar exports the ID associated with each option (that is, item name) and not the display labels.
  • Import data for modules such as Accounts, Contacts, Leads, Opportunities, Targets, Calls, Meetings, and Tasks with the help of an easy-to-use User Import Wizard. Refer to the tool-tips and instructions provided in the wizard at every step of the import process.
  • Use the Employees module to view information such as name, title, and email address for employees in your organization. All Sugar users are employees, not all employees are Sugar users. An employee needs a username and password to log into Sugar to be a user.

Friday, 26 July 2013

Retrieving a List of Fields From a Module - REST and PHP

Overview

A PHP example demonstrating how to retrieve fields vardefs from the accounts module with the get_module_fields method using cURL and the v4 REST API.
This example will only retrieve the vardefs for the 'id' and 'name' fields.

Example

01<?php
02 
03    $url = "http://{site_url}/service/v4/rest.php";
04    $username = "admin";
05    $password = "password";
06 
07    function call($method, $parameters, $url)
08    {
09        ob_start();
10        $curl_request = curl_init();
11 
12        curl_setopt($curl_request, CURLOPT_URL, $url);
13        curl_setopt($curl_request, CURLOPT_POST, 1);
14        curl_setopt($curl_request, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0);
15        curl_setopt($curl_request, CURLOPT_HEADER, 1);
16        curl_setopt($curl_request, CURLOPT_SSL_VERIFYPEER, 0);
17        curl_setopt($curl_request, CURLOPT_RETURNTRANSFER, 1);
18        curl_setopt($curl_request, CURLOPT_FOLLOWLOCATION, 0);
19 
20        $jsonEncodedData = json_encode($parameters);
21 
22        $post = array(
23             "method" => $method,
24             "input_type" => "JSON",
25             "response_type" => "JSON",
26             "rest_data" => $jsonEncodedData
27        );
28 
29        curl_setopt($curl_request, CURLOPT_POSTFIELDS, $post);
30        $result = curl_exec($curl_request);
31        curl_close($curl_request);
32 
33        $result = explode("\r\n\r\n", $result, 2);
34        $response = json_decode($result[1]);
35        ob_end_flush();
36 
37        return $response;
38    }
39 
40    //login -------------------------------------------
41 
42    $login_parameters = array(
43         "user_auth"=>array(
44              "user_name"=>$username,
45              "password"=>md5($password),
46              "version"=>"1"
47         ),
48         "application_name"=>"RestTest",
49         "name_value_list"=>array(),
50    );
51 
52    $login_result = call("login", $login_parameters, $url);
53 
54    /*
55    echo "<pre>";
56    print_r($login_result);
57    echo "</pre>";
58    */
59 
60    //get session id
61    $session_id = $login_result->id;
62 
63    //retrieve fields -----------------------------------
64 
65    $get_module_fields_parameters = array(
66 
67         //session id
68         'session' => $session_id,
69 
70         //The name of the module from which to retrieve records
71         'module_name' => 'Accounts',
72 
73         //Optional. Returns vardefs for the specified fields. An empty array will return all fields.
74         'fields' => array(
75             'id',
76             'name',
77         ),
78    );
79 
80    $get_module_fields_result = call("get_module_fields", $get_module_fields_parameters, $url);
81 
82    echo "<pre>";
83    print_r($get_module_fields_result);
84    echo "</pre>";
85 
86?>

Result

01stdClass Object
02(
03    [module_name] => Accounts
04    [table_name] => accounts
05    [module_fields] => stdClass Object
06        (
07            [id] => stdClass Object
08                (
09                    [name] => id
10                    [type] => id
11                    [group] =>
12                    [id_name] =>
13                    [label] => ID
14                    [required] => 1
15                    [options] => Array
16                        (
17                        )
18 
19                    [related_module] =>
20                    [calculated] =>
21                    [len] =>
22                )
23 
24            [name] => stdClass Object
25                (
26                    [name] => name
27                    [type] => name
28                    [group] =>
29                    [id_name] =>
30                    [label] => Name:
31                    [required] => 1
32                    [options] => Array
33                        (
34                        )
35 
36                    [related_module] =>
37                    [calculated] =>
38                    [len] => 150
39                )
40 
41        )
42 
43    [link_fields] => Array
44        (
45        )
46 
47)

Creating Custom Web Services In SugarCRM

I have been using web services to access Sugar for sometime now, for purposes of integration and for accessing data from a portal. While it is reasonably well documented, there are restrictions, and last week I cam across a requirement I just couldn’t meet with the standard web services methods. It was time to explore custom web services.
When I did, I suddenly realised that it was very simple to implement, and allowed me to push much of the business logic back into the server where it belongs. I could create a new method that had all sorts of complex logic,and expose the results via web services.
Now I did think that this might restrict the ability of the client software; any time it needs to access a Sugar instance, that instance needs the custom web service installed. By zipping up the custom web service as a loadable module (a topic I’ll discuss in the future as it is a very easy and powerful way to deploy any sort of customisation) this objection was quickly overcome. In any cases I would normally have access to the server when doing this type of work.
So, I have included a trivial method here, just to prove that I can. I think you will see that just about anything can go into such a method, allowing the web service to provide complex functionality to its client.
Before tackling that, lets see how the standard web service works. We will look at the version 4.1REST option from Sugar PRO 6.5.13.
service/v4_1/rest.php
You can try this in a browser directly, as follows (your url will be slightly different)
http://localhost/sugarPro6.5.13/service/v4_1/rest.php
This will show you documentation of the standard Sugar methods you can call, and their parameters.
Custom Web Service
Now our custom web service is to reside at custom/service so that it its upgrade safe. Lets look at the code, and compare it with the standard Sugar version above.
You will see we just extend the standard classes and create our own. These are below (MySugarRestService.php and MySugarRestServiceImp.php, though we could do without the first)
and MySugarRestServiceImpl.php below. You can see how it extends the Sugar class and adds a new method (getContactDetails).
Note that the method just returns hard coded values.
Accessing The Web Service
To prove that it works you need some a client. The following is very basic code to act as a client calling our new method. In a later post I will show more examples of client code, but for now this is enough to get started.
When you run that client you get the following response.
Which are just the hard coded value set in our server method.
I think that is enough to get started. I haven’t shown the login process, or how values can be retrieved from Sugar. All will have to wait for a new post.