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.

How to get the hyperlink in Onchange catalog client script?

Suvedha Vignesh
Tera Contributor

Hi all,

 

I have a requirement, in which i have to give the hyperlink for another catalog item. On change catalog client applies to variable set. I should get the hyperlink in error box.

 I could not able to achieve this in UI page/ Macro/ widget, because this is MVRS.

 

How can we achieve this?

 

1 ACCEPTED SOLUTION

Sujatha V M
Kilo Patron
Kilo Patron

@Suvedha Vignesh  Please find the syntax below used for onChange client script with 'newValue' details. 

 

 

var urlString = '<p><a class="web" target="_blank" href="' + "/incident.do?sys_id=" + newValue + '">' + "Click Here" + '</a></p>';

g_form.addInfoMessage('Your Incident is already escalated  If you want to know more ,please click' + urlString);

 

 

For testing purpose used the script in onLoad catalog client script by passing the generic url and the resulted as, 

 

Info Message : 

SujathaVM_0-1718898804430.png

Error Message :

SujathaVM_0-1718899046083.png

 

Reference : https://www.servicenow.com/community/developer-forum/how-to-give-link-in-alert-box-using-client-scri...

 

Please mark this as helpful and accept it as a solution if this resolves your query.

Thanks,

Sujatha V.M.

Please mark this as helpful and accept it as a solution if this resolves your query.
Sujatha V.M.

View solution in original post

3 REPLIES 3

Sujatha V M
Kilo Patron
Kilo Patron

@Suvedha Vignesh  Please find the syntax below used for onChange client script with 'newValue' details. 

 

 

var urlString = '<p><a class="web" target="_blank" href="' + "/incident.do?sys_id=" + newValue + '">' + "Click Here" + '</a></p>';

g_form.addInfoMessage('Your Incident is already escalated  If you want to know more ,please click' + urlString);

 

 

For testing purpose used the script in onLoad catalog client script by passing the generic url and the resulted as, 

 

Info Message : 

SujathaVM_0-1718898804430.png

Error Message :

SujathaVM_0-1718899046083.png

 

Reference : https://www.servicenow.com/community/developer-forum/how-to-give-link-in-alert-box-using-client-scri...

 

Please mark this as helpful and accept it as a solution if this resolves your query.

Thanks,

Sujatha V.M.

Please mark this as helpful and accept it as a solution if this resolves your query.
Sujatha V.M.

Hi Sujatha,

 

Thanks for the reply.

SuvedhaVignesh_0-1718940575440.png

Is there a way can we get this Click here in first line, rather than it goes to secondline.

 

Thanks,

Suvedha.

Sumanth16
Kilo Patron

Hi @Suvedha Vignesh ,

Try something like the following:



1) Create a UI page and lets call it Link. Your UI page just need to have the following on its html field:

 

<a href="catalog_home.do?sysparm_view=catalog_default">Link</a>

 

 

2) Create a catalog variable of type UI Page and reference your recently created UI page Link

 

If my response proves useful, please indicate its helpfulness by selecting "Accept as Solution" and " Helpful."

 

Thanks & Regards,
Sumanth Meda