Note that there are some explanatory texts on larger screens.

plurals
  1. POSugarCRM - how to populate some field with web service response?
    text
    copied!<p>I have my <code>index.php</code> file which is calling web service out of sugar and it returns me as response when I run it on my local Apache this result which is OK:</p> <pre><code>&lt;soapenv:Envelope &lt;soapenv:Body&gt; &lt;ns:CommandResponseData&gt; &lt;ns:Operation name="BalanceAdjustment"&gt; &lt;/ns:Operation&gt; &lt;/ns:CommandResponseData&gt; &lt;/soapenv:Body&gt; &lt;/soapenv:Envelope&gt; </code></pre> <p>I created one additional button within Detail View which I plan to call this web service but I do not know how to bind that button, my index.php file and result from that web service to pack in some field. For testing purposes I would like to put this whole response on example in field Comment of Contact module: so that field Comment should Contain above whole response (I will later parse it).</p> <p>I created new button (which does not do anything currently )</p> <p>I created button in view.detail.php.</p> <pre><code>&lt;?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-&gt;dv-&gt;defs['templateMeta']['form']['buttons'][101] = array ( 'customCode' =&gt; '&lt;input title="Call" accesskey="{$APP.LBL_PRINT_PDF_BUTTON_KEY}" class="button" onClick="javascript:CustomFunctionHere();" name="tckpdf" value="Call" type="button"&gt;'); parent::display(); } } ?&gt; </code></pre> <p>I will appreciate help with this. So to recapitulate : With this my button I want to call my index.php file which will call web service and I want to set web service response in my field Comment (I am getting response in index.php file as <code>htmlspecialchars($client-&gt;__getLastResponse()</code>)</p> <p>this is the whole index.php file that I am using currently to call some web service.</p> <pre><code> &lt;?php include_once 'CommandRequestData.php'; include_once 'CommandResponseData.php'; $client = new SoapClient("http://127.0.0.1:8181/TisService?WSDL", array( "trace" =&gt; 1, // enable trace to view what is happening "exceptions" =&gt; 1, // disable exceptions "cache_wsdl" =&gt; 0) // disable any caching on the wsdl, encase you alter the wsdl server ); $req = new CommandRequestData(); $req-&gt;Environment-&gt;Parameter[0]-&gt;name = "ApplicationDomain"; $req-&gt;Environment-&gt;Parameter[0]-&gt;value = "CAO_LDM_00"; $req-&gt;Environment-&gt;Parameter[1]-&gt;name = "DefaultOperationNamespace"; $req-&gt;Environment-&gt;Parameter[1]-&gt;value = "CA"; $req-&gt;Command-&gt;Operation-&gt;namespace = "CA"; $req-&gt;Command-&gt;Operation-&gt;name = "BalanceAdjustment"; $req-&gt;Command-&gt;Operation-&gt;ParameterList-&gt;StringParameter[0]-&gt;name = "CustomerId"; $req-&gt;Command-&gt;Operation-&gt;ParameterList-&gt;StringParameter[0]-&gt;_ = "387671100009"; $req-&gt;Command-&gt;Operation-&gt;ParameterList-&gt;IntParameter[0]-&gt;name = "AmountOfUnits"; $req-&gt;Command-&gt;Operation-&gt;ParameterList-&gt;IntParameter[0]-&gt;_ = "1000"; $req-&gt;Command-&gt;Operation-&gt;ParameterList-&gt;IntParameter[1]-&gt;name = "ChargeCode"; $req-&gt;Command-&gt;Operation-&gt;ParameterList-&gt;IntParameter[1]-&gt;_ = "120400119"; try { $result = $client-&gt;ExecuteCommand($req); $result-&gt;CommandResult-&gt;OperationResult-&gt;Operation-&gt;name . "&lt;br /&gt;&lt;br /&gt;"; } catch(SoapFault $e){ echo "&lt;br /&gt;&lt;br /&gt;SoapFault: " . $e . "&lt;br /&gt;&lt;br /&gt;"; } catch(Exception $e){ } echo "&lt;p&gt;Response:".htmlspecialchars($client-&gt;__getLastResponse())."&lt;/p&gt;"; ?&gt; </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload