The CreatorCon Call for Content is officially open! Get started here.

Script include always returning false

samadam
Kilo Sage
chkDates: function() {
 // check change task planned dates are within the parent change request planned dates
    var chgStartDate = this.getParameter('sysparm_start');
    var chgEndDate = this.getParameter('sysparm_end');
    var changeStartDate = new GlideDateTime(chgStartDate);
    var changeEndDate = new GlideDateTime(chgEndDate);
   
    var chg_id = this.getParameter('sysparm_chg');
    var task = new GlideRecord('change_task');
    task.addQuery('change_request', chg_id);
    task.addQuery('change_task_type', 'IN', 'implementation,planning');
    task.query();
    while (task.next()) {
        var sDate = task.planned_start_date.getDisplayValue();
        var eDate = task.planned_end_date.getDisplayValue();
        var startDate = new GlideDateTime(sDate);
        var endDate = new GlideDateTime(eDate);
        if (startDate < changeStartDate || startDate > changeEndDate ||
            endDate < changeStartDate || endtDate > changeEndDate) {
                return false;
            }
    }
 
This is always returning false even though I have the dates in the range. Any idea?
1 ACCEPTED SOLUTION

samadam
Kilo Sage

Able to resolve the issue, change dates are not coming over correctly changed to get value and it worked.

View solution in original post

4 REPLIES 4

jonsan09
Giga Sage
Giga Sage

There is a typo in variable name on the 4th to last line: 
" endDate < changeStartDate || endtDate > changeEndDate) {"

samadam
Kilo Sage

Thank you, I fixed that. Still have the same issue

Brad Bowman
Kilo Patron
Kilo Patron

I don't see a line where you are returning anything except false.  As with any script troubleshooting, add some gs.info lines to see the values of script variables, and confirm the if condition is evaluating to true, then you should see where the issue lies. 

samadam
Kilo Sage

Able to resolve the issue, change dates are not coming over correctly changed to get value and it worked.