Skip to main content
September 22, 2023
Question

DOCX From Dynamic Template

  • September 22, 2023
  • 4 replies
  • 0 views

I am getting error like Premature End of file while generating Pdf how can i resolve this ?

a!localVariables(
  local!voucherDetails: if(
    a!isNullOrEmpty(ri!batchNum),
    null,
    rule!GAI_getVoucherDetails(batchNum: ri!batchNum).data
  ),
  local!batchDetails: if(
    a!isNullOrEmpty(ri!batchNum),
    null,
    rule!GAI_getBatchDetail(batchNumber: ri!batchNum).data
  ),
  local!date: today(),
  local!xmlData: if(
    a!isNullOrEmpty(ri!batchNum),
    null,
    concat(
      "",
      "",
      ri!batchNum,
      "",
      "",
      local!date,
      "",
      "",
      index(local!voucherDetails, "description", {}),
      "",
      "",
      index(local!voucherDetails, "claimname", {}),
      "",
      "",
      index(local!voucherDetails, "fundsource", {}),
      "",
      "",
      index(local!voucherDetails, "fundamt", {}),
      "",
      "",
      index(local!voucherDetails, "invoicedate", {}),
      "",
      "",
      index(
        local!voucherDetails,
        "invoicenumber",
        {}
      ),
      "",
      "",
      index(local!voucherDetails, "bankcode", {}),
      "",
      "",
      index(
        local!voucherDetails,
        "achLocationCode",
        {}
      ),
      "",
      "",
      
      index(local!voucherDetails, "vendornumber", {}),
      "",
      "",
      "test",
      /*index(local!voucherDetails, "vendorname", {}),*/
      "",
      "",
      index(local!voucherDetails, "addresscode", {}),
      "",
      "
", index(local!voucherDetails, "address", {}), "
", a!forEach( items: local!voucherDetails, expression: concat( "" ) ), "
" ) ), local!finalXmlData: if( a!isNullOrEmpty(ri!batchNum), null, substitute(local!xmlData, "&", "&") ), local!isSuccess: and( a!isNotNullOrEmpty(ri!batchNum), length(local!voucherDetails) = length(local!batchDetails) ), a!map( pdfXmlData: local!finalXmlData, isSuccess: local!isSuccess, errorMessage: if( local!isSuccess, null, if( a!isNullOrEmpty(ri!batchNum), "No batch number provided", "Number of rows mismatch between voucher details and batch details" ) ) ) )

This is my rule to generate xml and in PM i am getting error

This is XML Output :pdfXmlData:<dynamic><batch>2023-0098</batch><date>9/22/2023</date><des>GA-2023-402 PT-091</des><claimname>GA-2023-402 PT-091-C10</claimname><fundsource>22392</fundsource><fundamt>1509.26</fundamt><invoicedate></invoicedate><invoicenumber>GA-2023-402 PT-091-C10</invoicenumber><bankcode>1300</bankcode><achLocationCode>5</achLocationCode><vendornumber>14723</vendornumber><vendorname>test</vendorname><addresscode>22</addresscode><address></address><edtable Sr='1' amt='8729.7' accnt='2' fund='10112' dept='46627402' fSource='22392' program='5680101' class='315' project='46639242' bugRef='2023' /></dynamic>,isSuccess:true,errorMessage:]

4 replies

mathieud0001
Brainy
September 22, 2023

Before converting to PDF, is the Word Document being generated correctly?

September 23, 2023

No, it is giving that error in word only

mathieud0001
Brainy
September 23, 2023

XML looks OK. I suspect perhaps something is corrupt in the template file. Maybe try starting again from scratch and putting in the merge fields one by one.