It appears that only the Button text can be formatted which is fine for my needs. I've tried using the following functions without success:
If ( "http://dl.dropbox.com/u/usercode/FileMaker/" & Site::site_number & "/Location.pdf" = "" ; 0 ; 1 )
Tried lots of variations but can't get any of the expressions to work unfortunately, any suggestions?
Try the GetLayoutObjectAttributes function. It can return the URL of the webviewer, and you may be able to parse a valid criterion from that, maybe.
Thanks for the tip Sorbsbuster, I can't get it to work yet though...
I created a Calculation field using:
GetLayoutObjectAttribute ( "Appendices_Web_Viewer"; "source" ) The Calc result is set to "Text" and repetitions is set at "1". The do not evaluate... checkbox is ticked. Global storage is off.
On the layout, I've added the field but it remains blank all the time. However, if I change the attribute from "source" to "objectType" in the Calc field then "Web Viewer" is returned as the result so I don't think I'm that far off returning the actual URL?
I have set up a test database with a web viewer (named as an object "Webviewer") set to show google.co.uk and when I set a calculation field to be:
WebViewerAttributes = GetLayoutObjectAttribute ( "WebViewer"; "source" )
it returns http://local.google.com/
Ok, getting closer I think...
I set the Calc field to "Unstored" so that the field updates each time I click a button to change the Web Viewer. However, I have to click inside the field for the change to take effect or refresh the window.
I've tried to automate this but not had much luck, also tried the "Set Feild" command but nothing!
Another snag that I'm going to run into is that the returned URL is identical irrespective of whether the file exists or whether a 404 error is displayed.
Having to refresh the field we can come back to later.
When I change my webviewer URL to be google.comco the calculation field returns my internet provider's default '404' page (a lot of gobbledegook about if you'd like to buy this domain name, etc). If that's not the case with you (and you are getting a gen-you-wine 404 error) can you not parse something from that?
BTW: at first glance the calculation can seem to return a blank, but if you extend the text box you may find that it is simply a very long continuous character string.
Ah sorry, the URL's are linking to www.dropbox.com so whenever a file doesn't exist, Dropbox displays its own 404 page due to the duff link.
So, is that not really good, because you then have a consistent 404 message to parse out the 404 from (say) and dim the button?
Ah, got you I think.
For example, if the returned URL contains the text "Error (404)", dim the button, change the font etc. Will have a look at that now...
Hmm, I changed the Calc field to "content" and found that if a valid PDF file is downloaded into the Web Viewer, then the Calc field is blank (after clicking into it). However, if the file doesn't exist, the field lists the HTML for the custom 404 page.
So, I tried conditional formats as follows:
not IsEmpty ( Sites_Addresses::c_web_viewer )
IsEmpty ( Sites_Addresses::c_web_viewer )
If ( Sites_Addresses::c_web_viewer =""; 0 ; 1 ) (I think this one needs to be in a separate field)
Look at the PatternCount function, and I think we're on the way...
Thanks, definitely getting closer!
I added the following conditional format to the Calc field:
PatternCount ( Sites_Addresses::c_web_viewer; "Error (404)" )
The HTML text that is returned when a file doesn't exist, is now highlighted in red.
However, the user will have to click the button first. This results in the custom 404 error. Then and only then, if he clicks into the Calc field, the HTML text will be displayed in red font.
Ideally, I would like it if the conditional formatting was displayed without the user having to click on any of the buttons. Is this possible? I'm guessing that a script trigger will need to kick in when the user arrives on this layout. The script would check whether the files exist at the destination and then highlight any buttons that only contain links to 404 pages...
It works for me if I trigger the field with a simple Go To Field, Select, Commit Record script. Can you set such a script to run OnLayoutLoad?