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

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Microsoft Dynamics NAV (Archived)
Suggested Answer

XMLPORT Import & Export Via CSV

(0) ShareShare
ReportReport
Posted on by 14,380 Super User 2025 Season 2

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

I have the same question (0)
  • mmv Profile Picture
    11,471 on at

    Hi,

    You have got "FieldValidate" property for each field and "DefaultFieldsValidation" property for the whole XML Port.

    Best Regards,

    MMV

  • Saurav.Dhyani Profile Picture
    14,380 Super User 2025 Season 2 on at

    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.

  • Suggested answer
    Rajasekhar@MS Profile Picture
    5,569 on at

    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

  • mmv Profile Picture
    11,471 on at

    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
    4BzSoftware Profile Picture
    6,073 on at

    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
    11,471 on at

    Hi Saurav,

    Does the above solution work for you?

    Best Regards,

    MMV

  • Saurav.Dhyani Profile Picture
    14,380 Super User 2025 Season 2 on at

    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
    11,471 on at

    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

  • Suggested answer
    Suresh Kulla Profile Picture
    50,251 Super User 2025 Season 2 on at

    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.

  • Community Member Profile Picture
    on at

    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.  

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

News and Announcements

Season of Giving Solutions is Here!

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 NAV (Archived)

#1
HoangNam Profile Picture

HoangNam 7

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans