Date Calculation on Report

msm4
Mega Guru

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.

 

9 REPLIES 9

Community Alums
Not applicable

Hello,

Did you get chance to look into solution provided by me. Please let me know if you need any help.

Voona Rohila
Kilo Patron
Kilo Patron

Hi msm

You can return list of sys_id's that match your filter from your script include.

Check below links on how to call script includes from the report, try and let us know if you're stuck

https://community.servicenow.com/community?id=community_question&sys_id=5ea4e608dbd978902dc24f781396...

https://community.servicenow.com/community?id=community_question&sys_id=68c940191bb37c90fc3233bc1d4b...


Mark it helpful if this helps you to understand. Accept solution if this give you the answer you're looking for
Kind Regards,
Rohila V
2022-25 ServiceNow Community MVP

Hello Rohila,

It is a date field as per my script it will return a specific date. 

Thanks!

Can you share the scriptinclude logic.

You should handle all the logic in scriptinclude and return list of sys_id's that match your filter.


Mark it helpful if this helps you to understand. Accept solution if this give you the answer you're looking for
Kind Regards,
Rohila V
2022-25 ServiceNow Community MVP

Here is the code:

  getLastweekstartdate: function() {

        var gd = new GlideDate().getDate();
        var lastWeek = gd.getDayOfWeek()+9;
        gw = new GlideDateTime(gd);
        gw.addDays(-(lastWeek));
       return gw;
    },