Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Retrieve data from Server script to Client controller in a widget

darianistor
Tera Contributor

I have this in server script and I want to use the details for the userholidaysArray in Client controller.

var userSchedule = new GlideRecord('schedule_holidays');
userSchedule.addQuery('schedule', schedule);
userSchedule.query();
var userholidaysArray = []; 
while (userSchedule.next()) {
    var startDateString = userSchedule.getValue('start_date');
    var endDateString = userSchedule.getValue('end_date);
    var holidayDetails = {
        name: userScheduleHolidays.getValue('name'),
        start_date: startDateString ,
        end_date: endDateString
    };
    userholidaysArray.push(holidayDetails); 
}
data.userSchedule = userholidaysArray; 
 
I tried with c.data.userSchedule in Client controller but it didn't work
1 REPLY 1

The Machine
Mega Sage

You need to put that in the Server script and then call it by using $scope.data.your-variable-name in the client controller. 

Good luck.