locked
Converting Single Entity Lookups to Multi Entity - Is it possible in 7.1 at all? RRS feed

  • Question

  • Hi devs,

    Any ideas about why the below code is not making a single entity lookup to multi entity lookup?

    I have a custom activity entity on which I have altered the "organizer" lookup html (using javascript) to make it multi-entity lookup.

    My JavaScript code to alter html is this:

    if (parent.document.getElementById('organizer') != null) {
                parent.document.getElementById("organizer").setAttribute("lookupstyle", "multi");
                parent.document.getElementById("organizer").setAttribute("lookuptypes", "1,2,4,8");
                parent.document.getElementById("organizer").setAttribute("lookuptypenames", "account:1:Account,contact:2:Contact,lead:4:Lead,systemuser:8:User");
                parent.document.getElementById("organizer").setAttribute("lookuptypeicons", "/_imgs/ico_16_1.gif:/_imgs/ico_16_2.gif:/_imgs/ico_16_4.gif:/_imgs/ico_16_8.gif");
            }

    Which when run modifies the html for "organizer" lookup as follows that I have copy-pasted from Developer Tools:


    <div 
    	id="organizer" 
    	data-attributename="organizer" 
    	data-formid="d68cfcbf-f142-4bbf-9be5-c96158ecfdcc" 
    	data-fdeid="PrimaryEntity" 
    	data-layout="0" 
    	tabindex="1140" 
    	isinline="true" 
    	lookupstyle="multi" 
    	lookupdialogmultipleselect="0" 
    	isinlinenewenabled="1" 
    	showasbreadcrumbcontrol="0" 
    	showglobalquickcreate="1" 
    	openfullform="0" 
    	addlookupimagebutton="" 
    	entitylogicalname="contact" 
    	entitydisplayname="Contact" 
    	entitytypecode="2" 
    	allowfilteroff="0" 
    	disablequickfind="0" 
    	disableviewpicker="0" 
    	disablemru="1" 
    	isdeduplookup="0" 
    	availableviewids="" 
    	resolveemailaddress="0" 
    	allowunresolvedpartiesonemailsend="0" 
    	defaultviewid="{E88CA999-0B16-4AE9-B6A9-9EDC840D42D8}" 
    	title="" 
    	class="ms-crm-Inline-Chrome partylist ms-crm-Inline-Chrome nvarchar" 
    	aria-describedby="organizer_c" 
    	lookuptypes="1,2,4,8" 
    	lookuptypenames="account:1:Account,contact:2:Contact,lead:4:Lead,systemuser:8:User" 
    	lookuptypeicons="/_imgs/ico_16_1.gif:/_imgs/ico_16_2.gif:/_imgs/ico_16_4.gif:/_imgs/ico_16_8.gif">
      <div class="ms-crm-Inline-Value ms-crm-Inline-Lookup" style="display: none;">
        <span>
          <span contenteditable="false" class="ms-crm-Inline-EmptyValue ms-crm-Inline-Lookup" id="organizer_lookupValue" title="">
            --
          </span>
          <div class="ms-crm-Inline-EditIcon" id="organizer_lookupSearchIconDiv" style="display: none;">
            <img src="/_imgs/imagestrips/transparent_spacer.gif" id="organizer_lookupSearchIcon" class="ms-crm-ImageStrip-search_normal ms-crm-InlineLookupEdit ms-crm-EditLookup-Image" alt="">
          </div>
          <div class="ms-crm-Inline-GradientMask">
          </div>
        </span>
      </div>
      <div class="ms-crm-Inline-Edit ms-crm-Inline-Lookup" style="display: block;" lookuptypes="8">
        <table id="organizer_lookupTable" cellpadding="0" cellspacing="0" lookupid="organizer" class="ms-crm-Lookup" aria-labelledby="organizer_c organizer_w" controlmode="normal" style="width: 100%;table-layout: fixed;">
          <tbody>
            <tr>
              <td valign="top">
                <div id="organizer_lookupDiv" role="list" ime-mode="auto" class="ms-crm-Lookup ms-crm-InlineLookupEdit" tabindex="0" title="" style="display: none;">
                  <ul class="ms-crm-InlineLookupEdit">
                    <li style="display: inline; white-space: nowrap;">
                      <span class="ms-crm-Lookup-Item" contenteditable="false" isinlinelookup="true">
                        <span class="ms-crm-LookupItem-Name" id="organizer_lookupEditSpan" title="">
                        </span>
                      </span>
                    </li>
                  </ul>
                </div>
                <label class="ms-crm-Hidden-NoBehavior" for="organizer_ledit">
                </label>
                <input class="ms-crm-InlineInput ms-crm-InlineLookupEdit" ime-mode="auto" type="text" id="organizer_ledit" maxlength="1000" style="display: block;">
              </td>
              <td class="ms-crm-InlineLookupEdit-Box">
              </td>
              <td class="Lookup_RenderButton_td" id="organizer_lookupSearch" style="vertical-align:top;width:22px;">
                <img src="/_imgs/search_normal.gif" id="organizer_i" alt="Select a value." class="ms-crm-InlineLookupEdit" title="Select a value.">
                <a href="#" id="organizer_a" tabindex="-1" title="Select a value.">
                </a>
              </td>
            </tr>
          </tbody>
        </table>
      </div>
      <span class="ms-crm-Inline-LockIcon" id="organizer_lock" style="display: none;">
        <img src="/_imgs/imagestrips/transparent_spacer.gif" class="ms-crm-ImageStrip-inlineedit_locked" alt="">
      </span>
      <span class="ms-crm-Inline-WarningIcon" title="" style="display: none;">
        <img src="/_imgs/imagestrips/transparent_spacer.gif" class="ms-crm-ImageStrip-inlineedit_warning" alt="Error" id="organizer_warn">
        <div id="organizer_w" class="ms-crm-Hidden-NoBehavior">
        </div>
      </span>
      <span id="organizer_warnSpan" class="ms-crm-Inline-WarningIcon" title="" style="display: none;">
        <img src="/_imgs/imagestrips/transparent_spacer.gif" class="ms-crm-ImageStrip-inlineedit_warning" alt="Error" id="organizer_warn">
        <div id="organizer_w" class="ms-crm-Hidden-NoBehavior">
        </div>
      </span>
    </div>

    The code was working fine in Dynamics CRM 2015 7.0 and older versions, but it is not taking effect in Dynamics 7.1 (Update 1) Online and upon requesting lookup dialog I only get disabled "Look for" field with default entity selected.

    


    blog: <a href="http://technologynotesforyou.wordpress.com">http://technologynotesforyou.wordpress.com</a> | skype: ali.net.pk



    • Edited by Khadim Ali Tuesday, August 11, 2015 12:53 PM
    Tuesday, August 11, 2015 9:32 AM

All replies

  • I believe that's because:

    1. Your code is 100% unsupported.

    2. New turbo forms were released.


    Dynamics CRM MVP
    My blog

    Tuesday, August 11, 2015 9:50 AM
    Moderator
  • Thanks Andrii for your response.

    I went through the link you provided. Overall, what I read it says that the new renderer

    • Has the same functionality and behavior
    • No fundamental changes made in terms of what the form does.
    • Focused on how the form load process can be optimized

    What I want to ask is if this unsupported way is really broken in 7.1 new rendering or am I missing something?



    blog: <a href="http://technologynotesforyou.wordpress.com">http://technologynotesforyou.wordpress.com</a> | skype: ali.net.pk


    • Edited by Khadim Ali Tuesday, August 11, 2015 12:40 PM
    Tuesday, August 11, 2015 12:40 PM
  • I pointed on it because:

    Examples of things that will break:

    • Any attempt to access DOM in the content iframe using JS, jQuery or other 3<sup>rd</sup> party libraries (document.getElementById() or jQuery selectors)
    • Creating a new HTML content in the parent window for persistent content (and assumed that the parent window was the main CRM iframe.
    • Window.load, parsing iframe/form URL
    • Attempting to use unsupported (non-XRM) APIs, especially undocumented ones that may have been shipped with CRM for internal usage only
    • Accessing window.parent() from a web resource that may assume for example there’s a variable set in the current window context.

    I believe that something could be changed in lookup control itself so tricks that worked before would not work anymore and you will have to rework your code to make it work using updated internal objects model.


    Dynamics CRM MVP
    My blog

    Tuesday, August 11, 2015 1:11 PM
    Moderator
  • Yeah, but as I pointed in my original post, I am able to access DOM in the form's iframe using parent object and this modifies the html for Organizer lookup like I did in previous versions. But this change is not taking effect actually when I click on the organizer lookup's lookup button to open a lookup dialog.

    I also tried below:

                    var theLookup = parent.$("#organizer_i");
                    if (theLookup.length > 0) {
                        var val = theLookup[0].getAttribute("lookuptypes");
                        if (val == null || val != "1,2,4,8") {
                            theLookup[0].setAttribute("lookupstyle", "multi");
                            theLookup[0].setAttribute("lookuptypes", "1,2,4,8");
                            theLookup[0].setAttribute("lookuptypenames", "account:1:Account,contact:2:Contact,lead:4:Lead,systemuser:8:User");
                            theLookup[0].setAttribute("lookuptypeicons", "/_imgs/ico_16_1.gif:/_imgs/ico_16_2.gif:/_imgs/ico_16_4.gif:/_imgs/ico_16_8.gif");
                            theLookup[0].setAttribute("defaulttype", "8");
                            //theLookup[0].setAttribute("createpermissiondictionary", "account:true,contact:true,lead:true,systemuser:true");
                        }
                    }
    <img src="/_imgs/search_normal.gif" id="organizer_i" alt="Select a value." class="ms-crm-InlineLookupEdit" title="Select a value." 
    	lookupstyle="multi" 
    	lookuptypes="1,2,4,8" 
    	lookuptypenames="account:1:Account,contact:2:Contact,lead:4:Lead,systemuser:8:User" 
    	lookuptypeicons="/_imgs/ico_16_1.gif:/_imgs/ico_16_2.gif:/_imgs/ico_16_4.gif:/_imgs/ico_16_8.gif" 
    	defaulttype="8">



     

    blog: <a href="http://technologynotesforyou.wordpress.com">http://technologynotesforyou.wordpress.com</a> | skype: ali.net.pk


    • Edited by Khadim Ali Tuesday, August 11, 2015 2:27 PM
    Tuesday, August 11, 2015 2:24 PM
  • Yeah, that's why I mentioned that your customizations are unsupported and there is no guarantees that unsupported customization would not be broken during installation of new SP/Rollup. I believe that's the point.

    Dynamics CRM MVP
    My blog

    Tuesday, August 11, 2015 2:33 PM
    Moderator
  • Hi Ali,

         it is working fine, you can make it to multi entity lookup, for the current 7.0 version there is not changes needed to be done but for 7.1 you need to make some changes in the code so that it will turn it in to multi select lookup.

    Tuesday, September 22, 2015 7:03 AM
  • Hi Vicky,

    And what are those changes?


    blog: http://technologynotesforyou.wordpress.com | skype: ali.net.pk

    Tuesday, September 22, 2015 7:06 AM
  • Hi Ali,

         Just use this code instated of your previous code

    Xrm.Page.ui.controls.getByName("organizer").getAttribute().$2_2.$9F_3 = [1,2,4, 8].

    it will work.

    Wednesday, September 23, 2015 7:54 AM