3

crm 2013 に問題があります。フィルタリングされた (たとえば) 請求先アカウントに fetchXML を使用しています。私たちのチームが CRM 2011 ですべて正常に動作しているときに、CRM 2013 に移行し、関連するプロジェクトを追加する際に問題が発生しました。

retrieveRecord( 
                recordId,
                "xxx_project",
                null,
                null,
                function (result) {
                    var xId = (result.xxx_Customer) ? result.xxx_xCustomer : "";

                    // Fetch to retrieve filtered data.
                    var fetch =
                    "<fetch version='1.0' output-format='xml-platform' mapping='logical' distinct='false'>" +
                    " <entity name='xxx_billingaccount'>" +
                    "   <attribute name='xxx_billingaccountid' />" +
                    "   <attribute name='xxx_name' />" +
                    "   <attribute name='statecode' />" +
                    "   <attribute name='xxx_xid' />" +
                    "   <order attribute='xxx_name' descending='false' />" +
                    "   <filter type='and'>" +
                    "       <condition attribute='xxx_xid' operator='eq' value='" + xId + "' />" +
                    "   </filter>" +
                    " </entity>" +
                    "</fetch>";

                    // Columns to display in the custom view (make sure to include these in the fetch query).
                    var layout = "<grid name='resultset' object='1' jump='xxx_name' select='1' icon='0' preview='1'>" +
                    "  <row name='result' id='xxx_billingaccountid'>" +
                    "    <cell name='xxx_name' width='150' />" +
                    "    <cell name='statecode' width='150' />" +
                    "    <cell name='xxx_xid' width='150' />" +
                    "  </row>" +
                    "</grid>";

                    SDK.Entity.BillingAccount.displayFilteredLookupView(gridTypeCode, gridControl, fetch, layout, "Filtered by Customer ID Billing Accounts");
                },
                SDK.Entity.BillingAccount.errorHandler);

displayFilteredLookupView: function (gridTypeCode, gridControl, fetch, layout, viewName) {

        var viewId = "{3D02B064-4D8D-4E7C-B919-965D5D2C225D}";
        var relName = gridControl.GetParameter("relName"),
            roleOrd = gridControl.GetParameter("roleOrd");

        // Creates the custom view object.
        var customView = {
            fetchXml: fetch,
            id: viewId,
            layoutXml: layout,
            name: viewName,
            recordType: gridTypeCode,
            Type: 0
        };

        // Pops the lookup window with our view injected.
        var lookupItems = LookupObjects(null, "multi", gridTypeCode, 0, null, "", null, null, null, null, null, null, viewId, [customView], null, null, null, null, null, null, 1);

        // Once the lookup window is closed, we need the parent record ID and ETC before associating selected records.
        if (lookupItems && lookupItems.items.length > 0) {
            var parent = GetParentObject(),
                parentId = parent.id,
                parentTypeCode = parent.objectTypeCode;

            //associates the selected records 
            AssociateObjects(parentTypeCode, parentId, gridTypeCode, lookupItems, IsNull(roleOrd) || roleOrd == 2, "", relName);
        }

    },

この問題を解決するためにパスを検索していたときに、1 つのリンクhttp://community.dynamics.com/crm/f/117/p/119416/248998.aspxを見つけました。これは私たちのプロジェクトにとって非常に悪いことです。

多分誰もがこの問題で私を助けることができます...

4

2 に答える 2

4

LookupObjects関数をLookupObjectsWithCallback関数に変更する必要があります。

LookupObjectsWithCallback(callbackReference, null, "multi", gridTypeCode, 0, null, "", null, null, null, null, null, null, viewId, [customView], null, null, null, null, null, null, 1);

そして、次のようなコードで呼び出します。

   displayFilteredLookupView: function (gridTypeCode, gridControl, fetch, layout, viewName) {

        var viewId = "{3D02B064-4D8D-4E7C-B919-965D5D2C225D}";
        var relName = gridControl.GetParameter("relName"),
            roleOrd = gridControl.GetParameter("roleOrd");

        // Creates the custom view object.
        var customView = {
            fetchXml: fetch,
            id: viewId,
            layoutXml: layout,
            name: viewName,
            recordType: gridTypeCode,
            Type: 0
        };
        // Get all necessary parameters, that you want to pass into your callbackReference function.
        SDK.Entity.BillingAccount.callbackReference.gridTypeCode = gridTypeCode;
        SDK.Entity.BillingAccount.callbackReference.relName = relName;
        SDK.Entity.BillingAccount.callbackReference.roleOrd = roleOrd;

        // Pops the lookup window with our view injected.
        LookupObjectsWithCallback(SDK.Entity.BillingAccount.callbackReference, null, "multi", gridTypeCode, 0, null, "", null, null, null, null, null, null, viewId, [customView], null, null, null, null, null, null, 1);                
    }

yourは、プロパティ、、、SDK.Entity.BillingAccount.callbackReferenceを持つオブジェクトです。callbackgridTypeCoderoleOrdrelName

 callbackReference: {

    callback: function (lookupItems) {

        // Once the lookup window is closed, we need the parent record ID and ETC before associating selected records.        
        if (lookupItems && lookupItems.items.length > 0) {
            var parent = GetParentObject(),
                parentId = parent.id,
                parentTypeCode = parent.objectTypeCode;

            //associates the selected records 
            AssociateObjects(parentTypeCode, parentId, SDK.Entity.BillingAccount.callbackReference.gridTypeCode, lookupItems, IsNull(SDK.Entity.BillingAccount.callbackReference.roleOrd) || SDK.Entity.BillingAccount.callbackReference.roleOrd == 2, "", SDK.Entity.BillingAccount.callbackReference.relName);
        }
    },
    gridTypeCode: null,
    roleOrd: null,
    relName: null
}
于 2014-03-12T18:06:29.837 に答える
0

上記の推奨事項を機能させることができませんでした。オブジェクト「callbackReference」を定義する方法を理解していないのだと思います。上記のコードを貼り付けると、Visual Studio からエラーが発生します。以下は、動作しなかったコードです。

var locAssocObjAction1 = {

    callback: function (lookupItems) {

        //debugger;
        // Once the lookup window is closed, we need the parent record ID and ETC before associating selected records.        
        if (lookupItems && lookupItems.items.length > 0) {

            var parent = GetParentObject(),
                parentId = parent.id,
                parentTypeCode = parent.objectTypeCode;

            //associates the selected records 
            AssociateObjects(parentTypeCode, parentId, params.gridTypeCode, lookupItems, IsNull(roleOrd) || roleOrd == 2, "", relName);

        }
        Xrm.Utility.alertDialog("Message on alert dialog", function () { });
    }
}

//pops the lookup window with our view injected
LookupObjectsWithCallback(locAssocObjAction1, null, "multi", params.gridTypeCode, 0, null, "", null, null, null, null, null, null, viewId, [customView]);

回避策として、次の解決策を見つけました。

http://www.magnetismsolutions.co.nz/blog/paulnieuwelaar/2014/04/21/filter-nn-add-existing-lookup-dynamics-crm-2013

上記の推奨事項と Paul Niewelaar の推奨事項との主な違いは次のとおりです。

var callbackRef = Mscrm.Utilities.createCallbackFunctionObject("locAssocObjAction", this, parameters, false);

//pops the lookup window with our view injected
LookupObjectsWithCallback(callbackRef, null, "multi", gridTypeCode, 0, null, "", null, null, null, null, null, null, viewId, [customView]);

}

「locAssocObjAction」の実装がわかりません。ただし、N:N 関連付けは機能しているようです。

乾杯!

于 2014-05-14T20:22:25.790 に答える