- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
yesterday - last edited yesterday
I want to run "Update Resource Capacity" UI action from background script. I will be passing user id, start date as current date, end date as current date+18 months.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
yesterday
something like this
var userSysId = 'YOUR_USER_SYS_ID'; // Replace with actual user sys_id
var startDate = new GlideDateTime(); // Today
var endDate = new GlideDateTime();
endDate.addMonthsLocalTime(18);
var CapacityGenerationAPI = new CapacityGenerationAPI();
// Method 1: Update single user (recommended)
CapacityGenerationAPI.updateCapacityAndAvailabilityForUsers([userSysId], startDate, endDate);
gs.info('Resource capacity updated for user: ' + userSysId + ' from ' + startDate + ' to ' + endDate);
💡 If my response helped, please mark it as correct ✅ and close the thread 🔒— this helps future readers find the solution faster! 🙏
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
yesterday
@Ankur Bawiskar , When I click that UI action, It will ask for "start date" and "End date"
In my case, I want to input "Start Date" as Current date, "End Date" as Current Date + 18 months.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
yesterday
@DhathriC
then you need to check how that UI page calls the backend script include and how it passes those 2 dates
I already shared the details above what to deep dive.
💡 If my response helped, please mark it as correct ✅ and close the thread 🔒— this helps future readers find the solution faster! 🙏
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
