One table to get another table list view
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-20-2024 01:17 AM
Hello community team,
I have one doubt that how to get the field of one table to get the another table list view without having any relationship.
Is it achievable in anyway?
Please help me to get resolve the issue.
Thanks in advance
- 473 Views
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-20-2024 01:19 AM
You can do via Dot Walk. but if you provide more details that will be good.
But the other table must reference the previous table. If there is no relationship we cant do.
If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.
Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/atul_grover_lng [ Connect for 1-1 Session]
****************************************************************************************************************
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-20-2024 02:29 AM
Hi @Sujit Jadhav ,
In List layout, you can right click on any column header & go to configure > list layout. Like below you can show the another table details.
HIT Helpful & Accept Solution !!!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-20-2024 02:47 AM
Yes, it is achievable to get the field of one table to another table list view without having any relationship. You can achieve this by creating a script include and a UI script. Here are the steps:
1. **Create a Script Include:**
- Go to System Definition > Script Includes.
- Click on New to create a new script include.
- Give it a name and make sure it is accessible from the client-side by checking the 'Client callable' checkbox.
- In the script, write a function that uses GlideRecord to query the table and get the field value you want.
Sample code for Script Include:
javascript
var GetFieldValue = Class.create();
GetFieldValue.prototype = Object.extendsObject(AbstractAjaxProcessor, {
getFieldValue: function() {
var tableName = this.getParameter('sysparm_tableName');
var recordId = this.getParameter('sysparm_recordId');
var fieldName = this.getParameter('sysparm_fieldName');
var gr = new GlideRecord(tableName);
if (gr.get(recordId)) {
return gr.getValue(fieldName);
}
return '';
},
type: 'GetFieldValue'
});
2. **Create a UI Script:**
- Go to System UI > UI Scripts.
- Click on New to create a new UI script.
- Give it a name and make sure it runs on 'Desktop' and 'Mobile'.
- In the script, write a function that calls the script include you created earlier and updates the field in the list view.
Sample code for UI Script:
javascript
function updateListView(tableName, recordId, fieldName) {
var ga = new GlideAjax('GetFieldValue');
ga.addParam('sysparm_name', 'getFieldValue');
ga.addParam('sysparm_tableName', tableName);
ga.addParam('sysparm_recordId', recordId);
ga.addParam('sysparm_fieldName', fieldName);
ga.getXMLAnswer(function(answer) {
g_list.editRecord(recordId, fieldName, answer);
});
}
3. **Call the UI Script Function:**
- You can call the function you created in the UI script from a client script or UI action.
- You need to pass the table name, record ID, and field name as parameters.
Sample code to call the function:
javascript
updateListView('incident', 'b03eb86037512300e0ef563dbb9a71c2', 'short_description');
Please note that this is a workaround and may not be the best practice. It's always recommended to establish a relationship between tables if you need to get data from one table to another.
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