Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Pass dynamic URL from Server Script to HTML in a widget

Talvin Singh
Tera Expert

Hello Reader,

I am trying to pass a URL from Server Script to the HTML content, but there seems some issue with the syntax. Here in my code, please suggest me a solution for the same.

HTML:

<a ng-href="{{data.link1}}">Download Diving License</a>

SERVER SCRIPT:

data.divinglicense = gr.getValue('x_87405_dive_man_0_license_image');
data.link1 = "https://dev12345.service-now.com/sys_attachment.do?sys_id="+data.divinglicense;

Here I am getting sys_id of the attachment from GlideRecord and using it to form a URL. But this is not working.

Kindly suggest.

Thanks

1 ACCEPTED SOLUTION

when you click on the what is happening exactly ?

is it taking you to new tab and then auto closing the tab with in  a second ?or it takes you to new tab and stays in the new tab with URL constructed with the attachment sys_id?

HTML 

<a href={{data.link1}} target="_blank">Download Diving License</a>

Server script:

data.divinglicense = gr.getValue('x_87405_dive_man_0_license_image');
data.link1 = "https://dev12345.service-now.com/sys_attachment.do?sys_id="+data.divinglicense.toString();

@Talvin Singh can you please try this

View solution in original post

3 REPLIES 3

Mohith Devatte
Tera Sage
Tera Sage

hello @Talvin Singh ,

Are you sure its the attachment sys_id?

you are trying to get the value of the attachment name I guess instead directly get the sys_id by querying with name

CAN YOU CONFIRM ON THIS ?

and also You need not use ng-href you can just use href and try !

Please use href and let me know 

Please mark my answer if it helps you

Hello Mohith, 

Thank you for the response.

Yes, It is sys_id of the attachment record. This is for sure.

Can you please provide syntax? I have tried it from end, but not being to achieve it.

Thanks

when you click on the what is happening exactly ?

is it taking you to new tab and then auto closing the tab with in  a second ?or it takes you to new tab and stays in the new tab with URL constructed with the attachment sys_id?

HTML 

<a href={{data.link1}} target="_blank">Download Diving License</a>

Server script:

data.divinglicense = gr.getValue('x_87405_dive_man_0_license_image');
data.link1 = "https://dev12345.service-now.com/sys_attachment.do?sys_id="+data.divinglicense.toString();

@Talvin Singh can you please try this