Loading an Image

I have a List View form that shows medications that have been prescribed for a patient. I have a background color calc to help distinguish between records on the form. When a medication sample is given out by the doctor, my background calc colors those records accordingly, but I would also like the word “SAMPLE” to appear on that record. I have loaded “Med_Sample.png” into my media library and created media field “med_sample” in the database. I then put the “med_sample” field on the form. Since I only want the word “SAMPLE” to appear on certain records, I thought this would be the best way to go. I’m having trouble getting the media field to populate with the image. I’ve tried

med_sample = plugins.images.getImage('media:///Med_Sample.png').getData();

Am I going about this the right way? Does anyone have another suggestion?

Thanks,
Nicholas Dunn
E-Automation Systems

Here is something I’ve come up with. I have changed my database field type from media to text. I added the field to my form and changed it’s display type to HTML_AREA. I then passed in the image like so:

med_sample = "<html><body><img src = 'media:///Med_Sample.png' /></body></html>";

This gives me the result I was looking for. If anyone has a better solution I’d appreciate the help.

Try using this:

med_sample = plugins.http.getMediaData('media:///Med_Sample.png');

When I try:```
med_sample = plugins.http.getMediaData(‘media:///Med_Sample.png’);

gldni:
med sample is set to “[B@1cb285b”.

Try set your elementtype to ‘IMAGE_MEDIA’

Ah. I overlooked that detail. I’m glad it’s Friday!

Thanks!

I noticed today when I opened my solution, the images I saved aren’t appearing. I can save an image to the database, but after restarting the solution they are gone. Am I still missing a step?

gldni:
I noticed today when I opened my solution, the images I saved aren’t appearing. I can save an image to the database, but after restarting the solution they are gone. Am I still missing a step?

Please check the length of the media field.
In my machine I can see a number like this : 2147483647

Thanks

I looked at the db table, and the field length was set to 500. I re-created the field, and it now has a length of 2147483647. I closed and re-opened my solution and this time the image was saved correctly. Thanks for the help!