Search Option in My to Dos Widget
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-17-2022 09:36 PM
Hi Everyone,
In My To-do Widget, I wanted to add a Search filter. Is there any OOB way to achieve it?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-17-2022 09:52 PM
Hi
OOTB you cannot !! you will have to do some customization here.
You can include typeahead search widget by using:
<sp-widget widget="typeahead-search"></sp-widget>
For Example :
HTML:
<div>
<sp-widget widget="data.typeahead"></sp-widget>
</div>
Server script:
(function(){
data.typeahead =
$sp.getWidgetFromInstance('typeahead-search');
})();
Mark my answer correct & Helpful, if Applicable.
Thanks,
Sandeep
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-28-2022 11:30 PM
Hi
Thank you for your response.
I have tried the above method but it is taking to the default search. I wanted to search the items inside My To-do Widget. So I was trying to change in the same.
I was making modifications to the widget script. Tried to filter the output from the scriptinclude using filter function. I need to run two filter functions for open and completed. Unfortunately both were not running parallelly and the output was not getting filter out. In the below code, only completed filter function is getting executed if the search data is in completed section. If the searchdata is in open section, the filter function is running and the value is getting filtered but not reflecting in the portal. Tried using Async and await but those are not supported in this version. Also tried to use this filter function inside a for loop, but it is running in background script but not in widget. In widget it is throwing an error saying dont declare function inside a for loop. Is it possible for you to help me out here?
Client Script:
c.search = function() {
c.server.get({
action: 'loadTodos',
search_text: c.filterText
}).then(function(response){
c.data = response.data;
_.each(c.data.todosToShow.recordsToShow, function(todos, tab) {
c.todoDisplayed[tab] = getLeftMenuItems(todos, tab);
});
};
Server Script:
else if (input && input.action == "loadTodos") {
data.onTodoPage = true;
data.onTicketPage = false;
data.todosToShow = util.getMyTodos(data.queryLimit, [], input.includeTodo);
var req_id = "";
var searchdata = [];
var ch = false;
if (input.search_text) {
var task = new GlideRecordSecure('task');
task.addQuery('123TEXTQUERY321', input.search_text);
task.query();
if (task.next()) {
req_id = task.getUniqueValue();
searchdata.push(req_id);
}
if (req_id) {
var gr1 = new GlideRecord("sysapproval_approver");
var queryCondition = gr1.addQuery("document_id", req_id);
queryCondition.addOrCondition('sysapproval', req_id);
gr1.addEncodedQuery('sys_id=javascript:new global.ApprovalDelegationUtil().getMyAndDelegatedApprovals()^ORapprover=javascript:new global.ApprovalDelegationUtil().getApprovers()');
gr1.query();
if (gr1.next()) {
searchdata.push(gr1.getUniqueValue()); //sysid of searchtext in approval table
}
}
if (searchdata.length > 0 && !ch) {
var requiredObjcompleted = data.todosToShow.recordsToShow.completed.filter(function(item) {
return ~this.indexOf(item.sysId.toString());
}, searchdata);
if (requiredObjcompleted) {
data.todosToShow.recordsToShow.completed = requiredObjcompleted;
}
var requiredObj = data.todosToShow.recordsToShow.open.filter(function(item) {
return ~this.indexOf(item.sysId.toString());
}, searchdata);
if (requiredObj) {
data.todosToShow.recordsToShow.open = requiredObj;
}
data.searchresult = "";
} else {
data.searchresult = "Search didnt match any requests ";
}
}
data.watchers = data.todosToShow.recordWatchers || [];
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-05-2024 11:11 AM
Did you find a solution to enable contextual search for todos page?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-15-2022 07:31 AM
Hi Sandeep,
Under tab 'Open' in the My Todos widget, we have incidents, ritms and other records listed. I want to provide the user a drop-down where they can filter records based on the table. Has this feature been implemented? Thanks.