How can I get blob value from one table to another in NAV 2016?

Mauritsio
Member Posts: 27
Hi,
I have a blob field (memo, not compressed) in table1 having a value.
How can I get a blob value from table1 to table2 blob field in NAV 2016? Table2 blob field is having the same field number like in table1.
I have tried for instance several tricks like transferfields, calcfields, createinstream, createoutstream, copystream functions and so on.
If I for example execute calcfields for table1 blob field it empties a blob value from memory.
Pls give a short example how I can do that in NAV 2016 if you have any. Thanks in advance!
I have a blob field (memo, not compressed) in table1 having a value.
How can I get a blob value from table1 to table2 blob field in NAV 2016? Table2 blob field is having the same field number like in table1.
I have tried for instance several tricks like transferfields, calcfields, createinstream, createoutstream, copystream functions and so on.
If I for example execute calcfields for table1 blob field it empties a blob value from memory.
Pls give a short example how I can do that in NAV 2016 if you have any. Thanks in advance!
0
Best Answer
-
@Mauritsio
I do not have a database to test Service Header posting, so, I'm guessing:
The function "PrepareShipmentHeader" is used in CU 5980 only and the "ServShptHeader" is a temporary record-variable.
The actual creation of the Posted Shipment Header takes place in function "CreatePostedShptHeader" of CU 5763.
In "CreatePostedShptHeader" each field is assigned line by line.
Try to add the new field in "CreatePostedShptHeader".
Cheers,My blog - https://www.HannesHolst.com/5
Answers
-
Hi Mauritsio,
in fact you can simply assign one Blob to another.SomeTable."Some Blob" := TempBlob.Blob;
Before using CALCFIELDS() on the source, make sure it is actually a record inside a recordset. If it is only an instance (not added to dataset through INSERT()/MODIFY()), do not use CALCFIELDS().
Cheers
Carsten
==> How To Ask Questions The Smart Way
This post is my own opinion and does not necessarily reflect the opinion or view of my employer.0 -
Hi SilverX,
I tried to assign a blob value but it does not work.Table2.Blob2 := Table1.Blob1;
Here's a code sample I used:WITH Table1 DO BEGIN Table2.INIT; Table2.TRANSFERFIELDS(Table1); Table2."No." := "No."; Table2.Blob2 := Blob1; Table2.INSERT; END;
0 -
WITH Table1 DO BEGIN CALCFIELDS(Blob1); Table2.INIT; Table2.TRANSFERFIELDS(Table1); Table2."No." := "No."; Table2.Blob2 := Blob1; Table2.INSERT; END;
0 -
Please also take a look here: http://www.dynamics.is/?p=1267Cheers
Carsten
==> How To Ask Questions The Smart Way
This post is my own opinion and does not necessarily reflect the opinion or view of my employer.0 -
da_neal: I tried you example and didn't work. Calcfields cleared a blob value.
SilverX: I checked already a page you mentioned and tried with all code examples with no luck.0 -
Please use the debugger and check the length property of source and destination Blob. Before and after assignment. I assume the source is empty.Cheers
Carsten
==> How To Ask Questions The Smart Way
This post is my own opinion and does not necessarily reflect the opinion or view of my employer.0 -
Hi Mauritsio,
Probably you have a problem somewhere else in the code.
To check if your Blob-field has a value, use the following code:Table1.CALCFIELDS(Blob1); IF Table1.Blob1.HASVALUE THEN BEGIN Table2.INIT; Table2."No." := Table1."No."; Table2.Blob2 := Table1.Blob1; Table2.INSERT; END; Table2.CALCFIELDS(Blob2); MESSAGE('Blob value copied: ', Table2.Blob2.HASVALUE);
If you don't get a 'Yes' in the end, the problem is somewhere else.
Good luck.
My blog - https://www.HannesHolst.com/0 -
SilverX: I checked lenthg of source and destination from debugger before and after assignment
-> Source has value all the time but the destination doesn't.
HannesHolst: First CALCFIELDS for Blob1 clears the value of Blob1. If I run the code without calcfield for blob1 field, it has value all the time but blob2 does'nt even if calcfields are executed for blob2 after insert.0 -
May be you have 2 variable Table1 (check local - global)?0
-
@Mauritsio
You have to reveal the truth and post your actual code :-)
CALCFIELDS for a Blob is OK.
It's used by NAV-standard also. Check the screenshot.
My blog - https://www.HannesHolst.com/0 -
Okay
Here's my one try. My added code marked as yellow -> Codeunit5988
Calcfields empties blobfield InternalMsg. My intention is to assign InternalMsg blob field value from Service Header to Service Shipment Header that will end up to database table in INSERT.
0 -
@Mauritsio
I do not have a database to test Service Header posting, so, I'm guessing:
The function "PrepareShipmentHeader" is used in CU 5980 only and the "ServShptHeader" is a temporary record-variable.
The actual creation of the Posted Shipment Header takes place in function "CreatePostedShptHeader" of CU 5763.
In "CreatePostedShptHeader" each field is assigned line by line.
Try to add the new field in "CreatePostedShptHeader".
Cheers,My blog - https://www.HannesHolst.com/5 -
Thanks HannesHolst! PrepareShipmentHeader Function was not correct place for assigning blob to blob field since as you mentioned there were temporary rec variables used for collecting data into temporary record.
Instead, I added my code to CU5899 to funtion FinalizeShipmentDocument where the actual insert is done into Service Shipment Header table with rec variable PServShptHeader and it now works nicely.
0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 320 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions