1:N 关系 视图查找



var nnId ="contact_customer_accounts";//"new_account_contact"; // entity N:N relationship id

var lookupTypeCode = 2; // entity type code

var lookupViewId = "A2D479C5-53E3-4C69-ADDD-802327E67A0D"; // the view id of referenced entity



var lookupSrc = "/" + ORG_UNIQUE_NAME + "/ISV/lookup/lookupmulti.aspx";

var lookupArg = "/" + ORG_UNIQUE_NAME + "/_root/homepage.aspx?etc=" + lookupTypeCode +"&viewid=" + lookupViewId;

var lookupEntityTypeCode;

var navId =document.getElementById("navContacts");

 //document.getElementById("nav" + nnId);

if (navId != null)

{

 var la = navId.onclick.toString();

 la = la.substring(la.indexOf("loadArea"), la.indexOf(";"));



 navId.onclick = function()

 {

     eval(la);

     var areaId = document.getElementById("areaContactsFrame");

     if(areaId != null)

     {

         areaId.onreadystatechange = function()

         {

             if (areaId.readyState == "complete")

             {

                 var frame = frames[window.event.srcElement.id];

                 var li = frame.document.getElementsByTagName("li"); 



                 for (var i = 0; i < li.length; i++)

                 {

                     var action = li[i].getAttribute("action");

                     if(action != null && action.indexOf(nnId ) > 1)

                     {

                         lookupEntityTypeCode = action.substring(action.indexOf("\(")+1, action.indexOf(","));

                         li[i].onclick = CustomLookup;

                         break;

                     }

                 }

             }

         }

     }

 }

}



function CustomLookup()

{

var lookupItems =  window.showModalDialog(lookupSrc, lookupArg, "dialogWidth:800px; dialogHeight:600px;");



if (lookupItems)

{

if ( lookupItems.items.length > 0 )

{

var commandAssociate = new RemoteCommand("AssociateRecords", "AssociateOneToMany");



var i = 0;

var objs = lookupItems.items;

var iLength = objs.length;



for(i = 0; i < iLength; ++i)

{

commandAssociate.SetParameter("childType", lookupEntityTypeCode);

commandAssociate.SetParameter("childId", objs[i].id);

commandAssociate.SetParameter("parentType", crmFormSubmit.crmFormSubmitObjectType.value);

commandAssociate.SetParameter("parentId", crmFormSubmit.crmFormSubmitId.value);

commandAssociate.SetParameter("relationshipName", nnId);



if (!commandAssociate.Execute().Success)

{

break;

}

}

}





try

{

auto(nnId);

}

catch(e)

{

}

}

 }

你可能感兴趣的:(视图)