locked
Lookup fields from external system RRS feed

  • Question

  • I want to make a lookup from a external databas and present that in a field on for example account.

    I want this to be On-Line ie when a user opens a account form this field should be looked up via webservice/plugin?

    This information is for example Overall Invoiced amount made in a external system.

     

    How is this doable? Any ideas

     

    /peter

    Friday, August 8, 2008 2:28 PM

Answers

  • Thanks for quick response.

     

    I am not so familiar with ajax but i used your example and i am on my way...Again Thanks!

     

    Monday, August 11, 2008 6:22 AM

All replies

  • Create a custom webservice/webpage and expose the results as XML, use AJAX to do the request in the Form OnLoad and fill the attributes.

     

    This is an example to retrieve a currencyrate from an external webservice

     

    Code Snippet

    // Declare the variables.
    var sCurrency="";
    var mTotalAmount = crmForm.all.totalamount.DataValue;
    var mTotalCurrency = 0;
    var serverUrl = "http://www.webservicex.net";
    var serviceLocation = "/CurrencyConvertor.asmx/ConversionRate?";
    var serviceParameters = "FromCurrency=USD&ToCurrency=";
    var startTag = "<double xmlns=\"http://www.webserviceX.NET/\">";
    var endTag = "</double>";
    var exch = "";
    var valueStart = "";
    var valueEnd = "";

    // This is the picklist.
    switch (parseInt(event.srcElement.DataValue, 10))
    {
       case 1:
          sCurrency = "JPY";
          break;
       case 2:
          sCurrency = "GBP";
          break;
       case 3:
          sCurrency = "EUR";
          break;
    }

    // Instantiate at connection to the Web service and call the get method.
    var xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
    xmlhttp.open("get", serverUrl + serviceLocation + serviceParameters + escape(sCurrency), false);
    xmlhttp.send();

    // Parse the returned XML string.
    valueStart = xmlhttp.responseXML.xml.indexOf(startTag, valueEnd) + startTag.length;
    valueEnd = xmlhttp.responseXml.xml.indexOf(endTag, valueEnd+1);
    exch = xmlhttp.responseXML.xml.substring(valueStart, valueEnd);

    // Set the exchange rate on the custom attribute.
    crmForm.all.new_exchangerate.DataValue = parseFloat (exch);

    // Calculate and set the total sum in the selected currency.
    mTotalCurrency = mTotalAmount*(parseFloat(exch));
    crmForm.all.new_totalcurrency.DataValue = mTotalCurrency;

     

     

    Saturday, August 9, 2008 1:43 PM
  • Thanks for quick response.

     

    I am not so familiar with ajax but i used your example and i am on my way...Again Thanks!

     

    Monday, August 11, 2008 6:22 AM