hi @Meet Mewada !

I actually figured out why you don't see a return value. The reason is that UIB only able to handle primitives (like strings, booleans) in the return value and in your script you return date type objects. You can see in the comments my modification

function transform(input) {
    var month = 6; //Month number
    var gdtStart = new GlideDateTime();
    gdtStart.setDayOfMonth(1);
    gdtStart.setMonthLocalTime(month);
    var answer = [];
    var total_days = gdtStart.getDaysInMonth();
    var first_day_of_month = new GlideDateTime(gdtStart);
    var last_day_of_month = new GlideDateTime(gdtStart);
    last_day_of_month.addDays(total_days - 1);

    var start_date, end_date = '';
    for (var i = 0; i < total_days; i++) {

        if (gdtStart.equals(first_day_of_month))
            start_date = gdtStart.getDate();

        if (gdtStart.getDayOfWeek() == 7)
            start_date = gdtStart.getDate();
        if (gdtStart.getDayOfWeek() == 5)
            end_date = gdtStart.getDate();
        if (gdtStart.equals(last_day_of_month))
            end_date = gdtStart.getDate();
        if (start_date != '' && end_date != '') {
            answer.push({
                'start_date': start_date.toString(), //modified this line
                'end_date': end_date.toString() //and this
            });
            start_date = '';
            end_date = '';
        }
        gdtStart.addDays(1);
    }

    return answer;
}


Tested it on my environment. Can see the result here:
Screenshot 2025-07-15 at 15.03.22.png

if my solution helped you please mark it as helpful and accept the solution



Regards,
**Martin Virag**
ServiceNow MVP 2026

View solution in original post