Date Calculation on Report
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-05-2022 03:08 AM
HI Team,
I have requirement, where I need to set a filter to check for a specific day from laskweek.
Example: I need to fetch records where the "week_starts_on" that specific day.
I have written the logic in a script Include and want to call that in report filter using "javascript: " , but I am not sure if it is possible.
Could you please suggest me how this can be achieved. Below is the screenshot where I want to call the script Include
Thanks.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-05-2022 03:22 AM
Hello,
The attached screen shot is broken, could you please attach it again.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-05-2022 03:41 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-05-2022 04:53 AM
Hello,
Could you please share script include code. If you are finding some records based on conditions you can return sys_id.
Suppose, if your condition is "created on last week" then it will show records created on last week.
Similarly you can apply this logic in script include and return sys_id of records in array and call this in filter condition "Sys id is one of script_include_name".
Regards,
Akshay
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-05-2022 06:04 AM
Hello,
Try below code in your script include -
in your report use this filter:
sys_id || Isoneof || javascript: new scriptincludename().functionname()
var gd = new GlideDate().getDate();
var lastWeek = gd.getDayOfWeek() + 9;
gw = new GlideDateTime(gd);
gw.addDays(-(lastWeek));
var arr = [];
var gr = new GlideRecord('your_table_name');
gr.addQuery("time_card.week_starts_on", "STARTSWITH", gw);
gr.query();
while (gr.next()) {
arr.push(gr.sys_id.toString());
}
return arr;
Please check and let me know if you have any queries.
Regards,
Akshay