Hi guys
what am I going to do?
1.add a customized button in a Account module , the way I followed :How to consume ZIP Code Information Web service from StrikeIron within SugarCRM
2.click the button, invoke the webservice method:GetZIPCodeInfo in http://wslite.strikeiron.com/zipcode...Lite.asmx?wsdl
how to repeat the problem I met?
- Prerequisites:
1. Sugar CRM 5.2 or later
2. Enhanced Studio 2.2.1 or later.
The steps
In general, we have 4 steps to complete this sample:
1. Create "Custom Code field" for a Sugar Accoun. When this step is completed, you will have a button called "Verify Postal Code" that will help to verify a ZIP/Postal code of a customer.
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 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 SIZIPChecker for field name, SI ZIP Checker for Display label.
Enter the following code to Code text value:
PHP Code: Code:
echo '
<script>
var xmlhttp;
function invoke() {
alert("Progress started");
xmlhttp=GetXmlHttpObject();
if (xmlhttp==null)
{
alert ("Your browser does not support XMLHTTP!");
return;
}
var url="index.php?entryPoint=sizipcode?zipcode='.$bean->billing_address_postalcode.'";
alert("url="+url);
xmlhttp.onreadystatechange=stateChanged;
xmlhttp.open("GET",url,true);
xmlhttp.send(null);
}
function stateChanged()
{
if (xmlhttp.readyState==4)
{
document.getElementById("div_info").innerHTML=xmlhttp.responseText;
}
}
function GetXmlHttpObject()
{
if (window.XMLHttpRequest)
{
// code for IE7+, Firefox, Chrome, Opera, Safari
return new XMLHttpRequest();
}
if (window.ActiveXObject)
{
// code for IE6, IE5
return new ActiveXObject("Microsoft.XMLHTTP");
}
return null;
}
</script>
<div style="align:left">
<input type="button" id="botton" name="button" value="Verify postal code" onclick="invoke();"></div>
<div id="div_info">
</div>
'; This php code will help create a button called "Verify Postal Code". When user click on it, it will use a php page: "/sugarcrm/sizipcode.php" to consume the StrikeIron ZIP Code Information web services for some location info.
please add this line : Code:
'sizipcode' => array('file' => 'sizipcode.php', 'auth' => true) , in sugarcrm-5.2.0e\htdocs\sugarcrm\include\MVC\Controller\entr y_point_registry.php .( this line resolves "Not A Valid Entry Point" problem)
Step 2 - Determine where to place above button
We decided to place it to the Account EditView, the place where user can edit a Account detail information like Name, billing address, shipping address...
Navigate to Layout on the same tree, drop down the nodes, find EditView node, click on it. Drag the "New Row" to Address Information, below Billing Street. We would like the user to see this button near the billing postal code. Then drag the SIZIPChecker field to this empty panel. Click Save and Deploy.
Step 3 - Create a Web service client as a php page.
Create a file named "sizipcode.php", edit the file with the following code, and copy it to SugarCRM root folder (like E:\Program Files\sugarcrm-5.2.0\htdocs\sugarcrm):
PHP Code:
Code:
<?php
require_once('include/nusoap/nusoap.php');
$client = new soapclient('http://wslite.strikeiron.com/zipcodeinfolite01/ZIPCodeInfoLite.asmx?wsdl',true);
$aryPara = array('ZIPCode'=> $_REQUEST['zipcode']);
$return = $client->call('GetZIPCodeInfo',$aryPara);
echo '<div>ZIP code information:</div>
<div id="div_info"><b>Result</b>:'.$return['GetZIPCodeInfoResult']['ServiceStatus']['StatusDescription'].'
<br><b>City: </b>'.$return['GetZIPCodeInfoResult']['ServiceResult']['ZIPCodes']['ZIPCodeData']['PreferredCityName'].'</b>
<br><b>State: </b>'.$return['GetZIPCodeInfoResult']['ServiceResult']['ZIPCodes']['ZIPCodeData']['State'].'</b>
<br><b>County: </b>'.$return['GetZIPCodeInfoResult']['ServiceResult']['ZIPCodes']['ZIPCodeData']['County'].'</b>
</div>';
?> after I click the "Verify postal code" button , it retruns me the website of sugarcrm, which is wrong. That is the problem I met, if you know what is wrong with my code, plz tell me, thanks
Bookmarks