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

(Copy &) Paste into Dynamics NAV

(0) ShareShare
ReportReport
Posted on by 215

I wrote a custom WPF app in C# to help me track my daily activities. At the end of the week I have to fill in this data into MS Dynamics NAV 5.0, which our company uses. Since I don't want to type all the data again, I thought copying all to the clipboard and pasting it into the table in NAV would be cool.

So I copied some rows of that table from NAV first and analyzed the DataObject in the Clipboard. There were 5 values:

DataFormat "Text": The complete text as string. Column header text separated by tabulator (0x09) then the rows with values also separated by tabulator. Each row is separated by CR/LF (0x0D,0x0A).

DataFormat "UnicodeText": Exactly the same as in "Text". Byte for byte.

DataFormat "System.String": This value is null.

DataFormat "Locale": A MemoryStream with 4 bytes: 0x07, 0x04, 0x00, 0x00

DataFormat "OEMText": Just as "UnicodeText" exactly the same as "Text" byte for byte.

I formatted my data exactly as NAV did and put all 5 values into the DataObject. Unfortunately when I try to paste it into NAV it is not working. Either, when a complete row is selected, nothing happens. Or, when the cursor is is a cell, the complete text with all the tabulators and linebreaks is pasted into the current cell.

First I thought I did something wrong. So I copied some rows from the table in NAV. Then I read byte for byte so I can reproduce this information. I cleared the Clipboard and recreated the data byte for byte. From a C# point of view the data was exactly the same. Still I couldn't paste it back into NAV.

Is there some information in the clipboard I can't evaluate in C#? Or what else am I doing wrong?

*This post is locked for comments

I have the same question (0)
  • navuser2 Profile Picture
    10 on at
    RE: (Copy &) Paste into Dynamics NAV

    Hello, that's exactly what i'm trying to achieve. Can u help me wwith some explanation on how to set datas in the clipboard??

  • Community Member Profile Picture
    on at
    Re: (Copy &) Paste into Dynamics NAV

    the path of least restance would be to write a data import function, use a data-port, report or the RIM tool kit.  pasting into NAV just ... well not a good idea

  • Community Member Profile Picture
    on at
    Re: (Copy &) Paste into Dynamics NAV

    There are several downloads you can look at on the www.mibuso.com/downloads.asp site.

    from things like the waldo notepad : www.mibuso.com/dlinfo.asp

    to : all types of import wizards for XML or excel.

    Just try the search feature & select General Downloads & keyoword "import"

    perhaps you can find something you can use.

  • rsaritzky Profile Picture
    on at
    Re: (Copy &) Paste into Dynamics NAV

    MSDN has all the basic developer documentation.  I've been a developer for a long time so I use the PDF versions that come with the software.  Depending on which form you are trying to paste into, a dataport can be simple, medium or complex.  But here's a starting point for dataports:

    msdn.microsoft.com/.../dd354981.aspx

    Also, if you are using the classic client, click "Help", then "C/Side Reference Guide"

    Whether you are allowed to build dataports and use them is based on what permissions you have been granted by your NAV administrator.

    Good luck!

    Ron

  • Dietmar Z. Profile Picture
    215 on at
    Re: (Copy &) Paste into Dynamics NAV

    I haven't written my little program on behalf of my company. Also I'm an ordinary user in navision with no special rights and I'm using it remote via cisco client. Therefore I'm not sure, I can make use of dataport or xmlport. Are there any resources on the web, where I can read about these two?

    I'm guessing too, that navision uses it's own internal clipboard. And since I have no access to this clipboard, it's impossible for me to get my data into nav.

  • rsaritzky Profile Picture
    on at
    Re: (Copy &) Paste into Dynamics NAV

    I am not a C# developer, but I've never been able to paste multiple fields into a NAV table or form from an application outside of NAV.  I have been able to copy/paste from one NAV form to another NAV form occasionally, but because of the auto-numbering feature or a hidden key field in NAV, even that doesn't work.

    Copying from NAV into an outside app like Excel does work.

    The common solution to this is to import the data via a dataport or xmlport.  Export your data from your custom app to CSV or XML then dataport/xmlport it into NAV.  Or, if your data is table-based and accessible via ODBC, you can create a report in NAV that will read the data via ADO.

    My guess is that the "Paste" function in NAV has access to additional information other than what you can see in the clipboard data object which allows it to paste data that was copied originally from NAV (as opposed to an "outside" app).

    Ron

  • Dietmar Z. Profile Picture
    215 on at
    Re: (Copy &) Paste into Dynamics NAV

    @Soren:

    Is the NAV Clipboard the same, I can access with the .net Clipboard class?

    I already took a look on the Formats. Clipboard.GetDataObject().GetFormats() gets me the 5 Formats: "Text", "UnicodeText", "OEMText", "System.String" and "Locale".

    @Savatage:

    Haven't found anything relevant in the blog.

    Yes, I can save the data as CSV or XML, but how would that help me get it into NAV?

  • Community Member Profile Picture
    on at
    Re: (Copy &) Paste into Dynamics NAV

    Hi Dietmar,

    i worked on a project where i had to save the contents of the NAV clipboard, so the data could be saved and later on loaded on pasted into NAV.

    That works fine, the only issue, is the client can set a different FormatName for the data on the clipboard for every time you start the app.

    I did my script in AutoIT, and it works pretty well. I save the 3 types for each: FormatName, Format#, Data.

    It sounds like you are just looking at the Data part.

  • Community Member Profile Picture
    on at
    Re: (Copy &) Paste into Dynamics NAV

    Can your data be saved in other ways? (csv, xml, fixed width, xls)

  • Community Member Profile Picture
    on at
    Re: (Copy &) Paste into Dynamics NAV

    Have you peeked arounf this site?

    blogs.msdn.com/.../nav_developer

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 > 🔒一 Microsoft Dynamics NAV (Archived)

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans