Answered

Change XML contents during transfer

Hello everyone,

I am trying to transfer set of XML files from one FTP location to another. Before the transfer I want to change the contents of the XML file, specifically I am looking to change the value of one node <Practice Code>. The new value need to be picked up from a separate mapping file which will be updated occasionally. 

I managed to transfer the files and change the node value, though I just hardcoded the new value, using presave hook. How can I use a separate mapping file to change the value of that node. My mapping file looks like this.

Old Code -> New Code
TESTD03   ->  ON-015
TESTD05   -> BC-013
TESTD06   -> BC-010
TESTD07   -> BC-009
TESTD08   -> BC-008
TESTD09   -> BC-007

The XML file format is as below

<?xml version="1.0" encoding="utf-8"?>
<BATCH ID="Batch859514">
<Image>c859514.pdf</Image>
<InvoiceType>CREDIT</InvoiceType>
<SupplierCode>TESTSup01</SupplierCode>
<PracticeCode>TESTD06</PracticeCode>
<InvoiceNumber>859514</InvoiceNumber>
<PaymentTerm>60</PaymentTerm>
<InvoiceDate>2022-03-29</InvoiceDate>
<PONumber></PONumber>
<Currency>CAD</Currency>
<AccountNumber>TESTD06</AccountNumber>
</BATCH>

I'll appreciate any help or suggestion. 

Thanks

 

0

Comments

6 comments
Date Votes
  • Official comment

    Hello Deepak Sharma

    Here are the possible solutions provided by our Support staff in your support ticket. I've added these here if anyone else runs across the same issue. 

    Option 1:  This is the most straightforward solution. Use the #compare handlebar. 
     


    Option 2: Use a presave page hook to match the source data with the new values using a switch statement. 
    Example:

    for (let i = 0; i < options.folder.length; i++) { 
    let result = ""; 
    switch(true){ 
    case (options.folder[i].id === "TESTD03"): 
    result = "ON-015"; 
    break; 
    case (options.folder[i].id === "TESTD05"): 
    result = "BC-013"; 
    break; 
    case (options.folder[i].id === "TESTD06"): 
    result = "BC-010"; 
    break; 
    default: result = "No Code" 

    console.log(result); 

    options.folder[i].newfield = result 
    }


    Option 3: Have a dedicated lookup step that retrieves the correct code from a database before importing it into FTP, we gave google sheets a try while on a call, but it seems like we cannot reference the values in our sheet. We are only able to reference the specific cell.
     


    Option 4: Import the source data as a CSV file first, since when you import as a CSV file using FTP, you get the option to use the mapper and use the static lookup table. Then re-export the CSV file so it can be imported as an XML file with the new node value included.
     


  • Can the separate "old code -> new code" mappings be stored/managed directly in a field mapping in integrator.io? If so, please see pic below for guidance on how to set this up. Or, if you do really need the separate mappings to be managed completely from the external file on the FTP site, then it is also possible to build a separate flow to export the contents of the file, and update the main flow with the mappings. Everything that you do in the integrator.io UI can also be done via the integrator.io API, which means you can use flows to automate setting fields within other flows, etc... Office hours and/or support can help explain these options further.

     

    0
  • Thanks for the response Scott Henderson. Apologies for the delayed reply, I was out on holidays. It seems I could use field mapping to achieve the desired results but I am stuck on the very first step. When I go and try to create mappings I am getting the following message. 

    The flow "Octacom cXML Invoices - TEST", contains no imports.

    The "Import flow" does exists in the integration. Is there anything I am missing altogether?

    Thanks 

     

    0
  • Can you send a screenshot of your flow, and can you send a screenshot of the error you are getting (with the full page in view) so we can see what you are clicking and seeing, etc...?  Please send any other screenshots that you think might help.

    0
  • Hi Scott, 

    I just realized I am using "FTP Transfer" in my flow hence the "mapping" is not available. What should be the next step in my scenario? Your technical team has access to our flows and has helped me with the same flow in the past with a different issue. We have until end of next week to make it work and any help will be greatly appreciated. 

    Thanks.

     

     

    0
  • Can you please read this community post to see if it helps?  It is very hard to help you here without seeing lots of screenshots of your flow, and all the bubble drawers within your flow, etc...  I recommend working with support at this point.

    0

Please sign in to leave a comment.

 

Didn't find what you were looking for?

New post