Docx from Dynamic template with table of empty data not showing table headers

Certified Senior Developer

Hi All,

  I have a template document where it has 3 statements and then a table which will display data . But if the data is empty, the table header is also not displaying . But I need the output doc to display the template. table with header row showing no data available. Is this possible, Please suggest some solutions.

a!localVariables(
  local!queryXML:  if(
    toboolean(ri!isFormat)=true(),
    ri!data,
    a!forEach(
      items: reject(fn!isnull,{ri!data}),
      expression: 
      "<tablerow"&
      " preferredterm='"&toHtml(substitute(fv!item.preferredTerm,"'",  htmldecode("‘")))&"'"&
      " caseid='"&toHtml(substitute(fv!item.caseId,"'", htmldecode("‘")))&"'"&
      " studyid='"&toHtml(fv!item.studyName)&"'"&
      " blindedstatus='"&toHtml(fv!item.studyBlindedStatus)&"'"&
      " sequence='"&toHtml(fv!item.dilSequence)&"'"&
      " deathlifethreatening='"&toHtml(fv!item.deathLifeThreatening)&"'"&
      " downgradedtononsr='"&toHtml(fv!item.dgdNonSt)&"'"&
      " clockstartdate='"&toHtml(fv!item.clockStartDate)&"'"&
      " />"
    )
  ),
  if(
    a!isNullOrEmpty(ri!data),
    "",
    if(
    toboolean(ri!isSplit)=true(),
    local!queryXML,
  "<dil>"&
  "<product>"&ri!product&"</product>"&
  "<daterange>"&rule!DIL_testNewDateFormat(date: ri!dateFrom)&" to "&rule!DIL_testNewDateFormat(date: ri!dateTo)&"</daterange>"&
  "<listingtype>"&ri!type&" listing</listingtype>"&
  if(
    ri!type = "Unblinded",
    "<unblinded>Unblinded Safety Data : Do not share with blinded study personnel</unblinded>",
    "<unblinded></unblinded>"
  )&
  local!queryXML&
  "</dil>"
)
)
)
/resized-image/__size/640x480/__key/communityserver-discussions-components-files/19/pastedimage1725976361949v1.png

  Discussion posts and replies are publicly visible