cancel
Showing results for 
Search instead for 
Did you mean: 

Create a CSV with 2 Header lines

ConnorSkillsoft
Deputy Chef II
Deputy Chef II

I'm attempting to create a CSV file with 2 header lines for an integration between D365 and Coupa:

 

RequisitionSubmit For Approval?JustificationRequested By (Email)Requested By (Login)Ship to Location CodeHide Pricepo_email_addressevent__work_orderevent_start_dateevent_end_date                        
Requisition LineLine NumberCatalog Item NumberNon Catalog Item DescriptionSupplier Part NumberQuantityPriceUOM CodeNeed By DateSupplier NumberCommodity NameCurrency CodeChart of Account NameAccount CodeAccount Segment 1Account Segment 2Account Segment 3Account Segment 4Account Segment 5Payment Term Codeasset_locationasset_tagasset_idservice_start_dateservice_end_dateproductexpense_glprofile_idusers_deptchannelmodalityproduct_lineactivitycategoryinstructor


Output should look like below

 
RequisitionSubmit For Approval?JustificationRequested By (Email)Requested By (Login)Ship to Location CodeHide Pricepo_email_addressevent__work_orderevent_start_dateevent_end_date                        
Requisition LineLine NumberCatalog Item NumberNon Catalog Item DescriptionSupplier Part NumberQuantityPriceUOM CodeNeed By DateSupplier NumberCommodity NameCurrency CodeChart of Account NameAccount CodeAccount Segment 1Account Segment 2Account Segment 3Account Segment 4Account Segment 5Payment Term Codeasset_locationasset_tagasset_idservice_start_dateservice_end_dateproductexpense_glprofile_idusers_deptchannelmodalityproduct_lineactivitycategoryinstructor
Requisition                                  
Requisition Line                                  

Has anyone faced a similar issue before, and if so, knows the most efficient way to solve this?

 

Any suggestions welcome, many thanks!

 

Connor Smith

9 REPLIES 9

gary1
Executive Chef III
Executive Chef III

I've never seen this kind of formatting before. Is the final CSV always only 4 lines? 

Me either, find it very strange. Correct only ever 4 lines.

Got it. I would construct this one line at a time. If you're comfortable scripting, you can write a single action to make an array of arrays, and then convert the array to CSV.

Here's a quick Ruby snippet that should do the trick. You just need to flesh out the variables before pushing them into the array. Make sure each array variable has the same amount of items (even if blank) so the CSV columns remain aligned.

 

 

array = []
req_header = ["Requisition","Submit For Approval?","Justification","..."]
req_line_header = ["Line Number","Catalog Item Number","Non Catalog Item Description","..."]
req_line = ["Requisition","..."]
req_line_line = ["Requisition Line","..."]

array.push(req_header, req_line_header, req_line, req_line_line)
csv = array.to_csv

## output 
{csv: csv}

 

 Let me know if you need more help with this.

Thanks so much!