Using a simple list in a portal form
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-13-2023 03:54 PM
Hello All.
I would like to use a simple list in a parent form and filter out it's child documents using the filter that is in the simple list widget. So, in the filter section of the parent I have tried: parent_number=javascript:$sp.getValue('sys_id'), parent_number=javascript:g_form.getValue('sys_id'), but nothing seems to work. I've hardcoded in a sys_id in the filter and that seems to work fine, however I can't seem to do it dynamically. Any thoughts/ideas?
I opted not to use the 'related list' feature as I didn't like the 'user experience' it provides.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-14-2023 01:55 AM
Hi @PeteM1 ,
var parentNumber = g_form.getValue('sys_id');
function setFilterForSimpleList() {
var listWidget = g_form.getControl('your_list_widget_field_name');
var filter = 'parent_number=' + parentNumber; // Construct your filter condition
listWidget.filter = filter;
listWidget.refresh();
}
Thanks,
Anand
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-14-2023 02:18 AM
Hello @Anand Kumar P and thank you for the quick response. I currently have this script running in a onload client script as below, but it does not seem to get the sys_id of the record. Should this be in an onload script..or should it be somewhere else? Thanks in advance.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-14-2023 05:52 AM
Hi @PeteM1 ,
Yes you can use it on onload client script update with below script
var parentNumber = g_form.getUniqueValue();
Thanks,
Anand
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-14-2023 03:11 PM - edited 10-14-2023 03:12 PM
Thanks again for the response @Anand Kumar P. After another unsuccessful attempt, it appears getControl is not supported in a Portal. So, I found this alternative (https://www.servicenow.com/community/developer-forum/embedded-sp-widget-options/m-p/1612824) and it seems to work well. The only issue I am having with it is I need it to use a recordwatcher. I am hoping that is just some sort of option I can set as part of the server side code.....