• 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)
    {
    }
    }
     }
    
  • 相关阅读:
    JavaScript constructor prototyoe
    bootstrap固定响应式导航
    跨浏览器事件处理程序
    原生JS实现字符串分割
    关于css里的class和id
    js动态创建表格方法
    关于css的默认宽度
    js字符串大小写转换
    C++类的一个重要成员:静态成员(二)——静态成员的定义
    C++ 类的一个重要成员:静态成员(一)
  • 原文地址:https://www.cnblogs.com/hellohongfu/p/1894030.html
Copyright © 2020-2023  润新知