Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics CRM (Archived)

'FilterSubGrid' is undefined at eval code (eval code:1:1)

Posted on by Microsoft Employee

hey buddies,

   I am stuck in this error:  'FilterSubGrid' is undefined at eval code (eval code:1:1)

my task is to filter grid using second filter

plz help me .below is my code:

function FilterSubGrid()

 debugger; 
 var rowData = [5]; 
 var gridOfPrescription = window.parent.document.getElementById('Prescriptions');
 var filteredRecordCount = Xrm.Page.getControl('diseaseGrid').getGrid().getTotalRecordCount();
 
 for(int i = 0; i < filteredRecordCount ; i++)
  {    
   rowData[i] = Xrm.Page.getControl('diseaseGrid').getGrid().getRows().get(0).getData().getEntity().getAttributes().get('new_disease').getValue()[i].id;
  }
 var fetchXmlForPrescription = "<fetch version='1.0' output-format='xml-platform' mapping='logical' distinct='false'>" +
           "  <entity name='new_prescription'>" +
           "    <attribute name='new_prescribedon' />" +
           "    <attribute name='new_patientname' />" +
           "    <attribute name='new_suggestion' />" +
           "    <attribute name='new_weightofpatient' />" +
           "    <attribute name='new_patientname' />" +
           "    <attribute name='new_prescribedbydoctor' />" +
           "    <attribute name='new_issueof' />" +
     "    <attribute name='new_disease' />" +
           "    <order attribute='new_name' descending='false' />" +
           " <link-entity name='new_patientdisease' from='new_disease' to='new_disease'>"+
     "  <filter type='or'>"+
           "   <condition attribute='new_disease' operator='eq' value='" +rowData+ "' />"+
     "  </filter>"+
     " </link-entity>"+
           "  </entity>" +
           "</fetch>";
  
  gridOfPrescription.control.SetParameter("fetchXml",fetchXmlForPrescription);
        gridOfPrescription.control.refresh();
}

 

*This post is locked for comments

  • Suggested answer
    RaviKashyap Profile Picture
    RaviKashyap 55,410 on at
    RE: 'FilterSubGrid' is undefined at eval code (eval code:1:1)

    I think it is because you have mentioned getRows.get(0).

    Can you try change it to getRows.get(i) and see if works.

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: 'FilterSubGrid' is undefined at eval code (eval code:1:1)

    fetching disease list from first subgrid [a column]

    to filter the second subgrid.:

    for(i=0; i < filteredRecordCount ; )

    {

    var Values= Xrm.Page.getControl("diseaseGrid").getGrid().getRows().get(0).getData();

    var Entity= Values.getEntity();

    var EntityAttribute= Entity.getAttributes();

    var SelectedAttribute= EntityAttribute.get("new_disease").getValue();

    rowData[i] = SelectedAttribute[i].id;

    i++;

    }

    while debugging its getting only first record only

  • RaviKashyap Profile Picture
    RaviKashyap 55,410 on at
    RE: 'FilterSubGrid' is undefined at eval code (eval code:1:1)

    You can refer this community.dynamics.com/.../sub-grid-client-side-script-methods

    Can you elaborate more on your requirement? What exactly you want to fetch within that for loop?

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: 'FilterSubGrid' is undefined at eval code (eval code:1:1)

    it will fetch only first row ....

    I tried already Ravi

  • RaviKashyap Profile Picture
    RaviKashyap 55,410 on at
    RE: 'FilterSubGrid' is undefined at eval code (eval code:1:1)

    You can debug your script to see where exactly its breaking. This error generally means that the value is null.

  • Suggested answer
    RaviKashyap Profile Picture
    RaviKashyap 55,410 on at
    RE: 'FilterSubGrid' is undefined at eval code (eval code:1:1)

    Try this script

    rowData[i] = Xrm.Page.getControl('diseaseGrid').getGrid().getRows().get(0).getData().getEntity().getAttributes().get('new_disease').getValue()[0].id;

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: 'FilterSubGrid' is undefined at eval code (eval code:1:1)

    thanks Ravi Kashyap

    now m got error is:

    Unable to get property 'id' of undefined or null reference at FilterSubGrid (dynamisitydemo3.crm8.dynamics.com/.../new_assignAutoGenerateID)

  • Verified answer
    RaviKashyap Profile Picture
    RaviKashyap 55,410 on at
    RE: 'FilterSubGrid' is undefined at eval code (eval code:1:1)

    Hi Arti,

    The error you are getting is 'FilterSubGrid' is undefined where FilterSubGrid is your method... which means your JS library is not loading properly... which is because you have incorrect syntax.

    Remove int from the for loop. and update the JS liabrary. You may need to do ctrl f5 to refresh the form/ load the updated JS.

    for(i = 0; i < filteredRecordCount ; i++)

    www.w3schools.com/.../js_loop_for.asp

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: 'FilterSubGrid' is undefined at eval code (eval code:1:1)

    filter subgrid using second subgrid

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,280 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,214 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans