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

Mohith Devatte
Tera Sage
Tera Sage

Hello @Ramel ,

you can try this

You can use the below example to do this .Just replace the incident_list with your incident task table name

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

please mark my answer correct if it helps you

 

Hi Mohith,

I am using onload client script but this one is using current.sys_id. Can it be done on client script alone or need to use BR?

Regards,

hello @Ramel  then use this below script

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

 

it is returning the whole list of records, not just the record in the related list.