Dynamic URL in 'Annotation' on a form

leonverster
Kilo Contributor

Hi, there

I have an URL in an 'Annotation' on a form, which opens another web site in a new window/tab. I wish to append a parameter to the URL so that it opens the target web site with a string in a search field on that site automatically. Here below is the hard coded href in the Annotation;

Visit the <a href="http://abr.business.gov.au/SearchByAbn.aspx?SearchText=84726886658" target="_blank">Visit ABN Lookup Site</a> to verify the ABN and Company Details.

ABR Website Link.png

The field on the form is 'u_abn' and I wish to pass this variable as parameter in the URL (in the above example the value is 84726886658). Assume one can do this with javascript in the annotation, but I am not sure how to achieve this. Anyone who can provide me with example code that will work in an Annotation?

Many thanks

4 REPLIES 4

Slava Savitsky
Giga Sage

I am not sure using annotations is the best approach in this case. It should be easier to achieve this with a simple info message. You can read the value from 'u_abn' field and build the URL in a 'display' business rule and use addInfoMessage() to display the text with the hyperlink to the user.



Business Rules - ServiceNow Wiki


GlideSystem - ServiceNow Wiki


Thanks for your reply, @Slava!



What I ended up doing is to generate the url with a client script and pass it into a read-only field on the form (Field Type = URL)



Cheers



Leon


You can have a dynamic annotation, and therefore a dynamic link in an annotation. Set the annotation to the text below USING FORM LAYOUT:



Visit the <a href="http://abr.business.gov.au/SearchByAbn.aspx?SearchText=${current.u_abn}" target="_blank">Visit ABN Lookup Site</a> to verify the ABN and Company Details.




Form designer will try and strip the HTML tags but Form Layout won't.




Note: this pulls from current.u_abn which is the value that was last saved to the database. It will not reflect changes made to the form field if Save has not been clicked yet.




cheers,


Howard


Matt211
Giga Contributor

This was tremendously helpful, thank you!!