- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-25-2023 08:00 AM
Hello SNC,
I have created a catalog form and it has a list collector variable which is refering to task table and my reference qualifier will filter the items, Everything is fine untill this point.
Now in the RITM created, I want all the selected items from the list collector(which are shown in the variables section) should be populated as individual items in the related list.
Please let me know how this can be achieved.
TIA
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-31-2023 10:24 AM
I was able to achieve it myself with the following line in the query of the custom related list,
current.addQuery('sys_id','IN',parent.variables.list_collector_name);
Might be usefull for anyone.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-25-2023 10:15 AM
No worries, I take no offense 🙂
However, from what I can see on that other thread, there is no mention of the results existing in different tables, which is part of the issue here - you need a single related list to display results from multiple tables, but together, no? (the list collector could grab problem and incident)
If not, this should be a LOT easier -- sorry, I misunderstood when I was suggesting an intermediate custom table to use as a join/view for your related list to use.
In this case, you could definitely set up the relationship as described in the other thread, but you would need a separate related list for each table that has a record type which could be selected with the list collector. You can then write a client script to which looks at each list to see if it is empty and hides it onLoad, if so.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-25-2023 10:15 AM
HI @Srikanth Menava ,
I trust you are doing great.
To achieve the desired functionality, you can follow these steps:
- Open the RITM (Requested Item) form in ServiceNow's Form Designer.
- Identify the related list where you want the selected items to be displayed individually.
- Add a new related list field to the form by clicking on the "Related Lists" tab in the Form Designer.
- Configure the related list field to display the selected items from the list collector variable.
- Use a UI Policy or Client Script to dynamically update the related list field based on the selected items in the list collector variable.
function onChangeListCollector() {
var selectedItems = g_form.getValue('list_collector_variable'); // Get the selected items from the list collector variable
var relatedList = g_form.getControl('related_list_field'); // Get the related list field control
// Clear the related list field to remove any existing items
relatedList.removeCurrentValues();
// Iterate through the selected items and populate them individually in the related list
for (var i = 0; i < selectedItems.length; i++) {
var item = selectedItems[i];
relatedList.addNewItem(item.value); // Add each selected item to the related list
}
}
// Attach the onChangeListCollector function to the list collector variable
g_form.addOnChange('list_collector_variable', onChangeListCollector);
Was this answer helpful?
Please consider marking it correct or helpful.
Your feedback helps us improve!
Thank you!
Regards,
Amit Gujrathi
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-25-2023 10:26 AM
AFAIK, you can't add a related list in Form Designer...you can add a "list" variable type to the form...is that what we are talking about here?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-26-2023 09:09 AM
@Amit Gujarathi so as @jMarshal at uLe says As Far As I know(AFAIK) I couldn't add related list in the form designer.
But I tried something else which gave me a partial result of what I want.
which showed me all the records in task table.
Now All I need is something in the add query line in the relationship.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-31-2023 10:24 AM
I was able to achieve it myself with the following line in the query of the custom related list,
current.addQuery('sys_id','IN',parent.variables.list_collector_name);
Might be usefull for anyone.