- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-04-2023 04:43 AM - edited 01-04-2023 04:44 AM
I Have created a new widget in this widget i have added Filter Option using search option,
in that search option i need to filter option to select any task , how to set that?
@jaheerhattiwale can you help me in this one?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-04-2023 07:49 AM
@devservicenow k Tried and tested 100% working solution.
HTML script:
<div>
<div class="search-icon">
<input ng-model="c.keyword" type="text" placeholder="Search..">
<button type="button" ng-click="c.keywordSearch()"><i class="fa fa-search"></i></button>
</div>
<table class="table">
<tr>
<th>Number</th>
<th>Short Description</th>
</tr>
<tr ng-repeat="inc in data.incidents">
<td>{{inc.number}}</td>
<td>{{inc.short_description}}</td>
</tr>
</table>
</div>
Client script:
api.controller=function() {
/* widget controller */
var c = this;
c.keywordSearch = function(){
c.data.action = "keyword_search";
c.data.keyword = c.keyword;
c.server.update().then(function(resp){
})
}
};
Server Script:
(function() {
/* populate the 'data' object */
/* e.g., data.table = $sp.getValue('table'); */
data.incidents = [];
var inc = new GlideRecord("incident");
if(input && input.action=="keyword_search"){
inc.addQuery('123TEXTQUERY321', input.keyword);
}
inc.query();
while(inc.next()){
data.incidents.push({
"number": inc.number.toString(),
"short_description": inc.short_description.toString()
})
}
})();
Result:
Without search:
With search:
Note:
Replace the server side with your table and query
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-04-2023 04:47 AM
@devservicenow k Dont create custom widget. Clone the "Data table from URL Definition" widget and add it to your page ,you will get everything by default.
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-04-2023 04:57 AM - edited 01-05-2023 10:01 PM
i was instructed to not to clone from data table from url definition
Actually this is my Requirement:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-04-2023 05:33 AM
@devservicenow k Let me come back
ServiceNow Community Rising Star, Class of 2023
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-04-2023 07:49 AM
@devservicenow k Tried and tested 100% working solution.
HTML script:
<div>
<div class="search-icon">
<input ng-model="c.keyword" type="text" placeholder="Search..">
<button type="button" ng-click="c.keywordSearch()"><i class="fa fa-search"></i></button>
</div>
<table class="table">
<tr>
<th>Number</th>
<th>Short Description</th>
</tr>
<tr ng-repeat="inc in data.incidents">
<td>{{inc.number}}</td>
<td>{{inc.short_description}}</td>
</tr>
</table>
</div>
Client script:
api.controller=function() {
/* widget controller */
var c = this;
c.keywordSearch = function(){
c.data.action = "keyword_search";
c.data.keyword = c.keyword;
c.server.update().then(function(resp){
})
}
};
Server Script:
(function() {
/* populate the 'data' object */
/* e.g., data.table = $sp.getValue('table'); */
data.incidents = [];
var inc = new GlideRecord("incident");
if(input && input.action=="keyword_search"){
inc.addQuery('123TEXTQUERY321', input.keyword);
}
inc.query();
while(inc.next()){
data.incidents.push({
"number": inc.number.toString(),
"short_description": inc.short_description.toString()
})
}
})();
Result:
Without search:
With search:
Note:
Replace the server side with your table and query
Please mark as correct answer if this solves your issue.
ServiceNow Community Rising Star, Class of 2023