Web services SugarCRM-如何用web服务响应填充某些字段?
我有我的Web services SugarCRM-如何用web服务响应填充某些字段?,web-services,sugarcrm,Web Services,Sugarcrm,我有我的index.php文件,该文件正在用sugar调用web服务,当我在本地Apache上运行它时,它返回我作为响应。结果是OK: <soapenv:Envelope <soapenv:Body> <ns:CommandResponseData> <ns:Operation name="BalanceAdjustment"> </ns:Operation> </ns:CommandResponseData> &l
index.php
文件,该文件正在用sugar调用web服务,当我在本地Apache上运行它时,它返回我作为响应。结果是OK:
<soapenv:Envelope <soapenv:Body> <ns:CommandResponseData>
<ns:Operation name="BalanceAdjustment"> </ns:Operation>
</ns:CommandResponseData> </soapenv:Body> </soapenv:Envelope>
稍后我应该能够对此做出更详细的回答。但是,基本上您可以使用与我在中描述的类似的技术,也就是说,我建议使用定制的可安装包将其添加到SugarCRM中,将新的JavaScript文件注入联系人模块
DetailView
,使用JavaScript将按钮动态注入页面(而不是编辑任何核心的SugarCRM文件),并让该按钮对外部脚本执行AJAX请求以获取数据。您希望填充DetailView
上的哪个字段?您无法从DetailView
编辑联系人记录,因此如果您想在联系人上动态设置某个字段,您必须从EditView
进行编辑,或者您需要额外的代码来使用自定义SugarCRM入口点更新联系人记录。您好,谢谢您的回答。没关系,我可以从EditVIew开始,我也可以。仍然存在问题:)我只需要一些简单的开始指南,我想从index.php文件中得到这个响应,并将它放在某个模块的某个字段中,稍后我将正确解析它。我只需要指导如何绑定按钮、web服务请求和将web服务响应放在某个字段中。谢谢你。无论何时,如果你有时间,我都会试着看一看这篇文章并给出回复。这将非常类似于另一个问题,但我将包括jQuery,因为这使使用AJAX和更新DOM变得更加容易。在EditView
上执行此操作会更简单,因此我建议在那里执行此操作。
<?php
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
require_once('include/json_config.php');
require_once('include/MVC/View/views/view.detail.php');
class ContactsViewDetail extends ViewDetail
{
function ContactsViewDetail()
{
parent::ViewDetail();
}
function display()
{
$this->dv->defs['templateMeta']['form']['buttons'][101] = array (
'customCode' => '<input title="Call" accesskey="{$APP.LBL_PRINT_PDF_BUTTON_KEY}" class="button" onClick="javascript:CustomFunctionHere();" name="tckpdf" value="Call" type="button">');
parent::display();
}
}
?>
<?php
include_once 'CommandRequestData.php';
include_once 'CommandResponseData.php';
$client = new SoapClient("http://127.0.0.1:8181/TisService?WSDL", array(
"trace" => 1, // enable trace to view what is happening
"exceptions" => 1, // disable exceptions
"cache_wsdl" => 0) // disable any caching on the wsdl, encase you alter the wsdl server
);
$req = new CommandRequestData();
$req->Environment->Parameter[0]->name = "ApplicationDomain";
$req->Environment->Parameter[0]->value = "CAO_LDM_00";
$req->Environment->Parameter[1]->name = "DefaultOperationNamespace";
$req->Environment->Parameter[1]->value = "CA";
$req->Command->Operation->namespace = "CA";
$req->Command->Operation->name = "BalanceAdjustment";
$req->Command->Operation->ParameterList->StringParameter[0]->name = "CustomerId";
$req->Command->Operation->ParameterList->StringParameter[0]->_ = "387671100009";
$req->Command->Operation->ParameterList->IntParameter[0]->name = "AmountOfUnits";
$req->Command->Operation->ParameterList->IntParameter[0]->_ = "1000";
$req->Command->Operation->ParameterList->IntParameter[1]->name = "ChargeCode";
$req->Command->Operation->ParameterList->IntParameter[1]->_ = "120400119";
try {
$result = $client->ExecuteCommand($req);
$result->CommandResult->OperationResult->Operation->name . "<br /><br />";
}
catch(SoapFault $e){
echo "<br /><br />SoapFault: " . $e . "<br /><br />";
}
catch(Exception $e){
}
echo "<p>Response:".htmlspecialchars($client->__getLastResponse())."</p>";
?>