web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

createCallbackFunctionObject throwing indescript error.

(0) ShareShare
ReportReport
Posted on by

Hello everyone,

I am attempting to create a filtered N:N subgrid with the code from here: paulnieuwelaar.wordpress.com/.../filter-nn-add-existing-lookup-dynamics-crm-2016-turbo-forms

This is a Dynamics 365 Online instance if that helps. The problem I am facing though is strange in that the lookup window comes up, filters perfectly, and allows me to choose items. But when I click "add" I get a general error message. As far as I can tell everything in the code is fine but I am unclear as to how I should proceed to debug this. My initial thought is that I could start debugging in the "crmWindow.Mscrm.Utilities.createCallbackFunctionObject" function but I am unclear as to where that even is.

Any idea?

//filters an add existing lookup view (N:N)
function addExistingFromSubGridCustom(gridTypeCode, gridControl, crmWindow, fetch, layout, viewName) {
    var viewId = "{DB2C6D94-48F2-E711-A2B6-00155D045E00}"; // a dummy view ID
    var relName = gridControl.GetParameter("relName");
    var roleOrd = gridControl.GetParameter("roleOrd");
  
    //creates the custom view object
    var customView = {
        fetchXml: fetch,
        id: viewId,
        layoutXml: layout,
        name: viewName,
        recordType: gridTypeCode,
        Type: 0
    };
  
    var parentObj = crmWindow.GetParentObject(null, 0);
    var parameters = [gridTypeCode, "", relName, roleOrd, parentObj];
    var callbackRef = crmWindow.Mscrm.Utilities.createCallbackFunctionObject("locAssocObjAction", crmWindow, parameters, false);

    
    crmWindow.LookupObjectsWithCallback(callbackRef, null, "multi", gridTypeCode, 0, null, "", null, null, null, null, null, null, viewId, [customView]);
}
    
  
function filterAddExistingContact(gridTypeCode, gridControl, primaryEntity) {
    debugger;

    var crmWindow = Xrm.Internal.isTurboForm() ? parent.window : window;

    var lookup = new Array();
    lookup = Xrm.Page.getAttribute("new_channel").getValue();
    if (lookup != null) {
        var name = lookup[0].name;
        var id = lookup[0].id;
        var entityType = lookup[0].entityType;
    }
    else
    {
        crmWindow.Mscrm.GridRibbonActions.addExistingFromSubGridAssociated(gridTypeCode, gridControl); //default button click function
        return;
    }
    

    if (primaryEntity != "nxt_callreport") {
        crmWindow.Mscrm.GridRibbonActions.addExistingFromSubGridAssociated(gridTypeCode, gridControl); //default button click function
        return;
        //Mscrm.GridRibbonActions.addExistingFromSubGridAssociated(gridTypeCode, gridControl); //default button click function
        //return;
    }
  
    //fetch to retrieve filtered data
    var fetch = "<fetch version='1.0' output-format='xml-platform' mapping='logical' distinct='false'>" +
"  <entity name='new_market'>" +
"    <attribute name='new_marketid' />" +
"    <attribute name='new_name' />" +
"    <attribute name='createdon' />" +
"    <order attribute='new_name' descending='false' />" +
"    <filter type='and'>" +
        "      <condition attribute='new_channel' operator='eq' uiname='" + name + "' uitype='" + entityType + "' value='" + id + "' />" +
"    </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='new_name' select='1' icon='1' preview='1'>" +
        "  <row name='result' id='new_name'>" +
        "    <cell name='new_name' width='300' />" +
        "  </row>" +
        "</grid>";
  
    addExistingFromSubGridCustom(gridTypeCode, gridControl, crmWindow, fetch, layout, "Filtered Markets");
}

*This post is locked for comments

I have the same question (0)
  • Community Member Profile Picture
    on at

    Were you able to get any resolution for this? It doesnt throw any error for me but navigates to somewhere else?

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the April Top 10 Community Leaders

These are the community rock stars!

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans