[progress Communities] [progress Openedge Abl] Forum Post: Re: Can I Display An Image On Ms...

  • Thread starter Thread starter Shiva Duriseati
  • Start date Start date
Status
Not open for further replies.
S

Shiva Duriseati

Guest
Hi Jirawat, Currently Rollbase support inserting image into DOC only through "image upload" field. Since your are getting image from hostedfile you were not able to insert into DOC. I have created a defect #46595 for this and will let you know ETA very soon. However since you are on Private Cloud ,you can add java classes to be exposed to Rollbase javascript. Util the fix is available you can make use of the below workaround. Steps: 1)Convert the HostedFileImage to ImageUploadField. 2)For the above operation there is a server side API called "rbv_api.setBinaryFieldValue()". In the above step we need to pass base 64 encoded value of image as one of the parameter. But using pure js encoded value cannot be generated,but with help of java classes this can be be done. (In Rollbase Private Cloud java classes can be added and later can be exposed to Rollbase javascript). 3)Once you have the encoded value which is generated from above step you can directly call "rbv_api.setBinaryFieldValue()" to convert hostedfile to image upload field. 4)Run the document template(which should be using image upload field token). Now to achieve the above operation,please follow the below steps: 1)Create an "Image Upload" field (ex:ImageUploadField) 2)Add the token of above created field in your doc template (ex:{!ImageUploadField}) 3)Add a key "CustomClassFilter" in shared.properties file as below and restart the server. CustomClassFilter=(sun.net.ftp.*)|(java.net.*)|(java.lang.*)|(java.io.*)|(sun.net.www.protocol.*)|(java.awt.*)|(javax.imageio.*)|(sun.misc.*) 4)Create an object script trigger and copy the below code in trigger section: var url=new Packages.java.net.URL("{!#HOSTED_FILE.qkAtE82oQyu17TI0PdtxaQ}"); var img=new Packages.javax.imageio.ImageIO.read(url.openStream()); var bos=new Packages.java.io.ByteArrayOutputStream(); var imageString=""; new Packages.javax.imageio.ImageIO.write(img,"jpg",bos); var imageBytes=bos.toByteArray(); var encoder = new Packages.sun.misc.BASE64Encoder(); imageString=encoder.encode(imageBytes); bos.close(); rbv_api.println(imageString); rbv_api.setBinaryFieldValue("Account_1", "{!id}", "ImageUploadField", imageString, "image/jpg", "some file name"); rbv_api.runTemplate("Account_1", "{!id}", "QpVnYn1xTiWSrcdPFFRdTw") ; Please let us know in case you need any assistance. Regards, Shiva

Continue reading...
 
Status
Not open for further replies.
Back
Top