Write record variable to OutStream

matthiasclaesmatthiasclaes Member Posts: 18
Is it possible to write a complete record variable to an out stream?

This way doesn't work (from "Sales Header".OnModify):
...
"Job Queue Entry"."Parameter String" := STRSUBSTNO('DMS DOCTYPE %1', "Document Type");
"Job Queue Entry".XML.CREATEOUTSTREAM(outStream);
outStream.WRITE(xRec); //This statement fails.
outStream.WRITE(Rec);
"Job Queue Entry".Status := "Job Queue Entry".Status::Ready;
"Job Queue Entry".INSERT(TRUE);

Our NAS (running JOBQUEUE) has to perform a task when certain fields in the sales header change.
I'm trying to pass the complete xRec and Rec to the NAS Handler.
The NAS Handler will perform the evaluation of the changed fields and act upon it (asynchronous, on a different machine).

I'm not looking forward to writing all the separate fields one by one, and reading them back one by one in the NAS Handler.
Is there a way to convert a record variable to an XML structure in memory and write that into the BLOB field?

Comments

  • vaprogvaprog Member Posts: 1,139
    I have never tried to write a full rec in binary, but in text I have not found a way that never produces an overflow.

    I think you will have to write the data field by field. You can use a Fieldref in a loop to cut down on your typing and to allow for table changes without having to change your code each time.
  • kinekine Member Posts: 12,562
    Ther is no way other than using FieldRec as already mentioned.
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • matthiasclaesmatthiasclaes Member Posts: 18
    Thank you for the hint about FieldRefs, forgot about them.
    I tried using a Variant as an intermediate variable, but that doesn't work.
    Is there documentation on what data types are supported in OutStream.Write()?

    I'll use the FieldRef method, it seems the most reliable and flexible.
  • matthiasclaesmatthiasclaes Member Posts: 18
    I'm still stuck. I can't use FieldRefs on my implicit Rec variable.
    Those values are not yet saved in the database when the OnModify code executes, so I cannot GET() them.
  • vaprogvaprog Member Posts: 1,139
    I believe RecRef.GETTABLE should work regardless, then use RecRef.FIELDINDEX to get the FieldRef.
Sign In or Register to comment.