- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-09-2023 12:11 AM
I have Created a Widget with the Filter option using Search option .
and the HTML and server script is working fine
and the Records is searched easily by search option
Now i need to Add one more Filter in that Widget
like the marked one i need the Filter in the widget.
in the View Filter instead of Closed Request i need case records/case task records .
how to do that can anyone help me.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-09-2023 03:28 AM
@devservicenow k Add the below code to exiting widget.
HTML:
<sn-choice-list
field="c.mychoice"
sn-model="c.mychoice"
sn-options="c.mychoicelistoption"
sn-value-field="myChoiceValue"
sn-text-field="myChoiceDisplay"
sn-items="c.mychoiceoptions"
sn-on-change="c.changeClass(selectedValue)">
</sn-choice-list>
Client controller:
c.mychoiceoptions = [
{
myChoiceDisplay:"All",
myChoiceValue:"all"
},
{
myChoiceDisplay:"Case records",
myChoiceValue:"case_records"
},
{
myChoiceDisplay:"Case tasks",
myChoiceValue: "case_tasks"
}
];
c.mychoicelistoption = {
hideSearch: true
};
c.mychoice = "all";
c.changeClass = function(taskType){
c.data.action = "change_class";
c.data.taskType = taskType;
c.server.update();
}
Server script:
if(input && input.action=="change_class"){
if(input.taskType == "all"){
inc.addEncodedQuery("task.sys_class_name=sn_customerservice_task^ORtask.sys_class_name=sn_customerservice_case");
}else if(input.taskType == "case_records"){
inc.addEncodedQuery("task.sys_class_name=sn_customerservice_case");
}else if(input.taskType == "case_tasks"){
inc.addEncodedQuery("task.sys_class_name=sn_customerservice_task");
}
}
Please mark as correct answer if this solves your issue.
ServiceNow Community Rising Star, Class of 2023
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-09-2023 03:28 AM
@devservicenow k Add the below code to exiting widget.
HTML:
<sn-choice-list
field="c.mychoice"
sn-model="c.mychoice"
sn-options="c.mychoicelistoption"
sn-value-field="myChoiceValue"
sn-text-field="myChoiceDisplay"
sn-items="c.mychoiceoptions"
sn-on-change="c.changeClass(selectedValue)">
</sn-choice-list>
Client controller:
c.mychoiceoptions = [
{
myChoiceDisplay:"All",
myChoiceValue:"all"
},
{
myChoiceDisplay:"Case records",
myChoiceValue:"case_records"
},
{
myChoiceDisplay:"Case tasks",
myChoiceValue: "case_tasks"
}
];
c.mychoicelistoption = {
hideSearch: true
};
c.mychoice = "all";
c.changeClass = function(taskType){
c.data.action = "change_class";
c.data.taskType = taskType;
c.server.update();
}
Server script:
if(input && input.action=="change_class"){
if(input.taskType == "all"){
inc.addEncodedQuery("task.sys_class_name=sn_customerservice_task^ORtask.sys_class_name=sn_customerservice_case");
}else if(input.taskType == "case_records"){
inc.addEncodedQuery("task.sys_class_name=sn_customerservice_case");
}else if(input.taskType == "case_tasks"){
inc.addEncodedQuery("task.sys_class_name=sn_customerservice_task");
}
}
Please mark as correct answer if this solves your issue.
ServiceNow Community Rising Star, Class of 2023
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-09-2023 04:21 AM
yeah i have tried on Loading the sp portals, when we click on that filter it is displaying
no records found
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-09-2023 04:23 AM
@devservicenow k Send the screenshot of code
ServiceNow Community Rising Star, Class of 2023
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-09-2023 04:31 AM
this is the code