Widget - Select table through "Options Scheme"

Elton2
Tera Contributor

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 😉

 

 

1 ACCEPTED SOLUTION

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

 

View solution in original post

5 REPLIES 5

Elton2
Tera Contributor

Hi @Bhavya11 , I'm glad you are very well!!!

I'd like to thank you for your attention, I did it here and now it is working very well!!!

Thanks again for your suggestion!!!

Best regards 😉