Retrieve data from Server script to Client controller in a widget
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-20-2024 06:00 AM
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
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-20-2024 06:25 AM - edited 02-20-2024 06:25 AM
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.