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

Community site session details

Session Id :
Customer experience | Sales, Customer Insights,...
Answered

How to get the data from a Subgrid to the HTML webresource

(0) ShareShare
ReportReport
Posted on by 11
I have tab in a Table Items. At this tab there are two webresources: image and HTML.
It looks like this
 
I would like to get to the blue fields data from the subgrid elements, from the table Warranties. Subgrid is in the same tab with a webresource.
The Actual Date and the Planned Date values for the Complex Type should be under the Complex picture in the fielsd with the appropriate names and for the simple type appropriately.
As far as I understand, I should add the part of the Java Script code to the HTML code and get the needed data.
And also, can in my case be the JS file, link to which will be added to the HTML web resource. Theoretically to get the Data from the Script I should add the JS webresource on Script load?
I would be grateful for the hint, which functions should I use, which actions sequesnce as well.
 
 
I have the same question (0)
  • Verified answer
    Dengliang Li Profile Picture
    Microsoft Employee on at
    How to get the data from a Subgrid to the HTML webresource
    Hi,
     
    Yes, you can retrieve the data from the subgrid in the HTML web resource and then pass it into the HTML.
    In my test, I passed the Warranty Actual Date and Warranty Planned Date values for records with a Warranty Type of simple in the case subgrid of the contact entity into the HTML web resource.
    The code is shown below.
     
    <body>
        <img src="https://img-prod-cms-rt-microsoft-com.akamaized.net/cms/api/am/imageFileData/RE1Mu3b?ver=5c31" alt="">
        <div >
            <label for="Actual Date">Actual Date</label>
            <input type="text" id="Acutal Date">
        </div>
        <br>
        <div>
            <label for="Planned Date">Planned Date</label>
            <input type="text" id="Planned Date">
        </div>
    </body>
     
    <script>
        window.onload= load;
            function load(){
     
            //Get the Actual Date and Planned Date in an HTML web resource.
            var actualDate = window.window.document.getElementById("Acutal Date");
            var plannedDate = window.window.document.getElementById("Planned Date");
           
            //Gets all row records of the case subgrid.
            var gridControl = window.top.Xrm.Page.getControl("contactcasessgrid");
            var gridRows = gridControl.getGrid().getRows().get();
     
            //If no row records are fetched, wait 4 seconds for the case subgrid to finish loading to execute the next step.
            if(gridRows.length ===0){
                setTimeout(function(){
                   
                    //Iterate through all rows of records
                    for(let item of gridRows){
     
                    //Look for the record for Warranty Type as simple.
                    let type = item.getAttribute("cra21_warrantytype").getValue();
                   
                    if(type !== null&&type===0){
                    //Populate the HTML web resource with the values of Actual Date and Planned Date for records with a Warranty Type of simple.
                    actualDate.value = item.getAttribute("cra21_warrantyactualdate").getValue()
                    plannedDate.value = item.getAttribute("cra21_warrantyplanneddate").getValue()
                }
            }
                },4000);            
            }        
        }
    </script>
     
     
     
    If my answer was helpful, please click Like, and if it solved your problem, please mark it as verified to help other community members find more.
    If you have further questions, please feel free to contact me .
     
    Best Regards,
    Dengliang Li
     

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Abhilash Warrier – Community Spotlight

We are honored to recognize Abhilash Warrier as our Community Spotlight honoree for…

Leaderboard > Customer experience | Sales, Customer Insights, CRM

#1
Rishabh Kanaskar Profile Picture

Rishabh Kanaskar 258

#2
MVP-Daniyal Khaleel Profile Picture

MVP-Daniyal Khaleel 182

#3
Tom_Gioielli Profile Picture

Tom_Gioielli 125 Super User 2025 Season 2

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans