locked
Lookup Field - Change based event??? RRS feed

  • Question

  • I've a lookup field to select the price list. I want to trigger an event on change event of this picklist (without pressing save button). Whenever a new price list is selected, i want to pass the price list name to an iframe on the same screen. How can i achieve that?


    Sohaib Ahmad [Business Management Solution Specialist] http://www.solutiontalk.blogspot.com
    Monday, February 2, 2009 8:56 AM

Answers

  • You will need to write JavaScript code on the OnChage event of the Lookup field. Read the PriceListId and pass it to the IFrame src property.
    The examples below will help.

    FROM THE MS CRM SDK HELP FILE:
    The following code example shows how to read values from a field of type Lookup.
    var lookupItem = new Array;
    // This will get the lookup for the attribute primarycontactid on the Account form.
    lookupItem = crmForm.all.primarycontactid.DataValue;
    
    // If there is data in the field, show it in a series of alerts.
    if (lookupItem[0] != null)
    {
       // The text value of the lookup.
       alert(lookupItem[0].name);
    
       // The GUID of the lookup.
       alert(lookupItem[0].id);
    
       // The entity type name.
       alert(lookupItem[0].typename);
    
    }

    FROM THE MS CRM SDK HELP FILE:
    The following code example shows you how to set the src for the IFRAME and pass the parameters.
    var params = crmForm.all.IFRAME_test.url;
    params = params.substr(params.indexOf('?'));
    var newTarget = "http://mysite/mypage.aspx";
    newTarget = newTarget + params;
    crmForm.all.IFRAME_test.src = newTarget ;


    Monday, February 2, 2009 9:51 AM