Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics NAV (Archived)

XMLPORT Import & Export Via CSV

(0) ShareShare
ReportReport
Posted on by 14,302 Super User 2025 Season 1

Hi all,

I have a requirement where i need to import and export data using XMLPort in Say ITEM Table.

The File that i want in both the cases will be CSV.

 

Here is the problem -

1. If i use a temporary table and try to import via code it works great.

2. IF i use table fields i can export but cannot import due to standard field validation getting fired and the record is not completely inserted.  

** I do need to call the Standard Field Validation.

 

So i need a single XMLPORT which do both the things based on user selection. Please share your feedback if you have done anything like this.

 

Thanks in advance.

*This post is locked for comments

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: XMLPORT Import & Export Via CSV

    How can i validate for the same data (record) using some fields. Thankz

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: XMLPORT Import & Export Via CSV

    Hi All,

    When I am importing the data through XML Port, field validate trigger is not working after setting the property yes to "FieldValidate" and and "DefaultFieldsValidation".Can you   please reply on this issue.  

  • Suggested answer
    Suresh Kulla Profile Picture
    Suresh Kulla 44,656 on at
    RE: XMLPORT Import & Export Via CSV

    I am not sure if you have tried this, but other option would be disable the validation while importing but do the validation of the fields through code on the OnAfterInsertRecord.

  • mmv Profile Picture
    mmv 11,467 on at
    RE: XMLPORT Import & Export Via CSV

    Hi,

    You still can use the same XMLport for import and export.  Could you tell me which field was giving error eventhough the validation is set as No.?

    Best Regards,

    MMV

  • Saurav.Dhyani Profile Picture
    Saurav.Dhyani 14,302 Super User 2025 Season 1 on at
    RE: XMLPORT Import & Export Via CSV

    Hi All,

    Thanks for your responses but i ended up by creating two xmlports one for insert and one for update.

    mmv - Thanks for the input but i would suggest to take some more fields whose validate check master records.

    What is happening is when the cost of item is getting validated it is going in standard code where it checks that item is still not inserted and XMLPORT Stops (Case via Element type Fields).

    Yes via code i can say Init insert and after all field validate can say modify but then the same cannot be used for Exporting the data as that will  be of text type.

    But the question still remain open can i or not use same xmlport for export and import of CSV File?

  • mmv Profile Picture
    mmv 11,467 on at
    RE: XMLPORT Import & Export Via CSV

    Hi Saurav,

    Does the above solution work for you?

    Best Regards,

    MMV

  • Suggested answer
    4BzSoftware Profile Picture
    4BzSoftware 6,071 on at
    RE: XMLPORT Import & Export Via CSV

    Hi Saurav,

    It is possible to use a Variable Text XMLPort to Import and Export on Master Tables, without coding. On Table Element, make sure AutoSave property is Yes (its default value).

    Sometimes NAV message makes user confused. I think your case related to Field Validation, as a result, the record is not inserted.

  • mmv Profile Picture
    mmv 11,467 on at
    RE: XMLPORT Import & Export Via CSV

    Hi Saurav,

    This is what I did:-

    1. Created a XML Port - Variable Text (for Vendor table)

    2. Set the "DefaultFieldsValidation" property to "No"

    3. Added four fields (No., Name, City and Country/Region Code) - FieldValidate set to No

    4. Created a CSV File, with Values TEST0001, Testing, ABS, AK

       (Note: AK Country Code is not in my master).

    5. I tried to import the data using the above XMLPort and it imported without any validation error.

    Scenario - for error:-

    1. Created a XML Port - Variable Text (for Vendor table)

    2. Set the "DefaultFieldsValidation" property to Yes

    3. Added four fields (No., Name, City and Country/Region Code)

    4. Created a CSV File, with Values TEST0001, Testing, ABS, AK

       (Note: AK Country Code is not in my master).

    5. I tried to import the data using the above XMLPort and it gave me error for the non existence of the country code AK.

    So, you can keep the DefaultFieldsValidation (for the XMLPort) to No and FieldValidate (for each Node) to No or Undefined to import the data without the validation.

    Best Regards,

    MMV

  • Suggested answer
    Rajasekhar@MS Profile Picture
    Rajasekhar@MS 5,567 on at
    RE: XMLPORT Import & Export Via CSV

    Hi Saurav

    Can we write code to insert the records in the item Table by a variable on the "Item - Import ::onBeforeInsertRecord"  

    Regards

    Rajasekhar.Y

  • Saurav.Dhyani Profile Picture
    Saurav.Dhyani 14,302 Super User 2025 Season 1 on at
    RE: XMLPORT Import & Export Via CSV

    Dear MMV,

    yes i have set the property.

    My Question is  - Is it possible to use a Variable Text XMLPort to Import and Export on Master Tables.

    IF I SELECT SOURCE AS FIELDS -

    As per my understanding i can export file as csv using xmlport but when i try to import using that it calls every field validate and till then the record is not actually inserted so it give error like Item Does not exist.

    IF I SELECT SOURCE AS TEXT -

    For Import i Need to Write Code. But i cannot Export.

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

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Vahid Ghafarpour – Community Spotlight

We are excited to recognize Vahid Ghafarpour as our February 2025 Community…

Tip: Become a User Group leader!

Join the ranks of valued community UG leaders

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 292,516 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 231,399 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans