locked
CRM 2011-control.SetParameter keeps returning as undefined RRS feed

  • Question

  • Hello everyone,

    I have a javascript function which retrieves the information of a lookup field on a custom entity form and filters a subgrid view on the same form. The lookup field is "new_region" and the subgrid field is "Open_Opportunities". I currently have the script running as am OnLoad event on the form. Whenever I try to run the form, I get the following message:

    "To use this saved view, you must remove criteria and columns that refer to deleted or non-searchable items."

    Here is my script:

    function updateSubGrid() {
    
    var relatedOpportunities = document.getElementById('Open_Opportunities'); 
    
    var lookupField = new Array;
     
    lookupField = Xrm.Page.getAttribute('new_region').getValue(); 
    
    if(lookupField != null) {
    var lookupid = lookupField[0].id; 
    }
    else {
    return;
    }
    
    
    if (relatedOpportunities == null || relatedOpportunities.readyState !='complete' ){
    setTimeout('updateSubGrid()', 4000); 
    return;
    } 
    
    
    var fetchXml = "<fetch distinct = 'false' mapping = 'logical' output-format='xml-platform' version='1.0'>"+
                             "<entity name = 'opportunity'>"+
                             "<attribute name = 'name'/>"+
                             "<attribute name = 'customerid'/>"+
                             "<attribute name = 'cs_awarddate'/>"+
                             "<attribute name = 'cs_inforcast'/>"+
                             "<attribute name = 'cs_overallprobability'/>"+
                             "<attribute name = 'cs_opportunitystage'/>"+
                             "<attribute name = 'cs_marketid'/>"+
                             "<attribute name = 'cs_estimatedrevenuemillions'/>"+
                             "<attribute name = 'ownerid'/>"+
                             "<attribute name = 'opportunityid'/>"+
                             "<link-entity name = 'new_salesplan' from='new_region' to='cs_marketid' alias='aa' link-type='outer'>"+ 
                             "<filter type = 'and'>"+
                            "<filter type = 'and'>"+
                             "<filter type = 'and'>"+
                             "<condition attribute ='statecode' value='0' operator='eq'/>"+
                             "<condition attribute ='ownerid' operator='eq-userid'/>"+ 
                             "<condition attribute = 'cs_marketid' operator='eq' uitype='opportunity' value='"+ lookupid + "'/>"+
                             "</filter>"+
                             "</filter>"+
                             "</filter>"+
                             "</link-entity>"+
                             "</entity>"+ 
                             "</fetch>"; 
    
    
    relatedOpportunities.control.SetParameter("fetchXml", fetchXml); 
    relatedOpportunities.control.refresh();
    
    
    }

    After using the F12 debugger, I have found that the line:

    relatedOpportunities.control.SetParameter("fetchXml", fetchXml);

    continuously returns as undefined. My fetchXml was built using advanced find, and when I checked my fetchXml variable, it definitely was not null or undefined. Does anyone know why this may be occurring?

    (I am on the latest rollup update, by the way)




    • Edited by Sabr786 Monday, June 8, 2015 12:04 PM
    Monday, June 8, 2015 11:48 AM

All replies

  • Seems like one of the fields you are using in your fetch query is either deleted or is not searchable, customize the Opportunity entity and check all the fields you are using in your fetch if they exist and are searchable. This might also be conflicting with fields that have Field leve security if you have any of those?

    You might try and take out all the fields and add them back 1 at a time to the fetch xml to see if you can track down what field is causing the problem, and even if the problem is related to the fields at all.

    Here is another discussion relating to the same error, perhaps this will get you some answers.

    https://social.microsoft.com/Forums/en-US/8c7a79a4-1ccf-4ce1-b2d4-3c03148c092c/custom-view-error-in-mscrm-2011?forum=crm


    Halldór Jóhannsson

    Monday, June 8, 2015 4:17 PM
  • I've gone back and checked all the attributes in the fetchxml, and they are all marked as searchable and have no field security requirements. I've tried to remove all the fields and test them one by one, but even then for each field I keep getting the same error. I think the error might not actually be with the script.
    Tuesday, June 9, 2015 4:54 PM