Display infomessage with link to the related list records

Ramel
Mega Guru

Hi Community,

I have a requirement to display an infomessage that contains the link that will direct to the list of records in the related list. Like for example I have an incident, then I have a related list called Incident Tasks, the infomessage is displayed in the incident form but how can I write in script format so that the link in the infomessage will direct the user to the list of records  or to the form record in the incident task related list?

 

function onLoad() {

g_form.addInfoMessage("Please <a href = '/incident_list.do'>Click</a>"); // the bold part, what should I replace it so i can be redirected to the list of incident tasks that is added 

}

1 ACCEPTED SOLUTION

Hi,

please update as this and it should work fine

you should use ? I showed in bold below

function onLoad() {

    g_form.addInfoMessage("Please <a href = '/incident_task_list.do?sysparm_query=parent=" + g_form.getUniqueValue() + "^ORincident=" + g_form.getUniqueValue() + " target='_blank'>Click</a>");

}

Regards
Ankur

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

View solution in original post

19 REPLIES 19

@Ramel 

can your try this

var link = '<a href="incident_task_list.do?sysparm_query=incident=">'+g_form.getUniqueValue()+'List Link</a>';
var message = gs.getMessage('Incident tasks') + ' ' + link + ' ';
g_form.addInfoMessage(message);

 

mark my answer correct if it helps you

@Ramel did my response help ?

if yes please mark the answer correct and close the thread ,if not let me know how i can help with the issue?

Hi Mohith,

It is still not working, in var message you are still using gs.getMessage which is not working in client side. I am trying to use this format

g_form.addInfoMessage("Please <a href = '/incident_list.do'>Click</a>");

Just in one go, no more var declaration. I tried Ankur's suggestion but it redirects to not found.

function onLoad() {

	g_form.addInfoMessage("Please <a href = '/incident_task_list.do&sysparm_query=parent=" + g_form.getUniqueValue() + "^ORincident=" + g_form.getUniqueValue() + " target='_blank'>Click</a>");

}

Hi,

I shared the update code below check that

Regards
Ankur

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

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

like this in your client script

function onLoad() {

	g_form.addInfoMessage("Please <a href = '/incident_task_list.do&sysparm_query=parent=" + g_form.getUniqueValue() + "^ORincident=" + g_form.getUniqueValue() + " target='_blank'>Click</a>");

}

Regards
Ankur

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