locked
crm 2011 multi select lookup field RRS feed

  • Question

  • hi all,

    how to create multi select lookup field in ms crm 2011 uisng javascript.plaese any one help me asap.

    thanks in advace.

    thanks

    vijayasanthi

    Wednesday, April 3, 2013 9:43 AM

Answers

  • Hi,

    Try with these link,

    http://mscrm2011kt.blogspot.in/2012/04/mscrm-2011-lookup-multi-value-selection.html

    http://jianwang.blogspot.in/2009/08/crm-filtered-lookup-multi.html

    http://social.microsoft.com/Forums/en/crm/thread/6fbffd53-8df0-4799-89bb-4decb9a58129

    This might be helpful, if so mark this as "Answer" or "Vote as helpful"


    Sindu M

    Wednesday, April 3, 2013 9:53 AM
  • Hello Vijayasanthi check this links you get an idea

    http://rajeevpentyala.wordpress.com/tag/multi-select-lookup/

    http://mscrm2011kt.blogspot.in/2012/04/mscrm-2011-lookup-multi-value-selection.html


    ms crm

    Wednesday, April 3, 2013 10:10 AM

All replies

  • Hi,

    Try with these link,

    http://mscrm2011kt.blogspot.in/2012/04/mscrm-2011-lookup-multi-value-selection.html

    http://jianwang.blogspot.in/2009/08/crm-filtered-lookup-multi.html

    http://social.microsoft.com/Forums/en/crm/thread/6fbffd53-8df0-4799-89bb-4decb9a58129

    This might be helpful, if so mark this as "Answer" or "Vote as helpful"


    Sindu M

    Wednesday, April 3, 2013 9:53 AM
  • Hello Vijayasanthi check this links you get an idea

    http://rajeevpentyala.wordpress.com/tag/multi-select-lookup/

    http://mscrm2011kt.blogspot.in/2012/04/mscrm-2011-lookup-multi-value-selection.html


    ms crm

    Wednesday, April 3, 2013 10:10 AM
  • Thank you sindu,i was tryed all the above links,but  i didn't get solution.

    Monday, April 8, 2013 11:39 AM
  • Thank you dicaprio r,i was tryed all the above links,but  i didn't get solution.if you know new solution please share to me.

    Monday, April 8, 2013 11:41 AM
  • Hi, 

    Just brief what you find hard in that! 


    Sindu M

    Monday, April 8, 2013 11:44 AM
  • Hi 

    Please try this code 

    //Description:SetMultilookup in View
    
    function SetMultiLookUp() {
    
        /* Setting Multi Lookup Option for Lead */
        document.getElementById('new_leadid').setAttribute("lookuptypes", "4,2");
        document.getElementById('new_leadid').setAttribute("lookuptypeIcons", "/_imgs/ico_16_4.gif?ver=274421634:/_imgs/ico_16_2.gif?ver=274421634");
        document.getElementById('new_leadid').setAttribute("lookuptypenames", "lead:4:Lead,contact:2:Contact");
        /* Setting Multi Lookup Option for Contact */
        document.getElementById('new_contactid').setAttribute("lookuptypes", "4,2");
        document.getElementById('new_contactid').setAttribute("lookuptypeIcons", "/_imgs/ico_16_4.gif?ver=274421634:/_imgs/ico_16_2.gif?ver=274421634")
        document.getElementById('new_contactid').setAttribute("lookuptypenames", "lead:4:Lead,contact:2:Contact")
    }

    or 

    please refer the below link 

    http://mscrmgoodies.blogspot.in/2012/02/custom-lookup-in-crm-2011.html


    Thanks & Regards Dhamodharan R

    Monday, April 8, 2013 12:57 PM
  • hi sindu,

    i was used below code

    function  load()


    {


    document.getElementById("primarycontactid").setAttribute("lookupstyle", "multi");


    document.getElementById("primarycontactid").setAttribute("_lookupstyle", "multi");
    if(Xrm.Page.ui.getFormType()!=1)


    {
    var data=new Array();
    // I created a one multiline text box to save the lookup values.
    // set the multiline textbox visible equal to false.


    var store=Xrm.Page.getAttribute("new_textbox").getValue();


    data=store.split(";");

    // To get the "Target record type" Go to your form Customization ---> double click on your lookup--->Details--->Edit--->Here you can see "Target Record Type"


    var typename = "Target Record Type";

    var arr= new Array();
    var  i=0;
    var   j=0;


    for(i=0;i<((data.length-1)/2);i++)


    {


    arr[i] = new Object();


    arr[i].name = data[j];


    arr[i].id= data[j+1];


    arr[i].typename= typename ;


    j++;
    j=j+1;


    }


    crmForm.all["Your lookup Schema Name"].DataValue = arr;

    }


    }
    //Form OnSave

    function save()


    {




    var value = crmForm.all["Your lookup Schema Name"].DataValue;
    var s;
    var temp="";


    for (s=0;s<value.length;s++)


    {


    var temp2="";

    temp2=value[s].name+";"+value[s].id+";";
    temp=temp+""+temp2;

    }


    Xrm.Page.getAttribute("new_textbox").setValue(temp);


    Xrm.Page.getAttribute("Your lookup Schema Name").setValue(null);


    document.getElementById("Your lookup Schema Name").setAttribute("lookupstyle", "single");

    }

    as above code required customize one look field and one text field.here "primarycontactid" vailble,where can fetch this field.

    i have using two entities(account and contact),in account i was creted accountnamefield as a lookup(contact) and accountspec is a text field.in onload itself is not loading multi select dialog box.

    i used above code but its not working,please if there any changes means please help me.

    Tuesday, April 9, 2013 6:54 AM
  • Thank you for ur replay dhamodharan,i am new to the crm ,i am not able to understading the script,plaese can u explain me step by step.

    Tuesday, April 9, 2013 6:58 AM
  • Hi Sallagunla.vijayasanthi,

    Just do the following things in your paste code....

    In your load function,

    document.getElementById("primarycontactid").setAttribute("lookupstyle", "multi");


    document.getElementById("primarycontactid").setAttribute("_lookupstyle", "multi");

    Primarycontactid is the primary field's schema name of an entity. go to your entity->click fields-> there you find the unique identifier field as a lookup associated with the corresponding field say account with contact



    Sindu M

    Tuesday, April 9, 2013 7:11 AM
  • Thanks for ur replay sinu.that code already pasted in  form load,but is not working.i am new to crm please can u explain me to step by step.

    Tuesday, April 9, 2013 7:22 AM
  • Sure,

    And var store=Xrm.Page.getAttribute("new_textbox").getValue();

    "new_textbox" is the schema name of the multi line text-box which you created. As stated in comment line // To get the "Target record type" Go to your form Customization ---> double click on your lookup--->Details--->Edit--->Here you can see "Target Record Type.

     Found out your target record type and var typename = "Target Record Type"

    Replace it with "Target Record Type".

    crmForm.all["Your lookup Schema Name"].DataValue = arr;,out  In this line, Paste your look up schema name for which you want the look up to be multi look up 

    Hope it will help you!!!


    Sindu M


    • Edited by VidhiyaM Tuesday, April 9, 2013 7:36 AM
    Tuesday, April 9, 2013 7:28 AM
  • Create two fields

    1. Lookup

    2. text field to store selected guid values store

    assume that

    lookup field = new_lookupfield

    lookup entity relation schema name = new_lookupentityname

    text field to store guid's = new_lookupfield_guid

    Follow below steps.

    1. create a a jacvascript web resource with the below code

    2. here we have 2 functions. one is onload and onsave. call the function onload in form load and Onsave function in form save.

    3. save and publish and check.

    Code:

    function onload() 
    {

        document.getElementById("new_lookupfield").setAttribute("lookupstyle", "multi"); 
        var typename = "new_lookupentityname";

        if (Xrm.Page.ui.getFormType() != 1) 
    {
            var data = new Array();
            var store = Xrm.Page.getAttribute("new_lookupfield_guid").getValue();
            if (store != null) {
                data = store.split(";");
                var arr = new Array();
                var i = 0;
                var j = 0;
                for (i = 0; i < ((data.length - 1) / 2); i++) {
                    arr[i] = new Object();
                    arr[i].name = data[j];
                    arr[i].id = data[j + 1];
                    arr[i].typename = typename;
                    j++;
                    j = j + 1;
                }


               crmForm.all["new_lookupfield"].DataValue = arr;
               Xrm.Page.getAttribute("new_lookupfield").setSubmitMode("never");
            }
        }
    }
    //Form OnSave

    function onsave() 

        var value = crmForm.all["new_lookupfield"].DataValue;
        if (value != null) {
            var s;
            var temp = "";
            for (s = 0; s < value.length; s++) {
                var temp2 = "";
                temp2 = value[s].name + ";" + value[s].id + ";";
                temp = temp + "" + temp2;
            }
            Xrm.Page.getAttribute("new_lookupfield_guid").setValue(temp);
            Xrm.Page.getAttribute("new_lookupfield").setValue(null);
            document.getElementById("new_lookupfield").setAttribute("lookupstyle", "single");
        }

        


    Thanks in Advance Siva

    Tuesday, April 9, 2013 9:03 AM
  • Thank you sindu,i did as ur send code.but i got below error,please check it.

    Unable to get value of the property 'setAttribute': object is null or undefined.
    Unable to get value of the property 'DataValue': object is null or undefined.

    if you know the solution  of above errors,plaese can you help me.

    Tuesday, April 9, 2013 10:01 AM
  • HI,

    Try to set the debugger in the code!if am not wrong, the error arises in the load and save function.

    First will fix the load function

    function  load()


    {


    document.getElementById("primarycontactid").setAttribute("lookupstyle", "multi");


    document.getElementById("primarycontactid").setAttribute("_lookupstyle", "multi");
    if(Xrm.Page.ui.getFormType()!=1)

    Set the debugger in second line,

    like, function load()

    {

    debugger;

    and check where it shows error.

    does?crmForm.all["Your lookup Schema Name"].DataValue = arr; does?

    returns null value??

    Similarly set debugger  for onsave()

    document.getElementById("Your lookup Schema Name").setAttribute("lookupstyle", "single");

    Does? last line returns null value???


    Sindu M



    • Edited by VidhiyaM Tuesday, April 9, 2013 10:34 AM
    Tuesday, April 9, 2013 10:25 AM
  • i am getting below error.

    Microsoft Dynamics CRM Error Report Contents

    <CrmScriptErrorReport>
      <ReportVersion>1.0</ReportVersion>
      <ScriptErrorDetails>
       <Message>Unable to get value of the property 'setAttribute': object is null or undefined</Message>
       <Line>4</Line>
       <URL>/main.aspx?etc=1&extraqs=%3fetc%3d1%26pagemode%3diframe%26preloadcache%3d1365506811850&pagetype=entityrecord</URL>
       <PageURL>/main.aspx?etc=1&extraqs=%3fetc%3d1%26pagemode%3diframe%26preloadcache%3d1365506811850&pagetype=entityrecord</PageURL>
       <Function></Function>
       <CallStack>
       </CallStack>
      </ScriptErrorDetails>
      <ClientInformation>
       <BrowserUserAgent>Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; InfoPath.3; .NET4.0C; .NET4.0E)</BrowserUserAgent>
       <BrowserLanguage>en-us</BrowserLanguage>
       <SystemLanguage>en-us</SystemLanguage>
       <UserLanguage>en-us</UserLanguage>
       <ScreenResolution>1080x810</ScreenResolution>
       <ClientName>Web</ClientName>
       <ClientTime>2013-04-09T16:57:01</ClientTime>
      </ClientInformation>
      <ServerInformation>
        <OrgLanguage>1033</OrgLanguage>
        <OrgCulture>1033</OrgCulture>
        <UserLanguage>1033</UserLanguage>
        <UserCulture>1033</UserCulture>
        <OrgID>{53675F4C-ED95-E111-B629-000C29CD1191}</OrgID>
        <UserID>{76A22119-1248-E211-9D0E-005056AF3E02}</UserID>
        <CRMVersion>5.0.9690.3236</CRMVersion>
      </ServerInformation>
    </CrmScriptErrorReport>

    <CrmScriptErrorReport>
      <ReportVersion>1.0</ReportVersion>
      <ScriptErrorDetails>
       <Message>Unable to get value of the property 'DataValue': object is null or undefined</Message>
       <Line>4</Line>
       <URL>/%7B635011035230003236%7D/WebResources/new_mlooksave</URL>
       <PageURL>/userdefined/edit.aspx?etc=1&pagemode=iframe&preloadcache=1365506811850</PageURL>
       <Function>fireSaveEvent(iMode)</Function>
       <CallStack>
        <Function>fireSaveEvent(iMode)</Function>
        <Function>anonymous($p0){var$v_0=$get("crmForm"),$v_1=this.$$d_$78_3;$v_0.attachEvent("onsave",$v_1);var$v_2=true;$v_2=$v_0.fireSaveEvent($p0);$v_0.detachEvent("onsave",$v_1);return$v_2}</Function>
        <Function>anonymous(mode){var$v_0=$get("crmForm");if(!IsNull($v_0)){var$v_1=true;$v_1=$v_0.IsHtc;if(!IsNull($v_1))returnthis.$5C_3(mode)}returnthis.$5B_3(mode)}</Function>
        <Function>anonymous(mode,checkValid,forceSubmit,close,buildFullXml){if(this.$1Y_3)returnfalse;if(IsNull(buildFullXml))buildFullXml=false;this.$72_3(mode);var$v_0;if(this.IsValid(false)&&this.fireSaveEvent(mode)){var$v_1=this.get_objectTypeName();if($v_1==="appointment"||$v_1==="serviceappointment"){var$v_3=this.$5A_3(mode);if(!$v_3)returntrue}var$v_2=this.get_$1F_3();$v_0=this.BuildXml(false,!isNullOrEmptyString($v_2.value),buildFullXml,false,false);if($v_0===1||$v_0===3&&forceSubmit){var$v_4=this.get_$4t_3();$v_4.value=mode;var$v_5=this.get_$46_3();if(!IsNull($v_5))$v_5.value=this.$x_3?"true":"false";var$v_6=this.get_$3F_3();if(forceSubmit||!IsNull($v_6)&&!isNullOrEmptyString($v_6.value)){this.$7V_3();returntrue}}$v_0===3&&close&&this.CloseRecord(null);if($v_0===2)returnfalse}elsereturnfalse;Sys.Browser.agent===Sys.Browser.InternetExplorer&&window.focus();returnundefined}</Function>
        <Function>anonymous(){returnthis.SubmitCrmForm(1,true,false,false,false)}</Function>
        <Function>anonymous($p0,$p1){if(IsNull($p0))returnfalse;try{if(!IsNull($p0[$p1])){$p0[$p1]();returntrue}elseif(Sys.UI.Control.isInstanceOfType($p0)){var$v_0=$get($p0.get_id());$v_0[$p1]();returntrue}}catch($$e_3){}returnfalse}</Function>
        <Function>anonymous(form){var$v_0="Save";if(Mscrm.FormProxyForRibbon.isInstanceOfType(form)){form=form.get_crmFormControl();Mscrm.RibbonActions.$M(form,$v_0);return}Mscrm.RibbonActions.$6(form,$v_0)}</Function>
        <Function>anonymous($p0,$p1,$p2,$p3){Mscrm.CrmHeader.setScriptFile(Mscrm.CrmUri.create($p1),true);for(var$v_0=window,$v_1=$p0.split("."),$v_2=0;$v_2<$v_1.length;$v_2++)if($v_0)$v_0=$v_0[$v_1[$v_2]];if(!IsNull($v_0)&&typeof$v_0===Mscrm.TypeNames.functionType){var$v_3=this.$CN_1($p2,$p3);return$v_0.apply(null,$v_3)}returnnull}</Function>
        <Function>anonymous($p0,$p1,$p2,$p3){var$v_0=this.getCommandDefinition($p0,$p1);if(IsNull($v_0)||IsNull($v_0.Actions))returnfalse;for(var$v_1=0;$v_1<$v_0.Actions.length;$v_1++){var$v_2=$v_0.Actions[$v_1];switch($v_2.ActionType){case2:this.$DF_1($v_2.Attributes);break;case3:var$v_3=$v_2.Attributes;this.$9w_1($v_3.FunctionName,$v_3.Library,$v_2.Parameters,$p2);break;case1:this.$DG_1($v_2.Attributes,$v_2.Parameters);break}}returntrue}</Function>
        <Function>anonymous($p0,$p1,$p2){var$v_0=this.parseCommandFromRibbon($p0),$v_1=this.$7s_1($v_0.command,$v_0.entityLogicalName,$p1,$p2),$v_2=$p1;if(!IsNull($v_2)&&!isNullOrEmptyString($v_2.PopulationXML)&&!$v_2.SuppressCommandIncludes){var$v_3=null;if($v_0.entityContext==="Form"){var$v_4=$find("crmFormSelector");if($v_4)$v_3=$v_4.get_currentFormId()}$v_2.PopulationXML=this.$Ep_1($v_2.PopulationXML,$v_0.entityLogicalName,$v_3)}return$v_1}</Function>
        <Function>anonymous($p0,$p1,$p2){if(this.$1w_1&&!this.$1w_1.$3k_1)returnthis.$1w_1.handleCommand($p0,$p1,$p2);returnfalse}</Function>
        <Function>anonymous(handler,commandId,properties,sequenceNumber){returnhandler.handleCommand(commandId,properties,sequenceNumber)}</Function>
        <Function>anonymous($p0,$p1,$p2){var$v_0=this.$2R_0[$p0];if(CUI.ScriptUtility.isNullOrUndefined($v_0))returnfalse;elseif(Array.isInstanceOfType($v_0)){for(var$v_1=$v_0,$v_2=false,$v_3=0;$v_3<$v_1.length;$v_3++){var$v_4=$v_1[$v_3];if(this.callCommandHandler($v_4,$p0,$p1,$p2))$v_2=true}return$v_2}elsereturnthis.callCommandHandler($v_0,$p0,$p1,$p2)}</Function>
        <Function>anonymous(commandId,properties){returnthis.$DE_0(commandId,properties,this.getNextSequenceNumber())}</Function>
        <Function>anonymous(commandId,properties,commandInfo,root){returnthis.$10_1.executeCommand(commandId,properties)}</Function>
        <Function>anonymous($p0){if(CUI.ScriptUtility.isNullOrUndefined($p0.$4_1))return;$p0.$7Q_1=this.$DU_1();var$v_0=$p0.get_commandInfo();$v_0.CommandId=$p0.$4_1;$v_0.RootId=this.$4_0;$v_0.RootType=this.get_rootType();!CUI.ScriptUtility.isNullOrUndefined(this.$26_1)&&this.$26_1.executeRootCommand($p0.$4_1,$p0.$32_1,$v_0,this)}</Function>
        <Function>anonymous($p0){this.$7s_1($p0);returntrue}</Function>
        <Function>anonymous($p0){if($p0.$I_1!==11){$p0.get_commandInfo().RootLocation=$p0.$I_1===2?"UpperRibbon":"LowerRibbon";if($p0.$I_1===2){var$v_0=$p0.$32_1;$p0.get_commandInfo().TabId=$v_0.NewContextId}}returnCUI.Root.prototype.$2n_0.call(this,$p0)}</Function>
        <Function>anonymous($p0){this.$2n_0($p0)&&!CUI.ScriptUtility.isNullOrUndefined(this.$M_0)&&this.$M_0.$Ay_0($p0);this.$Am_0($p0)}</Function>
        <Function>anonymous($p0){this.$2n_0($p0)&&!CUI.ScriptUtility.isNullOrUndefined(this.$M_0)&&this.$M_0.$Ay_0($p0);this.$Am_0($p0)}</Function>
       </CallStack>
      </ScriptErrorDetails>
      <ClientInformation>
       <BrowserUserAgent>Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; InfoPath.3; .NET4.0C; .NET4.0E)</BrowserUserAgent>
       <BrowserLanguage>en-us</BrowserLanguage>
       <SystemLanguage>en-us</SystemLanguage>
       <UserLanguage>en-us</UserLanguage>
       <ScreenResolution>1080x810</ScreenResolution>
       <ClientName>Web</ClientName>
       <ClientTime>2013-04-09T16:58:16</ClientTime>
      </ClientInformation>
      <ServerInformation>
        <OrgLanguage>1033</OrgLanguage>
        <OrgCulture>1033</OrgCulture>
        <UserLanguage>1033</UserLanguage>
        <UserCulture>1033</UserCulture>
        <OrgID>{53675F4C-ED95-E111-B629-000C29CD1191}</OrgID>
        <UserID>{76A22119-1248-E211-9D0E-005056AF3E02}</UserID>
        <CRMVersion>5.0.9690.3236</CRMVersion>
      </ServerInformation>
    </CrmScriptErrorReport>

     

    Tuesday, April 9, 2013 11:29 AM
  • hi, 

    try to debug the javascript alone.In line 4, what type of code u are having??


    Sindu M


    • Edited by VidhiyaM Tuesday, April 9, 2013 11:39 AM
    Tuesday, April 9, 2013 11:38 AM
  • Hi, 

         I need multi select lookup functionality in CRM Fall-2013, how to achieve this. 

         Please can anyone help me to resolve this issue.


    Nagaraj


    Friday, October 18, 2013 1:16 PM
  • Hi ,

    I achevied multiselect lookup

    function  load()
    {
      document.getElementById('new_product').getElementsByTagName('div')[0].click();
      document.getElementById("new_product_i").setAttribute("lookupstyle", "multi");
      Xrm.Page.getAttribute("new_product").setValue(null);

     if(Xrm.Page.ui.getFormType()!=1)
    {
    var data=new Array();
    // I created a one multiline text box to save the lookup values.
    // set the multiline textbox visible equal to false.
    var store=Xrm.Page.getAttribute("new_textbox").getValue();
    if(store!=null)
    {
    data=store.split(";");
    alert(data);
    // To get the "Target record type" Go to your form Customization ---> double click on your lookup--->Details--->Edit--->Here you can see "Target Record Type"
    var typename = "Product";
     var arr= new Array();
     var  i=0;
    var   j=0;
    var name="";
    for(i=0;i<((data.length)/2);i++)
    {
    arr[i] = new Object();
    arr[i].name = data[j];
    arr[i].id = data[j+1];
    arr[i].entityType = 1024;
    if(i==0)
    {
    name= data[j];
    }
    else
    {
    name=name+"; "+ data[j];
    }
    j++;
    j=j+1;
    }
    alert(name);
    //Xrm.Page.getAttribute("new_product").setValue(name);
    document.getElementById('new_product_i_ledit_multi').value=name;
    }
    }
    Xrm.Page.getControl("new_description").setFocus(true);
    }



    //Form OnSave

    function save()
    {
      var lists = new Array();
      var item= new Array();
      var selected_list_nodes = document.getElementById("new_product_lookupDiv").getElementsByTagName('ul')[0].childNodes;
       for(i=0; i < selected_list_nodes.length - 1; i++)
       {
        item_node = selected_list_nodes[i].getElementsByTagName('span')[0];
        item[i] = new Object();
        item[i].id=item_node.getAttribute('oid');
        item[i].name=item_node.getAttribute('title');
        item[i].entityType=1024;
       }
     //lists=Xrm.Page.getAttribute("new_product").getValue();
    //setting values to description field
    if(item!=null)
    {
    var s1;
    var temp1="";
    for (s1=0;s1<item.length;s1++)
    {
      var temp3="";
    if(s1==item.length-1)
    {
      temp3=item[s1].name;
    }
    else
    {
      temp3=item[s1].name+";";
    }
      temp1=temp1+" "+temp3;
    }
    Xrm.Page.getAttribute("new_description").setValue(temp1);
    }

    //setting values to new_textbox field

    if(item!=null)
    {
    var s;
    var temp="";
    var productrange="";
    for (s=0;s<item.length;s++)
    {
    var temp2="";
    if(s==item.length-1)
    {
    temp2=item[s].name+";"+item[s].id;
    }
    else
    {
    temp2=item[s].name+";"+item[s].id+";";
    }
    temp=temp+""+temp2;
    /*
    {

        //get product id
        var productID = lists[s].id;
        alert(productID);
         var xml = "<?xml version='1.0' encoding='utf-8'?>" +
        "<soap:Envelope xmlns:soap='http://schemas.xmlsoap.org/soap/envelope/'" +
        " xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'" +
        " xmlns:xsd='http://www.w3.org/2001/XMLSchema'>" +
        Xrm.Page.context.getAuthenticationHeader() +
        "<soap:Body>" +
        "<Retrieve xmlns='http://schemas.microsoft.com/crm/2007/WebServices'>" +
        "<entityName>product</entityName>" +
        "<id>" + productID + "</id>" +
        "<columnSet xmlns:q1='http://schemas.microsoft.com/crm/2006/Query' xsi:type='q1:ColumnSet'>" +
            "<q1:Attributes>" +
                "<q1:Attribute>name</q1:Attribute>" +  "<q1:Attribute>new_productrange_value</q1:Attribute>"+ "</q1:Attributes>" +
        "</columnSet>" +    
        "</Retrieve>" +
        "</soap:Body>" +
        "</soap:Envelope>";
        alert("hello");
        var xmlHttpRequest = new ActiveXObject("Msxml2.XMLHTTP");
        xmlHttpRequest.Open("POST", "/mscrmservices/2007/CrmService.asmx", false);
        xmlHttpRequest.setRequestHeader("SOAPAction", "http://schemas.microsoft.com/crm/2007/WebServices/Retrieve");
        xmlHttpRequest.setRequestHeader("Content-Type", "text/xml; charset=utf-8");
        xmlHttpRequest.setRequestHeader("Content-Length", xml.length);
        xmlHttpRequest.send(xml);
        var resultXml = xmlHttpRequest.responseXML;

        var errorCount = resultXml.selectNodes('//error').length;

        if (errorCount != 0)
     {
            var msg = resultXml.selectSingleNode('//description').nodeTypedValue;
            //alert(msg);
        }
        //Display the retrieved value.
        else
     {
            if(resultXml.selectSingleNode("//q1:new_productrange_value")!=null)
      {
           productrange= productrange+ resultXml.selectSingleNode("//q1:new_productrange_value").nodeTypedValue;
           Xrm.Page.getAttribute("new_productrange_value").setValue(productrange);
       alert(productrange);
      }
     }
     }
    */
    }
    alert(temp);
    Xrm.Page.getAttribute("new_textbox").setValue(temp);
    Xrm.Page.getAttribute("new_product").setValue(null);
    document.getElementById("new_product").setAttribute("lookupstyle", "single");
    }
    else
    {
    Xrm.Page.getAttribute("new_textbox").setValue("");
    }

    }


    vandana

    Thursday, October 31, 2013 9:17 AM