- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-13-2025 10:01 AM
Hi everyone, how are you?!
I created a "card" (img1), but I would like the user to be redirected to all the incidents opened by him when he clicks it, according to the query created in the Option Scheme called "filter" (img2) and that it opens in a new window.
I checked, but I didn't find any information for redirecting to another page according to the value contained in "Option Scheme" (such as options.filter) img3.
Example: According to the number of INCs opened by the user shown in the "Card", when he clicks it, he is redirected to the INC table with this filter. This is my code:
HTML:
<div ng-click="c.action('redirect')" type="button" class="cfs-card" target='_blank' href="?id=my_requests">
<h4 class="cfs-title">{{::c.options.title}}</h4>
<span><i class="fa fa-{{::options.glyph}} cfs-icon"></i></span>
<h1 class="cfs-total">{{::c.data.incResult}}</h1>
</div>
CLIENT SCRIPT:
api.controller=function() {
/* widget controller */
var c = this;
c.action = function(redirect){
var link = '?id=my_requests';
//var link = options.filter
top.window.location = link;
}
};
SERVER SCRIPT:
var incRecords = new GlideAggregate('incident');
incRecords.addAggregate('COUNT');
incRecords.addEncodedQuery(options.filter);
incRecords.query();
if(incRecords.next()){
var incTotal= incRecords.getAggregate('COUNT');
data.incResult = incTotal;
gs.addInfoMessage(data.incResult)
}
Could you support me? please! 😉
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-13-2025 12:28 PM
Hello @Elton2 ,
Please add the following line to the Server script:
data.filter = options.filter;
Then please use this as the Client Script:
api.controller=function($window) {
/* widget controller */
var c = this;
c.action = function(redirect){
var link = '?id=list&table=incident&target_page_id=ticket&filter=' + c.data.filter;
$window.open(link, '_blank');
}
};
No changes required on the HTML, although the "target" and "href" attributes on the div element are not supported and should be removed.
Please note that I'm using the "list" page here, instead of the "my_requests" page that you are trying to open in your version. This is because the widget on the latter page does not support passing table or filter parameters.
Regards,
Robert
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-13-2025 12:28 PM
Hello @Elton2 ,
Please add the following line to the Server script:
data.filter = options.filter;
Then please use this as the Client Script:
api.controller=function($window) {
/* widget controller */
var c = this;
c.action = function(redirect){
var link = '?id=list&table=incident&target_page_id=ticket&filter=' + c.data.filter;
$window.open(link, '_blank');
}
};
No changes required on the HTML, although the "target" and "href" attributes on the div element are not supported and should be removed.
Please note that I'm using the "list" page here, instead of the "my_requests" page that you are trying to open in your version. This is because the widget on the latter page does not support passing table or filter parameters.
Regards,
Robert
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-13-2025 01:28 PM
Hello @Robert H ,
I hope you are very well!!!
I used your suggestion and it is working!!!
Thank you very much for your support and attention.
It was a great tip!!!
Have a good day!!! 😉