CRM Open Source Business & Social CRM Software

Results 1 to 4 of 4

Thread: How to consume StrikeIron US Address Verification Web service within SugarCRM (cont.)

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

    Default How to consume StrikeIron US Address Verification Web service within SugarCRM (cont.)

    Hello everybody,

    Working with your Account, Contact, and custom addresses, wouldn't it be nice if there was a way to verify addresses are correct and actually exist according to the United States Post Office official data? This way, when sending collateral, products, or anything, you can save money by ensuring that it actually gets there, have much better data, and ultimately provide much better customer service. There is nothing more harmful to CRM efforts than incorrect and/or incomplete customer information.

    Fortunately, address verification (and many other types of verification) can easily be integrated into SugarCRM. This topic discusses a way that can help you to verify those addresses within SugarCRM using US Address Verification Web Service 5.0.0 from StrikeIron.

    - Prerequisites:
    1. Sugar CRM 5.2 or later
    2. Enhanced Studio 2.2.1 or later.

    The steps
    In general, we got 4 steps to complete this sample:
    1. Create "Custom Code field" for a SugarCRM Account. When this step is completed, you will have a button called "Verify Address" that will help to verify the billing address of any customers.
    2. Layout the position of this button using Studio tool for developer in Sugar CRM
    3. Create a Sugar php page to consume the StrikeIron Web service.
    4. Run the sample

    Before starting with the 4 steps above, you have to make sure the Enhanced Studio has been installed into SugarCRM.
    Download the latest version Demo 2.2.1 , then use Module Loader in Admin page to upload and install this module to Sugar CRM. This installation allows you to create a custom "CODE" field, where you can put your php code into Account EditView.

    Step 1 - Create Custom Code field.

    Navigate to Admin -> Developer Tools ->Studio. In the Modules tree, drop down Accounts node, choose Fields ->Add Fields.
    Select "Code" for Data Type value, enter "SIAddressChecker" for field name, "SI Address Checker" for Display label.

    Enter the following code to the Code text value:

    PHP Code:
    $address str_replace("\r\n","|",$bean->billing_address_street); //to remove the carrage return and line feed characters of from address value with 2 lines.

    echo '
    <script>
    function invokeAddress() {
       alert("Progress started");
       var callback = {
            success: function(o) {
                        document.getElementById("div_address").innerHTML =  o.responseText;
                         
            }
        }
        var addr = "'
    .$address.'";
        var ar = addr.split("|");
            if (ar.length >1)
        {
             strConn = "/sugarcrm/siusaddress.php?address1=" + ar[0] + "&address2=" + ar[1] + "&citystatezip='
    .$bean->billing_address_city.' '.$bean->billing_address_state.' '.$bean->billing_address_postalcode.' ";
        } else
        {
             strConn = "/sugarcrm/siusaddress.php?address1="+ ar[0]+"&address2=&citystatezip='
    .$bean->billing_address_city.' '.$bean->billing_address_state.' '.$bean->billing_address_postalcode.' ";
        }
        
        alert( strConn);
        var connectionObject = YAHOO.util.Connect.asyncRequest ("GET", strConn, callback);
    }
    </script>  
    <div style="align:left">
    <input type="button" id="btn" name="button" value="Verify address" onclick="invokeAddress();"></div>

    <div id="div_address">
    </div>
    '

    This php code helps to create a button called "Verify Address". When a user clicks on it, it will send a request to a php page "/sugarcrm/siusaddress.php" to consume the StrikeIron US Address Verification web service. You will create this page in step 3.

    Step 2 - Determine where to place the button
    The best place to put it is the Account EditView, the place where user can edit a Account detail information (Name, billing address, shipping address...).

    So, navigate to Layout on the same tree (in Studio tool), drop down the nodes, find EditView node, click on it. Drag the "New Row" to Address Information, below Billing Street. It is a good idea to have this button physically near the billing address. Then, drag the SIAddressChecker field to this empty panel. Click Save and Deploy.

    Step 3 - Create a Web service client as a php page.

    Create a file named "siusaddress.php", edit the file with the following code, and copy it to SugarCRM root folder (i.e.: E:\Program Files\sugarcrm-5.2.0\htdocs\sugarcrm):

    PHP Code:
    <?php
    $siurl 
    'http://ws.strikeiron.com/StrikeIron/USAddressVerification5/USAddressVerification/VerifyAddressUSA?LicenseInfo.RegisteredUser.UserID=hoaidan@yahoo.com&LicenseInfo.RegisteredUser.Password=0503danth&VerifyAddressUSA.AddressLine1="'.urlencode($_REQUEST['address1']).'"&VerifyAddressUSA.AddressLine2="'.urlencode($_REQUEST['address2']).'"&VerifyAddressUSA.CityStateZIPCode="'.urlencode($_REQUEST['citystatezip']).'"';

    print(
    $siurl);

    $handle fopen($siurl"r");
    $contents '';
    while (!
    feof($handle)) {
        
    $contents .= fread($handle8192);
    }
    fclose($handle);

    $s simplexml_load_string($contents); 

    echo 
    '<div>Address verification result:</div>
    <div id="div_info"><b>Address status</b>:'
    .$s->VerifyAddressUSAResponse->VerifyAddressUSAResult->ServiceStatus->StatusDescription.'
    <br><b>RemainingHits: </b>'
    .$s->SubscriptionInfo->RemainingHits.'</b>
    <br><b>Address Line 1: </b>'
    .$s->VerifyAddressUSAResponse->VerifyAddressUSAResult->ServiceResult->AddressLine1.'</b>
    <br><b>Address Line 2: </b>'
    .$s->VerifyAddressUSAResponse->VerifyAddressUSAResult->ServiceResult->AddressLine2.'</b>
    <br><b>City: </b>'
    .$s->VerifyAddressUSAResponse->VerifyAddressUSAResult->ServiceResult->City.'</b>
    <br><b>State: </b>'
    .$s->VerifyAddressUSAResponse->VerifyAddressUSAResult->ServiceResult->State.'</b>
    <br><b>ZIP: </b>'
    .$s->VerifyAddressUSAResponse->VerifyAddressUSAResult->ServiceResult->ZIPCode.'</b>
    <br><b>Latitude: </b>'
    .$s->VerifyAddressUSAResponse->VerifyAddressUSAResult->ServiceResult->GeoCode->Latitude.'</b>
    <br><b>Longitude: </b>'
    .$s->VerifyAddressUSAResponse->VerifyAddressUSAResult->ServiceResult->GeoCode->Longitude.'</b>
    </div>'
    ;  

    ?>
    -- Notes: you have to replace the username and password values with the ones you have after
    StrikeIron user registration.
    In this code, we would like to consume the StrikeIron US Address Verification Web service at "http://ws.strikeiron.com/USAddressVerification4_0?WSDL" , and return the modified Address to Account EditView page. The call is nothing but a HTTP GET request to the Web service.

    Step 4- Run the sample
    Open Account list, edit one of them, you can see the "Verify Address" button. Click on it to verify the billing address of this customer.

    That's all there is to it. You can modify the "Custom Code" to display the verification result on a floating <div> so that you can easily move it when editing the Account detail.

    Hope it helps
    Have fun!
    Dan Tong.

    References
    1. StrikeIron US Address Verification 5.0.0 Web service:
    2. SugarCRM Enhanced Studio
    Last edited by dant; 2009-03-12 at 05:25 AM.

  2. #2
    dtokeefe's Avatar
    dtokeefe is offline Sugar Community Member
    Join Date
    Mar 2005
    Location
    Sao Paulo, Brasil
    Posts
    671

    Default Re: How to consume StrikeIron US Address Verification Web service within SugarCRM (co

    Good stuff, Dan !
    David O'Keefe
    Lampada Global Services
    SugarCRM Gold Partner
    USA: +1 908 998-2278
    BR: +55 11 3237-3110
    Skype: dtokeefe
    Email: equipe@lampadaglobal.com
    www.lampadaglobal.com

    Lampada Global delivers enterprise software and offshore programming services to customers around the world.

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

    Default Re: How to consume StrikeIron US Address Verification Web service within SugarCRM (co

    Your welcome! It's great to know that. There are plenty of interesting Web services on www.strikerion.com. Hope they may help your development.

    Dan.
    Last edited by dant; 2009-03-18 at 09:47 AM.

  4. #4
    blackened is offline Member
    Join Date
    Jun 2009
    Posts
    5

    Default Re: How to consume StrikeIron US Address Verification Web service within SugarCRM (co

    Hello Dan,

    I am just curious if this is still valid. I cannot seem to get it to work. When I click on the verify button, it pops up a message that says "Progress started" and then another pop-up that says "/sugarcrm/siusaddress.php?address1=123 Example Road&address2=&citystatezip=Somewhere MT 12345-6789". After that, nothing. Any ideas what would cause this?

    Thanks,
    Scott

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Replies: 9
    Last Post: 2011-06-15, 07:30 PM
  2. Replies: 5
    Last Post: 2009-03-05, 04:41 PM
  3. Replies: 0
    Last Post: 2009-02-18, 09:16 AM
  4. Replies: 6
    Last Post: 2007-12-28, 10:08 PM

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
  •