Customize Related List by adding custom columns

Not applicable

Hi All,

 

I want to show related incidents in Incident table but what I want to do is I want a link column that will give me link to view that particular incident, I want a number column but I don't want the whole number just the last 5 digits. Can such type of related list be displayed? On Configurable workspace? If yes, please tell me the detailed solution for that.

 

Thanks and Regards,

Hrithik

4 REPLIES 4

Mark Manders
Tera Patron

Just one question: Why? What is your business case? What is the requirement you are trying to fulfill? You will need to create a custom list field (there can be more records related to one incident) and will need to create a script that adds the 5 digits as a link to that field (so that would mean stripping the other characters and making a link of it). I can't think of any business case/requirement being worth the time you will have to spend on this. This is why ServiceNow created related records, which you can already see on your form view.

Dr Atul - LNG
Tera Patron

Hi @Community Alums 

 

May i know the use case of same? SHowing last 5 digits , what value it bring? ALso, what this new related list will do ?

Rajdeep Ganguly
Mega Guru


Yes, you can display such a related list in the Configurable Workspace in ServiceNow. Here are the steps to achieve this:

1. **Create a new Scripted Field:**
- Navigate to System Definition > Scripted Fields.
- Click on New.
- Fill in the necessary details like Table, Label, Type etc.
- In the Script field, write a script to get the last 5 digits of the incident number. For example:

var inc = new GlideRecord('incident');
inc.get(current.sys_id);
return inc.number.substring(inc.number.length - 5);

- Submit the form.

2. **Add the new field to the Incident Form:**
- Navigate to Incident > Open any Incident.
- Right-click on the header of the form and select Configure > Form Layout.
- Add the new field to the form and click on Save.

3. **Create a new List Layout:**
- Navigate to System Definition > List Layouts.
- Click on New.
- Select the Incident table and add the new field to the list.
- Submit the form.

4. **Add the new List Layout to the Configurable Workspace:**
- Navigate to Workspace Experience > Configurable Workspaces.
- Open the workspace where you want to add the list.
- Click on Add Component > List.
- Select the Incident table and the new list layout.
- Click on Save.

5. **Create a UI Action to open the Incident:**
- Navigate to System UI > UI Actions.
- Click on New.
- Fill in the necessary details like Table, Action Name, etc.
- In the Script field, write a script to open the incident. For example:

function openIncident() {
var inc = new GlideRecord('incident');
inc.get(current.sys_id);
window.open('/incident.do?sys_id=' + inc.sys_id);
}

- Submit the form.

Now, when you open the workspace, you will see the related incidents with a link to open the incident and the last 5 digits of the incident number.


nowKB.com

For asking ServiceNow-related questions try this :
For a better and more optimistic result, please visit this website. It uses a Chat Generative Pre-Trained Transformer ( GPT ) technology for solving ServiceNow-related issues.
Link - https://nowgpt.ai/

For the ServiceNow Certified System Administrator exams try this :
https://www.udemy.com/course/servicenow-csa-admin-certification-exam-2023/?couponCode=NOW-DEVELOPER

@Rajdeep Ganguly And now please answer the question that was actually asked, instead of just copy/pasting the nonsense AI gives you.