Custom report field always blank when exported from API

Options
DevonHerlitz
DevonHerlitz Expensify Customer Posts: 3

Hello, I have an integration using the expensify API up and running where I am submitting a template in the request to generate the report as it is described here

And then downloading the report as a CSV as described here

I have been able to get all of the data into the exported report, however, the one field I cannot seem to get to load is a custom field on the report level. According to the docs here, the format should be customField.Name_of_Report_Field which in the context of the template we believe would be (simplified)

<#if addHeader == true>
ReportTitle,ProdTourID<#lt>
</#if>
<#list reports as report>
${report.reportName},${report.customfield.PROD_ID__6_digits_only_}<#lt>    
</#list>

Where PROD_ID__6_digits_only_ is the name of the custom field added to our policy, as seen here, with all non-alpha-numeric characters converted to underscores:

So far, we have tried a number of different formats for the field, e.g. all upper case, all lowercase, etc. and have not been able to get the field to be anything other than an blank value.

We would appreciate any guidance on getting this field included in our report.

Best Answer

  • DevonHerlitz
    DevonHerlitz Expensify Customer Posts: 3
    Answer ✓
    Options

    We managed to get this working, on our own, in order to debug, we found it helpful to follow parts of this StackOverflow page in order to probe for exactly what fields were available, like this

    <#list .data_model?keys as key>
      ${key}
    </#list>
    
    

    Or even better, like this

    <#list reports as report>
      <#list report?keys as key>
        ${key}
        <#list report.customField?keys as cfk>
        key ${cfk}
        value ${report.customField[cfk]}
        </#list>
      </#list>
    </#list>
    

    In the end, it seems like the odd casing and formatting of the field may have gotten the better of us, note that the casing matches the field exactly as it does in the UI. (This did work for us)

    <#if addHeader == true>
    ReportTitle,ProdTourID<#lt>
    </#if>
    <#list reports as report>
    ${report.reportName},${report.customField.Prod_ID__6_digits_only_}<#lt>    
    </#list>
    


    For the record, when creating an expense report using the API and setting the custom field, the custom field actually had to be all uppercased, so PROD_ID__6_DIGITS_ONLY_ works for creating a new expense report for the CREATE  endpoint, but the export template needs Prod_ID__6_digits_only_.