Skip to main content

FTP to FTP XML document question

Answered

Comments

9 comments

  • Anitha Abraham Community manager Principal Technical Writer
    Celigo University Level 3: Master

    It looks like you're working with our Support team on this, which is great since they can look into your configuration and assist. I'll also follow that ticket. Thanks!

    0
  • Sinclair Dental IT Admin
    Engaged

    Yes, after not receiving any feedback here I opened an official ticket. Thank you.

     

    0
  • Bas van Ditzhuijzen Strategic Partner NetSuite Integration Whiz Salesforce Integration Whiz
    Answer Pro
    Engaged
    Celigo University Level 4: Legendary

    Hi,

    My way to do this is to create a flow that loads and saves the xml document as a CSV-file. That way you dont need to parse&rebuild the xml-file, which saves a lot of work. Then in a javascript-hook do a find&replace to change the text.

    0
  • Sinclair Dental IT Admin
    Engaged

    Hi Bas,

    Is your selection of CSV-file to treat the file as a <cr> or <nl> delimited file or to simply bypass file parsing?

    I will try your method as this would greatly simplify the process as the parse&rebuild process makes this harder than I would have originally imagined. 

    0
  • Stephen Brandt Documentation Manager Community moderator
    Engaged
    Great Answer
    Top Contributor
    Celigo University Level 3: Master

    This is a great post with clever collaboration. Thanks, Sinclair Dental IT Admin and Bas van Ditzhuijzen

    If you wanted to go the most direct route (but perhaps the hardest to rewrite values on the fly), it would look like the following XML upload instructions. I'm adding full details here because this information isn't yet captured in the Help Center, and others will surely come across this thread with the same question. 

    1. The last import step should be to upload to FTP. (+ Create destination; Application: FTP; What would you like to do: Transfer files into destination application.)
    2. Name the upload step, and keep the default Generate files from records set to Yes.
    3. Under How would you like to generate files, select XML for the File type.
      Notice that an XML document entry now appears within Where would you like the files transferred.
    4. Click at the right of XML document to open the handlebars Advanced field editor (shown below). 
    5. Paste the expected XML format from your app's guide into the Type your handlebars template here portion of the editor. 
    6. Based on the flow's data resources, supply the needed JSON paths as handlebars references. Preview to test the evaluated output.  
      Very often, you'll have to use handlebars helpers for looping, data type conversions, or logic to prepare the values for the destination app. In this case, you could use a series of {{#compare}} statements to change the PracticeCode values as needed.

    This example comes from the Marketplace template Salesforce Commerce Cloud (FTP) – NetSuite in the flow "NetSuite customer refunds to Salesforce Commerce Cloud refunds."

    0
  • Bas van Ditzhuijzen Strategic Partner NetSuite Integration Whiz Salesforce Integration Whiz
    Answer Pro
    Engaged
    Celigo University Level 4: Legendary

    Sinclair Dental IT Admin I parse it as as pipe-delimited file without header, and then when saving also write as a pipe-delimited file without header. That way it writes the file back the way it was originally. 

    Then in a presave script:

      options.data.forEach(line => {
        Object.entries(line).forEach(entry => {
          line[entry[0]] = entry[1].replace('foo','bar');
        });
      });
    0
  • Scott Henderson CTO
    Answer Pro
    Top Contributor

    Hey Bas, this is a great work around, and thanks for sharing! I will def keep this idea in my back pocket.

    Eventually, we will provide some sort of JavaScript hook to process raw files (i.e. right when they are first downloaded, or right before they get set somewhere, etc...), but not many people have asked for this, so not sure when we will build this.

    0
  • Sinclair Dental IT Admin
    Engaged

    Hi Bas, your example has helped us to move forward. We have now been able to import and transform the data as needed. Where we are struggling now is with the Save step where we write it back out. We don't know how to action "when saving also write as a pipe-delimited file without header'. Can you please provide a bit more detail here? 

    We are so close that we can taste success. :)

    0
  • Sinclair Dental IT Admin
    Engaged

    Hi Bas, I believe that Stephen's email covered the step that I was asking about. If this is not the case please let me know. 

    0

Please sign in to leave a comment.