Invalid Function definition Error in logs
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-10-2022 04:07 AM - edited 11-10-2022 07:21 AM
Hi All,
I am using below script in scheduled reports to check the month, but the script is not working
It shows invalid function def in logs
function checkMonths(){
var a = false;
var triggerMonths = [1,3,5,7,9,11];
var currentDate = new Date();
var currentMonth = currentDate.getMonth();
for (i in triggerMonths){
if ( currentMonth == triggerMonths[i])
a=true;
}
return a;
}
checkMonths();
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-10-2022 05:00 AM - edited 11-10-2022 05:01 AM
Can you try below code:
checkMonths();
function checkMonths() {
var triggerMonths = [1,3,5,7,9,11];
var currentDate = new Date();
var currentMonth = currentDate.getMonth();
for (i in triggerMonths){
if ( currentMonth == triggerMonths[i])
return true;
}
return false;
}
Thanks
Anubhav Ritolia
ServiceNow Rising Star 2023
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-10-2022 05:04 AM
Hi Anubhav, thanks for your reply
This script is similar right ? it gives the same result
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-10-2022 05:05 AM
Yes but I guess you need to call function first and than declare function. Have you tried it? Is it giving same error log?
Thanks
Anubhav Ritolia
ServiceNow Rising Star 2023
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-10-2022 05:06 AM
Yes, it gives the same result