Skip to main content

Notifications

Community site session details

Community site session details

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

Word Template Content Control Fields Not Repeating.. object error

(4) ShareShare
ReportReport
Posted on by 208

Hi Team,

 

I'm trying to display the timesheet and related time entries in a Word document, which will later be converted to PDF. However, it only shows [object Object] instead of actual data. I’ve tried different approaches, including hardcoding, but nothing works.

 

Has anyone faced this issue or found a solution? I referred to this article: https://www.bythedevs.com/post/how-to-populate-a-word-template-with-repeating-control.

 

Any help would be appreciated.

 

Attached is the screenshot.

 
  • Suggested answer
    Quartzite Profile Picture
    48 on at
    Word Template Content Control Fields Not Repeating.. object error

    Hi,

    Try the following steps:

    1. Insert a table in the Word document.

     
    2. Select the table and add a repeating section content control.
     
    By using this template and adding values from Power Automate field by field, your values will populate correctly, rather than as objects.
     
    If you find this information helpful, please consider accepting it as the answer. 😊
     
  • Vahid Ghafarpour Profile Picture
    9,688 Super User 2025 Season 1 on at
    Word Template Content Control Fields Not Repeating.. object error
    If any of the responses helped resolve your issue, please take a moment to mark the best answer. This helps others in the community quickly find solutions to similar problems.

    To do this, simply click the "Does this answer your question?" button on the most helpful response and like the helpful posts. If your issue is still unresolved, feel free to provide more details so the community can assist further!

    Thanks for being an active part of the Dynamics 365 Community! 😊
  • Suggested answer
    Daivat Vartak (v-9davar) Profile Picture
    5,970 Super User 2025 Season 1 on at
    Word Template Content Control Fields Not Repeating.. object error
    Hello Sushma Patole,
     
    The issue you're facing, where you see "[object Object]" instead of actual data in your Word document (and subsequently your PDF), is a common problem when working with Word templates and Dynamics 365 data, specifically repeating controls. The "[object Object]" indicates that the Word template is receiving an object (likely a JSON object) but doesn't know how to render it as text.
    Let's troubleshoot this issue and find a solution:
    Understanding the Problem:
    • Repeating Controls and Related Entities: You're trying to display data from a related entity (time entries) within a repeating control in your Word template.
    • Data Retrieval: The data retrieval from Dynamics 365 is likely returning the related data as a JSON object, which is how Dynamics 365 represents related entity data.
    • Word Template Rendering: Word's template engine is not automatically interpreting the JSON object as text.
    Troubleshooting Steps and Solutions:
    1. Verify Data Structure:
      • Check the Data Source: Ensure that the data source you're using in your Word template is correctly retrieving the related time entry data.
      • Inspect the XML Data: If you're using XML mappings, inspect the XML data that's being generated. Look for the structure of the time entry data. It should be an array of objects.
    2. Use Field Codes for Data Extraction:
      • Field Codes: Word field codes allow you to extract specific properties from JSON objects.
      • Syntax: Use the following syntax to access a property within a JSON object: {MERGEFIELD "your_data_source.your_field_name.property_name"}
      • Example: If your time entry data has a field named "Name" and you want to display the "Value" property, use: {MERGEFIELD "time_entries.Name.Value"}
      • Repeating Controls: Make sure you're using the correct field codes within the repeating control to iterate through the array of time entry objects.
    3. Check Data Types:
      • Data Type Mismatch: Ensure that the data types of the properties you're trying to display are compatible with Word's text rendering.
      • Conversion: If necessary, convert the data to a string before displaying it in the Word template.
    4. JavaScript Web Resource (Advanced):
      • Data Transformation: You could use a JavaScript web resource to transform the time entry data into a format that Word can understand.
      • String Representation: Convert the JSON objects into strings that represent the data you want to display.
      • Data Binding: Use data binding to pass the transformed data to the Word template.
    5. Alternative Data Retrieval Methods:
      • FetchXML: If you're using XML mappings, try using FetchXML to retrieve the time entry data. FetchXML provides more control over the data retrieval process.
      • Web API: Consider using the Dynamics 365 Web API to retrieve the data and format it before passing it to the Word template.
    6. Simplified Example (for illustration):
      Let's say your time entries data looks like this (JSON):
      JSON


      [
        { "Name": { "Value": "Entry 1" }, "Hours": { "Value": 8 } },
        { "Name": { "Value": "Entry 2" }, "Hours": { "Value": 6 } }
      ]


      In your Word template, within the repeating control, use the following field codes:
      • Name: {MERGEFIELD "time_entries.Name.Value"}
      • Hours: {MERGEFIELD "time_entries.Hours.Value"}
    7. Troubleshooting Tips:
      • Test with Sample Data: Use a small set of sample data to isolate the issue.
      • Simplify the Template: Start with a simple Word template and gradually add complexity.
      • Check for Errors: Look for any error messages in the Word template or the data source.
    Key Recommendation:
    • Use Field Codes: The most likely solution is to use the correct field codes within your repeating control to extract the specific properties you want to display from the time entry JSON objects.
    By following these troubleshooting steps and using the appropriate field codes, you should be able to resolve the "[object Object]" issue and display the time entry data correctly in your Word document. Remember to replace the placeholder field names with your actual field names from your data source.
     
    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.
     
    My response was crafted with AI assistance and tailored to provide detailed and actionable guidance for your Microsoft Dynamics 365 query.
     
    Regards,
    Daivat Vartak
  • Verified answer
    Sushma Patole Profile Picture
    208 on at
    Word Template Content Control Fields Not Repeating..It shwos obj
    Please refer url From Reza Dorrani-https://youtu.be/KVnfWsO1Fhs?si=W6HRgKIHIXhTkFCl
     
    It worked for me.
  • Suggested answer
    Holly Huffman Profile Picture
    5,510 on at
    Word Template Content Control Fields Not Repeating.. object error
    Hi there! Good morning, evening, or afternoon - depending on where you are :) Hope you are well today! 
     
    The issue of [object Object] appearing in your Word template instead of actual data typically occurs when the data binding between the content control fields and the source data is not properly configured. Here are some steps to troubleshoot and resolve the problem:
     
    1. Verify Data Binding: Ensure that the content control fields in your Word template are correctly mapped to the data source. If you're using Dynamics 365, check that the fields are properly linked to the entity and attributes you want to display.
    2. Repeating Section Configuration: For repeating data, such as time entries, make sure you've set up a repeating section in the Word template. Highlight the row or section you want to repeat, right-click the related entity in the XML Mapping pane, and select "Insert Content Control > Repeating."
    3. Data Format: Check the format of the data being passed to the Word template. If the data is an object, you may need to extract specific properties or values to display them correctly.
    4. Template Design Mode: Enable "Developer Mode" in Word and review the XML Mapping pane to ensure the fields are correctly mapped. You can also test the template with sample data to verify the output.
    5. Hardcoding Issues: Avoid hardcoding data directly into the template. Instead, use dynamic fields and ensure they are properly configured to pull data from the source.
    6. Testing and Debugging: Test the template with different records to see if the issue persists. If it does, review the XML structure and data source for inconsistencies.
     
    Hope this helps some!

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

🌸 Community Spring Festival 2025 Challenge 🌸

WIN Power Platform Community Conference 2025 tickets!

Jonas ”Jones” Melgaard – Community Spotlight

We are honored to recognize Jonas "Jones" Melgaard as our April 2025…

Kudos to the March Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 294,095 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 232,866 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,158 Moderator

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans