Hi everybody,
Customer Information Verification is always the top priority task to do everyday when you work with your Accounts. Before contacting a customer with his/her phone number, you always want to know if that number is existing and correct. Moreover, you would like to know more than a phone number, such as: what is the customer's location (city/state/zip), company name (the owner of the number), the employee size of that company, Fax number, ...
Below simple sample demonstrates how to use Reverse Phone and Address lookup Web service from StrikeIron to lookup that information using just a phone number in Account's Edit View.
Here we go,
- Prerequisites:
1. Sugar CRM 5.2 or later
2. Enhaced Studio 2.2.1 or later.
The steps
Before starting, you have to make sure the Enhanced Studio have been installed into your SugarCRM.
Download the latest version 2.2.1 Demo from this web site, then use Module Loader in Admin page to upload and install this module to Sugar CRM. This module will allow you to create a custom "CODE" field, where you can put your php code into the value of this field.
Step 1 - Create Custom Code field.
Navigate to Admin -> Developer Tools->Studio. In Modules tree, drop down Accounts node, choose Fields>Add Fields.
Select "Code" for Data Type value, enter SIReversePhone for field name, SI Reverse Phone for display name.
Then enter the following code to Code text value:
This php code will help create a button called "Look up reverse phone information". When user click on it, it will call a php page: "/sugarcrm/si_reversephone.php" and consume the info from StrikeIron Reverse Phone Information web service. After the Web service run, you will get many helpful information returned from the office phone number of customers such as: City, State, Company, Country, Fax, The company owns the number,...PHP Code:echo '
<script>
function invokeReversePhone() {
alert("Progress started");
var callback = {
success: function(o) {
document.getElementById("div_reverse").innerHTML =
o.responseText;
}
}
var connectionObject = YAHOO.util.Connect.asyncRequest ("GET", "/sugarcrm/si_reversephone.php?phone='.$bean->phone_office.'" , callback);
}
</script>
<div style="align:left">
<input type="button" id="btnRP" name="button" value="Look up reverse phone information" onclick="invokeReversePhone();"></div>
<div id="div_reverse">
</div>
';
Step 2 - Determine where to place the button
The best place for this button is the place where user can edit Account detail information like Name, Office phone, shipping address...
Now, navigate to "Layout" on the same tree, drop down the nodes, find "EditView" node, click on it. Drag the "New Row" to Account Information, below "Phone Office" field. We would like the user to see this button near the phone office which we need to verify. Then drag the SIReversePhone field to this empty panel. Click Save and Deploy.
Step 3 - Create a Web service client as a php page.
Create a file named "si_reversephone.php", edit the file with the following code, and copy it to SugarCRM root folder (for example: E:\Program Files\sugarcrm-5.2.0\htdocs\sugarcrm):
In this code, we would like to consume the StrikeIron Reverse Phone and Address Web services at http://www.strikeiron.com/productdetail.aspx?p=449. This Web service returns many helpful information about the person or company that owns this phone number. Replace your username and password in the code with those provided by StrikeIron after the user registration.PHP Code:<?php
$handle = fopen('http://ws.strikeiron.com/StrikeIron/ReversePhoneAddressLookup/TelematchServices/ReverseLookupByPhoneNumber?LicenseInfo.RegisteredUser.UserID=yourusername&LicenseInfo.RegisteredUser.Password=yourpassword&ReverseLookupByPhoneNumber.PhoneNumber='. $_REQUEST['phone'], "rb");
$contents = '';
while (!feof($handle)) {
$contents .= fread($handle, 8192);
}
fclose($handle);
$s = simplexml_load_string($contents);
echo '<div>Reverse Phone Information:</div>
<div id="div_info"><b>Result</b>:'.$s->ReverseLookupByPhoneNumberResponse->ReverseLookupByPhoneNumberResult->ServiceStatus->StatusDescription.'
<br><b>City: </b>'.$s->ReverseLookupByPhoneNumberResponse->ReverseLookupByPhoneNumberResult->ServiceResult->City.'</b>
<br><b>State: </b>'.$s->ReverseLookupByPhoneNumberResponse->ReverseLookupByPhoneNumberResult->ServiceResult->StateOrProvince.'</b>
<br><b>Country: </b>'.$s->ReverseLookupByPhoneNumberResponse->ReverseLookupByPhoneNumberResult->ServiceResult->Country.'</b>
<br><b>Company: </b>'.$s->ReverseLookupByPhoneNumberResponse->ReverseLookupByPhoneNumberResult->ServiceResult->CompanyName.'</b>
<br><b>Remaining hits: </b>'.$s->SubscriptionInfo->RemainingHits.'</b>
</div>';
?>
Step 4- Run the sample
Open Account list, edit one of them, you can see the "Lookup Reverse Phone Information" button. Click on it to explore the information behind the number.
Good luck and Have fun!
Dan
References
1. StrikeIron StrikeIron Reverse Phone and Address Lookup:
2. SugarCRM Enhanced Studio


LinkBack URL
About LinkBacks



Reply With Quote

Bookmarks