0

I have my index.php 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:

<soapenv:Envelope   <soapenv:Body> <ns:CommandResponseData> 
 <ns:Operation  name="BalanceAdjustment"> </ns:Operation>  
</ns:CommandResponseData> </soapenv:Body> </soapenv:Envelope>

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).

I created new button (which does not do anything currently )

I created button in view.detail.php.

<?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();
    }
}
?>

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 htmlspecialchars($client->__getLastResponse())

this is the whole index.php file that I am using currently to call some web service.

    <?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>";
    ?>
Veljko
  • 1,708
  • 12
  • 40
  • 80
  • I should be able to make a more detailed answer for this later. But, basically you can use a similar technique as the one I described in http://stackoverflow.com/questions/15254673/sugarcrm-how-to-get-popup-when-click-on-save-button/15259436#15259436 That is, I'd recommend adding this into SugarCRM using a custom installable package, injecting a new JavaScript file onto the Contacts module `DetailView`, dynamically inject the button into the page using JavaScript (as opposed to editing any core SugarCRM files), and have that button do an AJAX request to your external script to get the data. – Kyle Lowry Mar 07 '13 at 20:13
  • What field on the `DetailView` do you want to populate, exactly? You can't edit Contact records from the `DetailView`, so if you want to set some field on a Contact equal to something dynamically, you will either have to do it from the `EditView` or you will need additional code to update the Contact record using a custom SugarCRM entrypoint. – Kyle Lowry Mar 07 '13 at 20:15
  • hello, thank you for answer. It is OK I can do it from EditVIew it is OK with me. Still remains problem:) – Veljko Mar 07 '13 at 20:41
  • I just need some guidance for the start simple want to get this response from my index.php file and put it in some whatever field of some module-later I will parse it properly. I just need guide how to bind button,web service request and put web service response in some field. thank you..whenever and if you have time – Veljko Mar 07 '13 at 22:14
  • I will try to take a look at this and post a response. It will be very similar to that other question, but I'd include jQuery since that makes working with AJAX and updating the DOM so much easier. This would be more straightforward to do on the `EditView`, so I'd recommend doing this there. – Kyle Lowry Mar 08 '13 at 00:25
  • Yeah it is OK. EditView is OK also. If you can just give me the code how to put button there which will call my index.php file (contains Request and Response classes for invoking web service) and putting result in some field. Thank you!!!!!! – Veljko Mar 08 '13 at 00:31
  • Hi again, I updated my question with index.php whole file that I am using for invoking web service. I do not know maybe now you have clear picture what I want. index.php is working very well out of sugar I do not know how to "put" it in Sugar. Thank you – Veljko Mar 08 '13 at 00:55
  • I will take a look and try to get something together. It might take me a bit as my schedule is a bit cramped right now. SugarCRM has very specific syntax for getting these custom pieces in place, so it's not super straightforward to create the custom module. – Kyle Lowry Mar 08 '13 at 01:17
  • Hello Kyle I was wondering if you maybe have some time and update regarding this question? thank you – Veljko Mar 14 '13 at 07:24
  • Also have you ever had need to add column to gantt view? http://stackoverflow.com/questions/15403402/sugarcrm-how-to-add-additional-column-in-gant-view-for-project-tasks – Veljko Mar 14 '13 at 07:25

0 Answers0