Display records in Service Portal page based upon the records start time and end time

testingniras
Tera Contributor

We have a requirement where we would have to display records from a custom table to a service portal page if the start date/time matches the current time and should not be displayed when the end date/time matches the current time.

 

Currently, the widget displays all the records from the table. 

 

Screenshot 2024-05-02 at 1.42.18 PM.png

 

Screenshot 2024-05-02 at 1.50.12 PM.png

1 ACCEPTED SOLUTION

Gustav Aldenbra
Kilo Sage

@testingniras if you embedd a standard simpel list into your widget you could do something like this to get the record where start date is in the past and end date is in the future. 

<widget id="widget-simple-list" options="data.list" ></widget>
  var gdt = new GlideDateTime();
  data.list = {
   "secondary_fields":"number",
   "always_show":"true",
   "table":"incident",
   "filter":"active=true^u_start_date<=" + gdt +"^u_end_date>" + gdt,
   "display_field":"short_description",
   "maximum_entries":"5"
   };

 

View solution in original post

4 REPLIES 4

Gustav Aldenbra
Kilo Sage

HI @testingniras 
Can you elaborate with some more information, How is the data presented now, is it a custom built widget or an ootb widget?

Hi @Gustav Aldenbra ,

Yes, it is a custom widget, which is fetching data from a custom table. The Widget uses a simple list instance to which we set the table and filter to draw data into the page.

Gustav Aldenbra
Kilo Sage

@testingniras if you embedd a standard simpel list into your widget you could do something like this to get the record where start date is in the past and end date is in the future. 

<widget id="widget-simple-list" options="data.list" ></widget>
  var gdt = new GlideDateTime();
  data.list = {
   "secondary_fields":"number",
   "always_show":"true",
   "table":"incident",
   "filter":"active=true^u_start_date<=" + gdt +"^u_end_date>" + gdt,
   "display_field":"short_description",
   "maximum_entries":"5"
   };

 

testingniras
Tera Contributor

Thanks @Gustav Aldenbra , This was helpful.