Automation, Streams, and Navision

Matt_KeyesMatt_Keyes Member Posts: 23
Hey all,

i need to write a decent amount of text out of an automation variable i have created. My thought is to store this in a Navision BLOB field. However, i can't seem to get it to work quite right. Does anyone know of any tutorials or examples for something like this?

Many thanks!

Comments

  • SavatageSavatage Member Posts: 7,142
    search the forum for "blob" it will probably help alot.
  • jjanauskasjjanauskas Member Posts: 49
    I had a similar problem, but i solved it by creating a new temporary text file and passing the path to automation server. This is the easiest way to implement.

    More advanced way would be using streams. I haven't done much with that, but you can check some XMLPorts in Navision which exports for blobs of tables to XML files (e.g. Product list export including photos). I have seen that navision uses special automation server in order to convert blob data to hexadecimal symbols. This seems the similar to what you want to do.

    Furthermore, take a look at new data type BIGTEXT ;)
  • DenSterDenSter Member Posts: 8,307
    That is a good tip. There are some standard Navision XMLPorts that use the TempBLOB table, in order to be able to access streams. If you do a where used on the Std XMLPorts, you will find the codeunits that use them, and examples of how to use that. I don't have access to Navision right now, but if you need to I will see if I can find an example later this week.
  • ara3nara3n Member Posts: 9,257
    Here is code on how to use BLOB and store text in it. Hope it helps

    In this case body is a blob in customer table
    EmailOutstream is OutStream
    Customer.get('10000');
    Customer.Body.CREATEOUTSTREAM(EmailOutStream);
    Ch10 := 10;
    CH13 := 13;
    CH := FORMAT(CH13) + FORMAT(Ch10);
    Text := '                                ***** ' + Title + ' *****'+CH;
    EmailOutStream.WRITETEXT(Text,MAXSTRLEN(Text));
    Text := '                                ***** ' + Another line + ' *****'+CH;
    EmailOutStream.WRITETEXT(Text,MAXSTRLEN(Text));
    Customer.Modify;
    

    To read the data. here is an example on how to do it. I'm basically writing it to a file and opening the file.
    MyFile.WRITEMODE(TRUE);
    MyFile.CREATE(ENVIRON('temp') + 'temp.txt');
    MyFile.OPEN(ENVIRON('temp') + 'temp.txt');
    MyFile.TEXTMODE(TRUE);
    Customer.get('10000');
    WITH Customer DO BEGIN
      CALCFIELDS(Body);
      IF Body.HASVALUE THEN BEGIN
         Body.CREATEINSTREAM(EmailInStream);
         WHILE NOT (EmailInStream.EOS()) DO BEGIN
           Int := EmailInStream.READTEXT(Txt,MAXSTRLEN(Txt));
           MyFile.WRITE(Txt);
         END;
       END;
      MyFile.CLOSE;
      HYPERLINK(ENVIRON('temp') + 'temp.txt');
    END:
    
    Ahmed Rashed Amini
    Independent Consultant/Developer


    blog: https://dynamicsuser.net/nav/b/ara3n
  • Matt_KeyesMatt_Keyes Member Posts: 23
    Thanks y'all for the help!

    i had searched for BLOBs on the forums, but hadn't found anything specific. However, i'll try the above... i didn't think of using a file, but if it comes to that i guess that would work :)

    Thanks again.
Sign In or Register to comment.