web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

AIF Outbound XML to CSV Transform

(0) ShareShare
ReportReport
Posted on by

Greetings. I am running an AIF service (VendPaymentService) which exports an XML file with the payment information. I must convert this to a CSV format and research has shown me that I have to use a .NET Assembly to Transform do that. Microsoft has step-by-steps for creating an Inbound/Import .NET Assembly (CSV to XML), but not an Outbound/Export. I am a .NET amateur and MS's example shows how to call XML building tools and CSV reading tools, but I don't know how to build CSV building tools and XML Reading ones.

Here is the MSDN Article: msdn.microsoft.com/.../gg863930.aspx

To recap, I understand the overall concept that you build the .NET tranform and how to attach it to the AIF service but I am stuck on building the .NET Assembly itself and would like to know if anyone can provide me with help or an example of building the .NET transform from XML to CSV.

Thank you so much!

*This post is locked for comments

I have the same question (0)
  • Martin Dráb Profile Picture
    237,795 Most Valuable Professional on at

    You could probably use XSLT as well…
    About the assembly, it's trivial to write to write CSV; it's just a string. Parsing XML would be more difficult, but fortunately many great APIs exist, such as LINQ to XML.

  • Suggested answer
    Dick Wenning Profile Picture
    8,705 Moderator on at

    I did csv to xml , see my project dynamicsax2012csv.codeplex.com

    I think by changing the code a little bit you could do the same. it is a file stream in and file stream out.

    in your case the file stream in is the xml file

  • Community Member Profile Picture
    on at

    Hi

    As said it is quite easy to do the transform just the same way as inbound using the MS tutorial.

    Something like

    public void Transform(Stream xmlInput, Stream output, string configuration)

    {            

       sreader = new StreamReader(xmlInput);

       swriter = new StreamWriter(output);

       //Read your input xml and transform it to something useful

       // writing out:

       swriter.WriteLine("some output");

       swriter.Close();

    }

    The only thing I cannot figure out is how to get another filename than .xml

    So if anyone could tell me that it would be very much appreciated.

    Thanks

  • Suggested answer
    Community Member Profile Picture
    on at

    Seems AX always writes with the extension .xml

    In the class AifFileSystemSendAdapter the method getNewOutFileName() has the following line:

    filename = curTimestamp + #FileNameSeparatorCharacter + substr(counterText, strlen(counterText) - fileNumberMaxLength + 1, fileNumberMaxLength) + #XmlFileExtension;

    So I guess the solution is to create a parameter on the outbound port to set the fileextension to something else like csv and then change the system class to use this parameter.

    Do you have enough information to continue now?

  • Community Member Profile Picture
    on at

    Hi John,

    Where Can I wright the above code..

    Thanks

    hari

  • Community Member Profile Picture
    on at

    Can you please elaborate..?

  • Community Member Profile Picture
    on at

    Hi Ricky,

    have you achieved it?

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Martin Dráb Profile Picture

Martin Dráb 4 Most Valuable Professional

#1
Priya_K Profile Picture

Priya_K 4

#3
MyDynamicsNAV Profile Picture

MyDynamicsNAV 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans