Need to enable hyperlink in Variable Under Catalog item

vidyajadhav
Tera Contributor

vidyajadhav_0-1782299404730.png

Hi Team,

 

I have enabled this msg by writing below script in Catalog UI policy. But I want to add hyperlink so that user can click that link and can be routed to the Onboarding form. Which module i can use to enable this

 

var msg = "Choose the appropriate Project Business Role. " +
          "If you are not sure, please check with the Project Lead.<br><br>" +
          "Raise a separate request to complete the Business role onboarding " +
          "/sp?id=onboarding_formhere</a>, " +
          "if you cannot find your team's business role on the list.";

 

g_form.showFieldMsg('role_option', msg, 'info', false);
8 REPLIES 8

Tanushree Maiti
Tera Patron

Hi @vidyajadhav 

 

You can try with Rich Text Label variable / URL type variable to show the link the message based on selected variable value.

 

A community member has achieved it using DOM - It is not recommended. Refer:  https://www.servicenow.com/community/developer-forum/how-to-show-url-link-in-field-message-when-opti...

Please Accept the solution if it assisted you with your question & Mark this response as Helpful.
Regards
Tanushree Maiti
ServiceNow Technical Architect
LinkedIn: https://www.linkedin.com/in/tanushreemaiti

Hello @Tanushree Maiti ,

 

Unfortunately that gel method will not work in service portal ui , it will work on native ui(desktop) only 🙂

Ankur Bawiskar
Tera Patron

@vidyajadhav 

field messages don't support HTML Links etc

Couple of approaches

1) Either create URL type variable with default value and show/hide it based on your condition

OR

2) Create Rich Text Label variable and add link in it, then show/hide that variable based on your condition

💡 If my response helped, please mark it as correct and close the thread 🔒— this helps future readers find the solution faster! 🙏

Regards,
Ankur
Certified Technical Architect  ||  10x ServiceNow MVP  ||  ServiceNow Community Leader

pr8172510
Tera Guru

Hi @vidyajadhav,

I was able to achieve this requirement using a Rich Text Label 


Steps :

  1. Created a Rich Text Label variable in the Catalog Item.
  2. Added the informational message and hyperlink using HTML in the Rich Text editor (Source Code view).
  3. Styled the message using a <div> with background color, padding, and border to match the required UI.
  4. Used a Catalog UI Policy to show/hide the Rich Text Label based on the selected value in the Role/Option variable.

<div style="background: #d9edf7; border: 1px solid #bce8f1; padding: 10px; border-radius: 4px;">Choose the appropriate Project Business Role. <br><br>If you are not sure, please check with the Project Lead. <br><br>Raise a separate request to complete the Business Role onboarding <a href="/sp?id=sc_cat_item" target="_blank" rel="noopener noreferrer nofollow"> here </a> if you cannot find your team's business role on the list.</div>​



After testing in both Native UI and Service Portal, the hyperlink is displayed correctly and is clickable.
pr8172510_0-1782304677391.pngpr8172510_1-1782304695708.png

 

pr8172510_2-1782304723228.png

 

pr8172510_3-1782304769451.pngpr8172510_4-1782304853579.png