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

Community site session details

Session Id :
Small and medium business | Business Central, N...
Answered

Load Text variable into an XMLPort

(0) ShareShare
ReportReport
Posted on by 40

I want to import a file which I get as a Text variable using an XmlPort.

Is it correct that I have to convert the Text into an Instream?

What is the intended way for doing the conversion?

// xmlInStream: InStream
// xmlText: Text

xmlText = getMyXmlText(); // contains the xml file as text

// Create valid instream?


Xmlport.Import(Xmlport::MyXmlPort, xmlInStream);

I have the same question (0)
  • Verified answer
    Telcrome Profile Picture
    40 on at
    RE: Load Text variable into an XMLPort

    This is the solution:

    // tmp: Codeunit "Temp Blob";
    // xmlOutStream: OutStream;
    // xmlInStream: InStream;
    
    tmp.CreateOutStream(xmlOutStream);
    xmlOutStream.WriteText(some_text);
    tmp.CreateInStream(xmlInStream);

  • Community Member Profile Picture
    on at
    RE: Load Text variable into an XMLPort

    Typically when I am programitcally assigning values and inserting records I do NOT use a record variable in the XML port and us all text variables for data items. This should allow you to intercept each value as it comes in and process it however you want or need too. This can be time consuming to map all the fields and write code to handle the record insertion....but it also allows the most control as NAV is not doing things auto-magically, you the developer have full control over how the transaction runs.

    Then in the WABillingEntry - Import::OnAfterAssignVariable() I read all of the variables out of the different text variables, generate the new record key, populate fields and insert record (along with any other business logic necessary).

  • Telcrome Profile Picture
    40 on at
    RE: Load Text variable into an XMLPort

    // tmp: Codeunit "Temp Blob"
    tmp.CreateInStream(xmlInStream);
    xmlInStream.ReadText(xmlText);

    This doesnt work, sadly without any error message. XmlPort.Import just returns False

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…

Andrés Arias – Community Spotlight

We are honored to recognize Andrés Arias as our Community Spotlight honoree for…

Leaderboard > Small and medium business | Business Central, NAV, RMS

#1
Sohail Ahmed Profile Picture

Sohail Ahmed 2,669 Super User 2025 Season 2

#2
Sumit Singh Profile Picture

Sumit Singh 2,668

#3
Jeffrey Bulanadi Profile Picture

Jeffrey Bulanadi 2,203

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans