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

Hi Ankur,

There is an incident task record added in the related list. So if there is one incident task added in the related list, I want to  redirect the user to the specific incident task form when they click the link, easy for them to update the record. Instead of being redirected to the whole list of records and still need to filter and search for the incident task. I know they can just click on the incident task record but they also want to have added functionality that it can be done when they click the link in the infomessage.

@Ramel 

I believe I have answered your original question.

Would you mind marking my response as correct and helpful to close the thread.

Regards
Ankur

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

Hi,

but what if there are more than 1 incident tasks in related list?

which incident task you wish them to be taken?

any random one?

So I would suggest to show them list and then they can update whichever they want.

If you still want to pick random one then you will have to query incident_task table and get 1 record and then show the link

Regards
Ankur

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

Hi Ankur,

The first incident task always if there are multiple tasks. But if only one incident task then redirect to that form for them to update.

 

Hi,

then you need to script it in client side using GlideRecord

You can use GlideAjax as well since GlideRecord is not recommended in client side.

Regards
Ankur

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