- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-09-2025 02:59 PM
Hi everyone, how are you?
I'm creating the Options Scheme, I've already created "Title" using Options Scheme (img1), but I'm not sure how to create an Option to include or select a table and this field needs to be mandatory.
Obs.: I tried to pass data.table (img0) as a parameter in the Server Script, but it is not working
I'm using "GlideAggregate" in the Incidents table, but I'd like this Incidents table to be inserted through Options (img2)
I created the Option Scheme for "Title" and it's working, but I don't understand how to do it for the table. (img3)
This is my code:
HTML:
<div>
<div class="cfs-component-indicator">
<div class="cfs-indicator">
<p class="cfs-inc-title"> {{::c.options.title}} </p>
<!--<p class="cfs-inc-title"> {{::c.options.table}} </p> -->
<h2 class="cfs-inc-number"> {{data.displayQtdIncs}}</h2>
</div>
</div>
</div>
Server Script:
(function() {
/* populate the 'data' object */
/* e.g., data.table = $sp.getValue('table'); */
var incNumbers = new GlideAggregate('incident');
incNumbers.addAggregate('COUNT');
incNumbers.addEncodedQuery('active=true^assigned_toDYNAMIC90d1921e5f510100a9ad2572f2b477fe^ORDERBYDESCsys_updated_on');
incNumbers.query();
if(incNumbers.next()){
var displayIncNumbers = incNumbers.getAggregate('COUNT');
data.displayQtdIncs = displayIncNumbers;
options.title = options.title || "";
/*options.table = options.table || "";*/
}
})();
Could you support me? please.
Thanks 😉
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-10-2025 05:31 AM
Hi @Elton2 ,
i am doing grate!! hope your doing good!!
yes, you can use options.filter to fetch the query and you can use {{::c.options.filter}} to display.
for example:
<div>
<div class="cfs-component-indicator">
<div class="cfs-indicator">
<p class="cfs-inc-title"> {{::c.options.title}} </p>
<p class="cfs-inc-title"> {{::c.options.table}} </p>
<p class="cfs-inc-title"> {{::c.options.filter}} </p>
<h2 class="cfs-inc-number"> {{data.displayQtdIncs}}</h2>
</div>
</div>
</div>
server side
(function() {
/* populate the 'data' object */
/* e.g., data.table = $sp.getValue('table'); */
gs.addErrorMessage(data.table)
var incNumbers = new GlideAggregate(options.table);
incNumbers.addAggregate('COUNT');
incNumbers.addEncodedQuery(options.filter);
incNumbers.query();
if(incNumbers.next()){
var displayIncNumbers = incNumbers.getAggregate('COUNT');
data.displayQtdIncs = displayIncNumbers;
options.title = options.title || "";
/*options.table = options.table || "";*/
}
})();
it will work.
Refer this :Widget Option Schema
Please mark my answer correct & helpful, if it helps you
Thanks,
BK
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-09-2025 10:40 PM - edited 04-09-2025 10:43 PM
Hi @Elton2 ,
Please try below:
var incNumbers = new GlideAggregate(options.table);
Server side script:
(function() {
/* populate the 'data' object */
/* e.g., data.table = $sp.getValue('table'); */
//gs.addErrorMessage(data.table) - it will be undefined so use options.table
var incNumbers = new GlideAggregate(options.table);
incNumbers.addAggregate('COUNT');
incNumbers.addEncodedQuery('active=true^assigned_toDYNAMIC90d1921e5f510100a9ad2572f2b477fe^ORDERBYDESCsys_updated_on');
incNumbers.query();
if(incNumbers.next()){
var displayIncNumbers = incNumbers.getAggregate('COUNT');
data.displayQtdIncs = displayIncNumbers;
options.title = options.title || "";
/*options.table = options.table || "";*/
}
})();
Thanks,
BK
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-10-2025 05:11 AM
Hi @Bhavya11 , how are you?!
Thanks for your suggestions!!!
Yes! I used "options.table" and it's working!!! 😉
Another doubt:
I don't know if it's possible, but I created a schema option called "Filter", because I would like to
pass a query, because I don't want to leave this query fixed in the code (img4)
1) I created an option called "Filter"
2) options.filter = options.filter
3) {{::c.options.filter}}
Example:
Server Script:
optioms.filter = options.filter | " ";
HTML:
<p>{{::c.options.filter}}</p>
Obs: I was looking at the documentation, but I didn't find anything regarding options.table and "options.filter"
Is this possible?
Thanks again!!!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-10-2025 05:31 AM
Hi @Elton2 ,
i am doing grate!! hope your doing good!!
yes, you can use options.filter to fetch the query and you can use {{::c.options.filter}} to display.
for example:
<div>
<div class="cfs-component-indicator">
<div class="cfs-indicator">
<p class="cfs-inc-title"> {{::c.options.title}} </p>
<p class="cfs-inc-title"> {{::c.options.table}} </p>
<p class="cfs-inc-title"> {{::c.options.filter}} </p>
<h2 class="cfs-inc-number"> {{data.displayQtdIncs}}</h2>
</div>
</div>
</div>
server side
(function() {
/* populate the 'data' object */
/* e.g., data.table = $sp.getValue('table'); */
gs.addErrorMessage(data.table)
var incNumbers = new GlideAggregate(options.table);
incNumbers.addAggregate('COUNT');
incNumbers.addEncodedQuery(options.filter);
incNumbers.query();
if(incNumbers.next()){
var displayIncNumbers = incNumbers.getAggregate('COUNT');
data.displayQtdIncs = displayIncNumbers;
options.title = options.title || "";
/*options.table = options.table || "";*/
}
})();
it will work.
Refer this :Widget Option Schema
Please mark my answer correct & helpful, if it helps you
Thanks,
BK
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-10-2025 06:37 AM
Hi @Elton2 ,
If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.
Thanks,
BK