Importing picture to BLOB field
Nagi
Member Posts: 151
Hi,
I'm trying to create a BLOB field where I want to upload a picture. I have a field type BLOB with the subtype property set to BitMap. There is no C/AL code in the field. Next, I have a form where I've copied the menu items pertaining to the Picture button on the Company Information form. I can't find any other C/AL code that needs to be copied, other than the code in the OnPush trigger to Import, Export, and Delete. With only minor alterations to the code, my code looks like this:
SignatureExists is a variable of type Boolean (similar to PictureExists in the Company Information form) and Signature is the BLOB field.
For some reason, this doesn't work. I can't import the picture. There is no error message of any kind, but the picture just isn't imported to the record. I've tried importing the picture in the Company Information form, just to make sure that the picture matches any given criteria allowing it to be imported, and it worked fine.
If anybody has any suggestions on this, I would be very grateful.
Cheers!
I'm trying to create a BLOB field where I want to upload a picture. I have a field type BLOB with the subtype property set to BitMap. There is no C/AL code in the field. Next, I have a form where I've copied the menu items pertaining to the Picture button on the Company Information form. I can't find any other C/AL code that needs to be copied, other than the code in the OnPush trigger to Import, Export, and Delete. With only minor alterations to the code, my code looks like this:
<Control1101101024> - OnPush() //IMPORT
SignatureExists := Signature.HASVALUE;
IF Signature.IMPORT('*.BMP',TRUE) = '' THEN
EXIT;
IF SignatureExists THEN
IF NOT CONFIRM(Text001,FALSE) THEN
EXIT;
CurrForm.SAVERECORD;
<Control1101101025> - OnPush() //EXPORT
IF Signature.HASVALUE THEN
Signature.EXPORT('*.BMP',TRUE)
ELSE
MESSAGE(Text003);
<Control1101101026> - OnPush() //DELETE
IF Signature.HASVALUE THEN BEGIN
IF CONFIRM(Text002,FALSE) THEN BEGIN
CLEAR(Signature);
CurrForm.SAVERECORD;
END;
END ELSE BEGIN
MESSAGE(Text004);
END;
SignatureExists is a variable of type Boolean (similar to PictureExists in the Company Information form) and Signature is the BLOB field.
For some reason, this doesn't work. I can't import the picture. There is no error message of any kind, but the picture just isn't imported to the record. I've tried importing the picture in the Company Information form, just to make sure that the picture matches any given criteria allowing it to be imported, and it worked fine.
If anybody has any suggestions on this, I would be very grateful.
Cheers!
0
Answers
-
Ok, I will take it from other side. Why do you thing, that the file is not imported? How you are testing it?0
-
I've tried running the debugger, and it runs through the code without any interruptions. Not having done this before, I thought maybe I had to use an InStream to write to the BLOB field, but I can't find examples of it being done this way in Nav. The only C/AL code I've been able to find, is what I've copied. Therefore, I'm quite puzzled as to why this doesn't work. ](*,)0
-
Again.. how are you testing it?
If you are showing the picture in a report for example, you have to do CALCFIELDS before, or it won't show...0 -
Yes, I'm using CALCFIELDS(Signature) in an OnPreSection trigger on a report. I also tried adding a text box on the form and tie it to the field, just to see if the picture would be displayed, but nothing shows.0
-
The control box must be a Picture Box, not a text box, and it's better to do the calcfields in the OnAfterGetRecord trigger, not in the Presection, because if you are showing a hader, it might not display anything, since in the header the record is still not accesible...0
-
#-oThe control box must be a Picture Box
But still no picture.. The CALCFIELDS(Signature) is in the OnPreSection trigger in a footer section, but I've also tried it in the AfterGetRecord trigger.
I've also tried exporting the picture after importing it, with the C/AL code set up to deliver a message if there is no picture to export. When I try exporting the picture, the C/AL code returns this message.IF Signature.HASVALUE THEN Signature.EXPORT('*.BMP',TRUE) ELSE MESSAGE(Text003);
What am I not seeing? ](*,) ](*,) ](*,)
Thanks for the help so far, though. Always appreciated. =D>0 -
If there is value inthe BLOB field, you will see asterisk in the field when you run the table directly. If there are no data imported, it seems that they are not saved when the record is saved. Check if another code is called when the record is modified (like some code in OnModify of the table). May be that the code will clear the field.0
-
I figured it out! \:D/
In case anybody else happens upon the same problem, the solution was to use CALCFIELDS(Signature) in the OnPush trigger before trying to export/delete the picture. I suppose this is necessary because the table I have the BLOB field in has multiple records, and Company Information, where the code was copied from, does not. Same problem with the picture box. On a tabular form, you have to use CALCFIELDS in the AfterGetRecord trigger to load the picture. This doesn't seem to be necessary on a card-type form though.
So after changing text box -> picture box and adding CALCFIELDS in all the right places, it works
Thanks for all the help! =D> =D> =D>0 -
The calcfield in tabular form is needed to prevent calculation for all records when they are not needed. On the card form, you have just one record, it is not problem to call the calcfields automatically.. :-)0
-
also perhaps you don't know where your exporting
IF Signature.HASVALUE THEN Signature.EXPORT('c:\signature.BMP',FALSE);0
Categories
- All Categories
- 75 General
- 75 Announcements
- 66.7K Microsoft Dynamics NAV
- 18.8K 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
- 610 NAV Courses, Exams & Certification
- 1.9K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 251 Dynamics CRM
- 103 Dynamics GP
- 6 Dynamics SL
- 1.5K Other
- 991 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 28 Design Patterns (General & Best Practices)
- Architectural Patterns
- 9 Design Patterns
- 4 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1K General Chat
- 1.6K Website
- 77 Testing
- 1.2K Download section
- 23 How Tos section
- 249 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions
