CRM Open Source Business & Social CRM Software

Results 1 to 6 of 6

Thread: How to consume US Address Verification from StrikeIron within SugarCRM

  1. #1
    dant is offline Member
    Join Date
    Feb 2009
    Posts
    12

    Default How to consume US Address Verification from StrikeIron within SugarCRM

    This article will show how to develop a Cloud View (a Connector in Sugar CRM 5.2) which will consume the Strike Iron Cortera Service at http://wslite.strikeiron.com/Cortera...Lite.asmx?WSDL. More information about this Web service

    There are 5 steps to get the sample work.

    Step 1 – Determine the component name
    This name will be used to define the name of a Cloud View. In this sample, we call it “strikeiron” .

    Step 2 – Prepare the empty text files and directory to program the sample:
    We need to create the following directory structure:

    Directory Files
    [root]/formatters - strikeiron.php
    [root]/formatters/tpls - default.tpl, strikeiron.gif (image icon file)
    [root]/language - en_us.lang.php
    [root]/source / - config.php, mapping.php, strikeiron.php, vardefs.php

    Step 3 – Start programming
    1. Edit file: formatters\strikeiron.php.
    PHP Code:
    <?php
    if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
    require_once(
    'include/connectors/formatters/default/formatter.php');
    class 
    ext_soap_strikeiron_formatter extends default_formatter {
    public function 
    getDetailViewFormat() { 
       
    $mapping $this->getSourceMapping();
       
    $mapping_name = !empty($mapping['beans'][$this->_module]['name']) ? $mapping['beans'][$this->_module]['name'] : '';

       if(!empty(
    $mapping_name)) {
           
    $this->_ss->assign('mapping_name'$mapping_name);
           return 
    $this->fetchSmarty();
       }

       
    $GLOBALS['log']->error($GLOBALS['app_strings']['ERR_MISSING_MAPPING_ENTRY_FORM_MODULE']);
       return 
    '';
    }    

    public function 
    getIconFilePath() {
       return 
    'modules/Connectors/connectors/formatters/ext/soap/strikeiron/tpls/strikeiron.gif';
    }   

    }
    ?>
    In this class, the getIconFilePath() operation returns the path of deployed CloudView icon.

    2. Edit template of CloudView (formatters\tpls\default.tpl):

    PHP Code:
    <div style="visibility:hidden;" id="strikeiron_popup_div"></div>
    <
    script src="" type="text/javascript"></script>
    <script type="text/javascript" src="{sugar_getjspath file='include/connectors/formatters/default/company_detail.js'}"></script>
    <script type="text/javascript">
    function show_ext_soap_strikeiron(event)
    {literal} 
    {
    var xCoordinate = event.clientX;
    var yCoordinate = event.clientY;
    var isIE = document.all?true:false;
          
    if(isIE) {
        xCoordinate = xCoordinate + document.body.scrollLeft;
        yCoordinate = yCoordinate + document.body.scrollTop;
    }

    {/literal}

        cd = new CompanyDetailsDialog("strikeiron_popup_div", '<div id="strikeiron_div"><div>Company found:</div><iframe id="resFrame" src="" width="90%"  height="110"> </iframe><div><a href="http://www.strikeiron.com/ProductDetail.aspx?p=409">About StrikeIron Cortera Service</a></div><div><a href="http://www.strikeiron.com/Register.aspx">Register</div>', xCoordinate, yCoordinate);
        cd.setHeader("{$fields.{{$mapping_name}}.value}");
        cd.display();
        var sugarValue = "{$fields.{{$mapping_name}}.value}";
    var sugarValues = sugarValue.split(" ");
        var sugarCoName = "";
    {literal}    
        for (i=1; i< sugarValues.length; i++)
        {
            sugarCoName = sugarCoName + sugarValues[i-1] + " "; 
        }
    {/literal}
        var url = "{{$config.properties.STRIKEIRON_LINK}}?Company=" + sugarCoName;
        document.getElementById('resFrame').src = url;

    {literal}

    {/literal}
    </script> 
    STRIKEIRON_LINK will be defined in below step.
    3. Edit config.php file
    PHP Code:
    <?php
    if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
    // created: 2008-10-03 14:31:59
    $config = array (
          
    'name' => 'StrikeIronŠ',
        
    'properties' => 
        array (
            
    'STRIKEIRON_LINK' => 'http://a.server.com/sisugar.aspx'
        ),
    );
    ?>
    Notes: $config.properties.STRIKEIRON_LINK is the value of StrikeIron Cortera Link you need to set in Connector Settings configuration step in step 6

    4. Edit strikeiron.php file
    PHP Code:
    <?php
    if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
    require_once(
    'include/connectors/sources/ext/soap/soap.php');
    class 
    ext_soap_strikeiron extends ext_soap {
        public function 
    __construct(){
            
    parent::__construct();
            
    $this->_enable_in_wizard false;
            
    $this->_enable_in_hover true;
        }
        
        public function 
    getItem($args=array(), $module=null){}

        public function 
    getList($args=array(), $module=null){}
        
        public function 
    __destruct(){
            
    parent::__destruct();
        }
    }
     
    ?>
    5. Edit mapping.php file
    PHP Code:
    <?php
    // created: 2009-01-22 21:40:15
    $mapping = array (
      
    'beans' => 
      array (
        
    'Accounts' => 
        array (
          
    'name' => 'name',
          
    'id' => 'id',
        ),
      ),
    );
    ?>
    6. Edit vardefs.php file
    PHP Code:
    <?php
    if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
    $dictionary['ext_soap_strikeiron'] = array(

      
    'comment' => 'vardefs for StrikeIron connector',
      
    'fields' => array (
        
    'id' =>
          array (
            
    'name' => 'id',
            
    'vname' => 'LBL_ID',
            
    'type' => 'id',
            
    'comment' => 'Unique identifier',
              
    'hidden' => true,
        ),
        
    'name'=> array(
            
    'name' => 'name',
            
    'vname' => 'LBL_NAME',
            
    'type' => 'varchar',
            
    'hover' => true,
            
    'comment' => 'The name of the company',
        ),
      )
    );
    ?>
    7. Edit language file: en_us.lang.php
    PHP Code:
    <?php
    if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');

    $connector_strings = array (
        
    //licensing information shown in config screen
        
    'LBL_NAME' => 'Company Name',

        
    //Configuration labels
        
    'STRIKEIRON_LINK' => 'StrikeIron Cortera Link',

    );

    ?>
    Step 4 – Deploy the files
    Copy the source file to SugarCRM application folder:

    formatters/strikeiron.php -copy to---> [sugarcrm_root_dir]/ htdocs\sugarcrm\modules\Connectors\connectors\form atters\ext\soap\strikeiron
    All files in formatters/tpls/ -copy to---> [sugarcrm_root_dir]\ htdocs\sugarcrm\modules\Connectors\connectors\form atters\ext\soap\strikeiron\tpls
    All files in /source --copy to--> [sugarcrm_root_dir]\ htdocs\sugarcrm\modules\Connectors\connectors\sour ces\ext\soap\strikeiron\
    All files in /language -copy to---> [sugarcrm_root_dir]\ htdocs\sugarcrm\modules\Connectors\connectors\sour ces\ext\soap\strikeiron\language

    In other hand, you can deploy this connector by building the zip package file and upload it to SugarCRM using the instruction at http://www.sugarcrm.com/crm/index.ph...05.2.1.34.html

    Step 5 – Setup the StrikeIron Cortera Link.
    This link is an asp.net page. It consumes the StrikeIron Cortera service to return result for the CloudView.
    In order to do that, you need to create a asp.net page, add the following web reference into: http://wslite.strikeiron.com/Cortera...Lite.asmx?WSDL.

    Then modify Page_Load event:
    PHP Code:
    ...
    public 
    partial class Sugar_Default System.Web.UI.Page 
    {
        protected 
    void Page_Load(object senderEventArgs e)
        {
            if (
    Request["Company"] != null)
            {
                
    string company Request["Company"].ToString();
                
    com.strikeiron.wslite.CorteraLite service = new com.strikeiron.wslite.CorteraLite();
                
    com.strikeiron.wslite.CompanySearch objComp = new com.strikeiron.wslite.CompanySearch();
                
    objComp.CompanyName company;
                
    CorteraOutput output service.SearchByCompany(objComp);
                
    CorteraData[] arrData output.ServiceResult.Companies;
                
    string result "";
                
    result += "Remaining hits: " output.RemainingHits "</br>";
                if (
    arrData != null && arrData.Length 0)
                {
                    
    result "Company Name: " arrData[0].CompanyName "</br>";
                    
    result += "Address: " arrData[0].Address "</br>";
                    
    result += "City: " arrData[0].City "</br>";
                    
    result += "Postal Code: " arrData[0].PostalCode "</br>";
                    
    result += "State: " arrData[0].State "</br>";
                    
                }
                else
                {
                    
    result += "No company found";
                }
                
    Response.Write(result);
            }
        }

    Then build the solution and host this web page to a server, such as: http://a.server.com/sisugar.aspx

    Step 6 – Test the final result

    Login to SugarCRM under the role in which you can change the application configuration. Open Admin>Connector Settings
    Choose Set Connector Properties.
    Enter your link of the hosted asp.net page into “StrikeIron Cortera Link”, then click Save.

    Now move to Accounts page, you will see a list of Account, click on one you want to verify the company location. You will see the Account Detail and a small StrikeIron icon. Hove over it, you will get below result:

    Variations: you can change the asp.net page so that it will return a list of search instead of one row like above. Another variation of this sample is that instead of using <iframe> in tpls\default.tpl file to call the StrikeIron Cortera Link, you can call StrikeIron Cortera Lite directly without using StrikeIron Cortera Link from this default.tpl file using some Ajax SOAP call like a html page calls SOAP Web services.
    -Have fun.
    Dan Tong
    References:
    1. Connector Framework User Guide: http://www.sugarcrm.com/crm/index.ph...05.2.1.34.html
    2. StrikeIron Lite Web services: http://www.strikeiron.com/marketplace/liteservices.aspx
    Attached Files Attached Files
    Last edited by dant; 2009-03-12 at 05:28 AM.

  2. #2
    dant is offline Member
    Join Date
    Feb 2009
    Posts
    12

    Default Re: How to consume US Address Verification from StrikeIron within SugarCRM

    Hi everybody,
    This topic title should be "How to consume Cortera Web services from StrikeIron" rather than ".. US Address Verification". For some reason, the topic title could not be changed, so we will try to post the sample on SugarCRM working with "US Address Verification Web services from StrikeIron" in another topic.
    My apology for this.
    Hope this topic still help in case you want to try with other StrikeIron Web services.

    Dan Tong.
    Last edited by dant; 2009-02-20 at 04:38 AM.

  3. #3
    dant is offline Member
    Join Date
    Feb 2009
    Posts
    12

    Default Re: How to consume US Address Verification from StrikeIron within SugarCRM

    Hi everyone,

    If you want to read more about How to consume the StrikeIron US Address Verification version 5.0.0 using Custom field in SugarCRM, please visit this topic.
    Hope it helps.

    Dan.

  4. #4
    SugarDev.net is offline Sugar Community Member
    Join Date
    Feb 2008
    Posts
    1,401

    Default Re: How to consume US Address Verification from StrikeIron within SugarCRM

    Although we're a Europe-based company, I want to thank you for your input. I hope to build something like this for this side of the Atlantic someday.

    A hint: if you put your code in PHP blocks with [ php ] it makes it much easier to read your code.
    Developers go here
    Businesses go there (Dutch)

    Modules:
    SugarDev.net Developer Tools | Config | Dutch Language Pack
    "Nothing gets fixed unless there is a bug"

  5. #5
    sibob is offline Junior Member
    Join Date
    Feb 2009
    Posts
    2

    Lightbulb Re: How to consume US Address Verification from StrikeIron within SugarCRM

    StrikeIron also has a Global Address Verification Web Service API that can be integrated into SugarCRM in the same way as US Address verification in the example above. The global version verifies and enhances address data from over 240 countries. The service description and WSDL is here: http://www.strikeiron.com/ProductDetail.aspx?p=443

  6. #6
    dant is offline Member
    Join Date
    Feb 2009
    Posts
    12

    Default Re: How to consume US Address Verification from StrikeIron within SugarCRM

    Hi SugarDev.Net
    Thank you for your hint. Will try the PHP tag next time.
    BTW, it's great to know it can help.
    Dan

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. DNC verification for new leads
    By vegeta in forum Developer Help
    Replies: 1
    Last Post: 2009-02-13, 08:22 PM
  2. Knowledge Centered Support Verification?
    By acasey in forum Feature Requests
    Replies: 0
    Last Post: 2007-08-16, 11:24 AM
  3. Replies: 2
    Last Post: 2007-01-27, 01:22 AM
  4. Entries verification in custom modules
    By NairWick in forum Developer Help
    Replies: 4
    Last Post: 2006-05-12, 09:05 AM

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
  •