- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-21-2023 02:35 AM
Dear Team,
This is related to a similar ask posted earlier, refer to the below URL-
Requesting help on the Filter field of the Simple list widget (screenshot highlighted section) so that it displays only those task(s) associated with a RITM when the user access Service Portal> My Requests-RITMXXXXXX.
Currently, I applied the filter 'request_itemISNOTEMPTY' filter on the sc_task table but it displays all Tasks in the instance, which is not desired.
Please help on this
Thank you
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-23-2023 05:13 PM
Hello @rishabh31 ,
So, I used the Widget "Data Table from Instance Definition" and used the "Clone Widget" UI Action
Then, in the clone, I updated the Server script to enhance my filter (in my use case, I was looking at Catalog Tasks tied to RITMs, so my script update occurred at around line 25, where I added the filter for the sys_id of the current record to the filter on the data table. I then check to see if there is a filter from the widget itself. If not, then the word "Null" would be present and I forgo adding it:
Finally, I add the widget to the page and then set the table and fields I want on the table. If you want a custom filter, you can set it due to the filter check we did on line 35 and it will append that filter here.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-24-2023 05:38 AM
@rishabh31 Simple list won't work in this scenario
In Standard ticket configuration
you can add new tab called Tasks configure accordingly.
Below is OOB custom one created wm_order table to get their tasks.
Similarlly you can do for Requested item as well
They used "Work order Tasks for Work Order" widget we have to create one new widget replicate same for sc_tasks.
Bharath Chintala
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-24-2023 06:48 AM
Terribly sorry @rishabh31 ,
I should have realized my mistake when sending you the screenshots. I had a bug in my code. On line 27 of your server script, it should read:
data.filter = "request_item=" + sys
without that "=" the filter will fail, which is what is happening. Please try that and let me know your results.
Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-23-2023 05:13 PM
Hello @rishabh31 ,
So, I used the Widget "Data Table from Instance Definition" and used the "Clone Widget" UI Action
Then, in the clone, I updated the Server script to enhance my filter (in my use case, I was looking at Catalog Tasks tied to RITMs, so my script update occurred at around line 25, where I added the filter for the sys_id of the current record to the filter on the data table. I then check to see if there is a filter from the widget itself. If not, then the word "Null" would be present and I forgo adding it:
Finally, I add the widget to the page and then set the table and fields I want on the table. If you want a custom filter, you can set it due to the filter check we did on line 35 and it will append that filter here.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-24-2023 04:53 AM
Hello @Joshua_Quinn Sir,
Thank you for your response, I tried the way and halfway approached it as well but could not display only the task(s) associated with respective RITM as currently, it's displaying all the tasks. (below screenshot for reference)
I want only associated task(s) to display like in this case, RITM0010046 has only 1 task-SCTASK0010006 (shown in RITM record screenshot below)
Please find below the screenshots of cloned Data table widget Server Script customization (rest script kept as it is) as advised by you
Also below is the snapshot of the cloned widget instance with a table in Designer where I am not keeping any filter.
Could you please help to only filter the associated task(s) of related RITM0010046 has only 1 task-SCTASK0010006 so displays only SCTASK0010006, the same dynamically for all other RITMs.
Thank you
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-24-2023 06:48 AM
Terribly sorry @rishabh31 ,
I should have realized my mistake when sending you the screenshots. I had a bug in my code. On line 27 of your server script, it should read:
data.filter = "request_item=" + sys
without that "=" the filter will fail, which is what is happening. Please try that and let me know your results.
Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-25-2023 12:05 AM
Hi @Joshua Quinn Sir,
Thank you, below change in the Server script of cloned widget of the Data table from instance definition makes this work as expected.
data.filter = "request_item=" + sys
Now the Server Script for the cloned widget named 'Copy of Data Table from Instance Definit'
it looks like below:
(function() {
/* "use strict"; - linter issues */
// populate the 'data' object
var sp_page = $sp.getValue('sp_page');
var pageGR = new GlideRecord('sp_page');
pageGR.get(sp_page);
data.page_id = pageGR.getValue("id");
$sp.getValues(data);
if (data.field_list) {
data.fields_array = data.field_list.split(',');
} else {
data.field_list = $sp.getListColumns(data.table);
}
if (input) {
data.p = input.p;
data.o = input.o;
data.d = input.d;
data.q = input.q;
}
data.p = data.p || 1;
data.o = data.o || $sp.getValue('order_by');
data.d = data.d || $sp.getValue('order_direction');
//Set filter based on the record sys_id//
var sys = $sp.getParameter('sys_id');
data.filter = "request_item=" + sys;
//------------------------------------//
data.page_index = (data.p - 1);
data.window_size = $sp.getValue('maximum_entries') || 10;
data.window_start = (data.page_index * data.window_size);
data.window_end = (((data.page_index + 1) * data.window_size));
//Add the and to the filter if the filter hasn't been added yet//
var custom_filter = '^' + $sp.getValue('filter');
if (!custom_filter.toLowerCase().contains('null')) {
data.filter = data.filter + custom_filter;
}
//--------------------------------------//
//data.filter = $sp.getValue("filter");
//-------------------------------------//
var gr = new GlideRecordSecure(data.table);
if (!gr.isValid()) {
data.invalid_table = true;
data.table_label = data.table;
return;
}
data.table_label = gr.getLabel();
options.table = data.table;
options.fields = data.field_list;
options.o = data.o;
options.d = data.d;
options.filter = data.filter;
options.window_size = data.window_size;
options.view = data.view;
options.useInstanceTitle = true; // to make sure Data Table widget uses headerTitle always
options.headerTitle = options.title;
options.show_breadcrumbs = true;
data.dataTableWidget = $sp.getWidget('widget-data-table', options);
})();
Thanks for the solution. Marking as correct
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-18-2023 01:20 PM - edited 05-18-2023 01:22 PM
Hey Josh,
Thanks for the wonderful solution but i don't know why its not working for me, even i can't see any list of catalog task.
i don't see the table field configuration so that i can select the table name