Quantcast
Channel: CRM Development 論壇
Viewing all articles
Browse latest Browse all 10280

Adding custom lookup to subgrid

$
0
0

Hi,

I want to add a custom view to the Add Existing button on my subgrid. I've been following the instructions at this link and have fully implemented it. However when I go to use it, a generic error is thrown. It loads the lookup window and the view apparently changes to my custom view, but nothing is populated where the records usually are. I've tried to debug the code to find it but i haven't had any luck so far.

Can anyone help? 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);
}   
}


Viewing all articles
Browse latest Browse all 10280

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>