I have a form with a table view on it. The underlying records have a text field containing a path to a PDF file. This file may or may not exist. If it does exist, I want to display a little PDF icon for that record. If it doesn’t exist, I want a blank space.
In 6.0.x this used to work in the onRender() event of the button/label:
/** @type {JSRecord<{attachmentpath:String}>} */
var eventRec = JSRecord;
var currAttachpath = '';
eventRec = event.getRecord();
currAttachpath = eventRec.attachmentpath;
/** @type {JSLabel} */
var thisButton = event.getRenderable();
// -- Return icon depending on whether attachment file actually exists.
var attachmentFile = plugins.file.convertToJSFile(currAttachpath);
if (attachmentFile.exists())
{
imageURL = 'media:///pdficon_small.gif';
}
else
imageURL = 'media:///attachment_transparent.gif';
thisButton.imageURL = imageURL;
However that stopped working in 7.x, as the imageURL property is not available via getRenderable().
I have changed it to this (common code omitted):
thisButton.visible = (attachmentFile.exists()) ? true : false;
… however that is giving inconsistent results. Is there any reliable way to do this in web client?