I would like to add a button to a form that opens an external webpage.
It should call a dynamic URL, i.e. I would like to pass for example a compound ID to pull up a web report on a compound. From what I understand I need to write a groovy script and paste it into the button Script field.
Do you by any change have an example script that I could use as a starting point that does something like this?
there is a (quite complex) script, which does something similar: http://www.chemaxon.com/instantjchem/ijc_latest/docs/developer/scripts/patent_fetcher.html
The interesting part is at the end - you need to use the Desktop.browse(url) method to open a default browser. The lines before just prepare the URL to show.
If you need to include only values of some fields into the URL, then maybe dynamic URL field would be much simpler to use and maintain. (New standard field -> URL field -> dynamic). See Pubchem demo entity in the demo project bundled with IJC for some examples of those fields. The text field in the form makes the link clickable.
Thanks for your answer. The dynamic URL field is indeed much simpler.
Now however I have this long URL on my Form....is there a way to give it a display name, so that it only shows something like "Compound Report" instead of the URL?
each field has a "Display name", which is by default displayed in the border of the text field widget. Also, you don't need to display the whole URL; the beginning should be enough. Unfortunately, as of IJC 5.8, it is not possible to overwrite the displayed link.
If this is not sufficient, then the button script can be used.