问题描述:

I want to add a custom view to the popup when a user goes to add existing records in a subgrid for a many to many relationship.

I followed the instructions on the following link

But when I go to add existing records it throws a generic error, one that doesn't allow me to download the log file. Can anyone point me in the right direction to find out why this isn't working?

I'll post the code below.

function FilterSubGridLookup(gridTypeCode, gridControl, primaryEntity) {

if (primaryEntity != "ts_pmo_activity_request") {

Mscrm.GridRibbonActions.addExistingFromSubGridAssociated(gridTypeCode, gridControl);

}

else {

var fetchXml = '<fetch distinct="false" mapping="logical" output-format="xml-platform" version="1.0"> -<entity name="ts_qualification_area"> <attribute name="ts_qualification_areaid"/> <attribute name="ts_descriptor"/> <attribute name="createdon"/> <order descending="false" attribute="ts_descriptor"/> -<filter type="and"> <condition attribute="ts_solution_qualification_id" value="' + solutionQualificationId + '" uitype="ts_solution_qualification" operator="eq"/> </filter> </entity> </fetch>';

var layoutXml = "<grid name='resultset' object='1' jump='ts_qualification_areaid' select='1' icon='1' preview='1'><row name='result' id='ts_qualification_areaid'><cell name='ts_descriptor' width='150' /></row></grid>";

addExistingFromSubGridCustom(gridTypeCode, gridControl, fetchXml, layoutXml, "Filtered Qualification Areas");

}

}

function addExistingFromSubGridCustom(gridTypeCode, gridControl, fetch, layout, viewName) {

var viewId = "{1DFB2B35-B07C-44D1-868D-258DEEAB88E2}"; // a dummy view ID

var relName, roleOrd;

if (typeof (gridControl.GetParameter) === "function") { //post rollup 12

relName = gridControl.GetParameter("relName");

roleOrd = gridControl.GetParameter("roleOrd");

}

else { //pre rollup 12

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]);

//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 parentId;

var parentTypeCode;

if (typeof (GetParentObject) == "function") { //post rollup 12 has its own function to get this

var parent = GetParentObject();

parentId = parent.id;

parentTypeCode = parent.objectTypeCode;

}

else { //pre rollup 12 still needs to use the old way

var parent = typeof (crmFormSubmit) == "undefined" ? $get("crmFormSubmit") : crmFormSubmit; //according to daniels blog crmFormSubmit should already be defined, but it's not...

if (parent) {

parentId = parent.crmFormSubmitId.value;

parentTypeCode = parent.crmFormSubmitObjectType.value;

}

else {

parentId = window.parent.crmFormSubmit.crmFormSubmitId.value;

parentTypeCode = window.parent.crmFormSubmit.crmFormSubmitObjectType.value;

}

}

//associates the selected records

AssociateObjects(parentTypeCode, parentId, gridTypeCode, lookupItems, IsNull(roleOrd) || roleOrd == 2, "", relName);

}

}

网友答案:

In your fetch xml you have dashes. See if removing them fixes your problem:

Before:

<fetch distinct="false" mapping="logical" output-format="xml-platform" version="1.0"> 
-<entity name="ts_qualification_area">
    <attribute name="ts_qualification_areaid"/>
    <attribute name="ts_descriptor"/>
    <attribute name="createdon"/>
    <order descending="false" attribute="ts_descriptor"/> 
    -<filter type="and">
        <condition attribute="ts_solution_qualification_id" value="' + solutionQualificationId + '" uitype="ts_solution_qualification" operator="eq"/>
    </filter>
</entity>

After:

<fetch distinct="false" mapping="logical" output-format="xml-platform" version="1.0"> 
    <entity name="ts_qualification_area">
        <attribute name="ts_qualification_areaid"/>
        <attribute name="ts_descriptor"/>
        <attribute name="createdon"/>
        <order descending="false" attribute="ts_descriptor"/> 
        <filter type="and">
            <condition attribute="ts_solution_qualification_id" value="' + solutionQualificationId + '" uitype="ts_solution_qualification" operator="eq"/>
        </filter>
    </entity>
</fetch>
相关阅读:
Top