Create Capacity Records in Bulk

Each RH Capacity record covers one resource for one date range. When those date ranges are about to end, for example on December 31, every resource needs new capacity. Use the following scripts to create, change, or clean up capacity records for many resources at once, instead of editing each record by hand. Each script has its own page with its settings, the script, and how to read its results.

Choose a script

To do thisUse this script
Find resources with missing, overlapping, or multi-year capacity recordsCheck Capacity for Gaps and Overlaps
Give every resource the same weekly hours for one or more years, including resources with no capacityCreate Capacity with Standard Hours
Extend each resource’s current hours and role into the coming yearsCopy Each Resource’s Latest Capacity
Change one or more resources’ hours from a date onwardChange Capacity Hours from a Date
End capacity for resources who have leftEnd Capacity for Archived Resources
Break records that run several years into one record per yearSplit Multi-Year Capacity Records
Load different hours for each resource from a spreadsheetLoad from a CSV file

Both scripts that create capacity can make one record per month instead of one per year. Monthly records are easier to adjust for resources whose hours change from month to month, such as contractors.

If you’re not sure where your capacity stands, start with the check script. It changes nothing, and it lists the problems that the other scripts fix.

How far ahead to create capacity

For ongoing capacity without a known end date, create a separate RH Capacity record for each calendar year, and keep about three years in place at any time.

Avoid a single record that runs many years into the future. Resource Hero expands every RH Capacity record into one Resource Forecast record for each day in its date range that has hours, so a long record has two costs:

  • Data storage – A ten-year record adds up to roughly 5 to 7 MB of data storage for each resource, depending on how many days a week the resource works.
  • Processing time – Any later change to the record, such as the hours, the Start Date, or the End Date, reprocesses the entire date range.

With one record per calendar year, each record stays small, and a change to one year’s hours only reprocesses that year. To convert the long records you already have, use Split Multi-Year Capacity Records.

Before you run a script

Run each script in a sandbox first, then in production.

The user who runs a script needs the Resource Hero – Capacity Manager permission set.

Every script that changes data starts with DRY_RUN set to true. A dry run reports what the script would do without changing anything. Review the report, then set DRY_RUN to false and run the script again.

Every script also limits how much it does in one run, to stay inside Salesforce limits. When a run reaches the limit, its summary shows how many resources or records are still waiting. Run the script again until none are. Running a script again is safe: none of the scripts creates overlapping capacity, and each one skips work that’s already done.

If a run stops with a limit error, such as “Apex CPU time limit exceeded”, nothing from that run is saved. Lower the limit setting at the top of the script, then run it again.

Run a script

  1. Click the gear icon, then select Developer Console.
  2. Select Debug → Open Execute Anonymous Window.
  3. Paste the script and update the settings at the top. Leave DRY_RUN set to true.
  4. Select the Open Log checkbox, then click Execute.
  5. In the log, select the Debug Only checkbox and review the summary.
  6. Change DRY_RUN to false, then click Execute again.
  7. If the summary shows resources or records still waiting, click Execute again. Repeat until it shows 0.

After a script runs

New and changed RH Capacity records appear immediately. Resource Hero builds the daily Resource Forecast records behind each one, either during the run or in the background, which can take several minutes.

To confirm that processing is complete, check the Async Job Status field on the RH Capacity records. A blank value or a value of Completed means the record is done. The Total Capacity field updates a few moments later.

Note:

If your holiday hours come from resource capacity, a holiday on a date that no capacity record covers gets 0 hours. After you change capacity, run Check Capacity for Gaps and Overlaps to find any dates left uncovered.

Load from a CSV file

If each resource needs different hours, prepare the records in a spreadsheet and load them with the Data Import Wizard.

  1. Prepare a CSV file with columns: Resource, Start Date, End Date, Role, Sunday, Monday, Tuesday, Wednesday, Thursday, Friday, Saturday. Add one row for each resource for each calendar year, with the resource’s name in the Resource column and dates such as 2027-01-01. Enter 0 for a day with no hours. Role can be left blank.
  2. From Setup, enter Data Import Wizard in Quick Find, then select Data Import Wizard.
  3. Click Launch Wizard.
  4. In the “What kind of data are you importing?” section, select the Custom objects tab, then select RH Capacities from the list.
  5. In the “What do you want to do?” section, select Add new records, then select Resource Name from the Which Resource field in your file do you want to match against to set the Resource lookup field? picklist.
  6. In the “Where is your data located?” section, select CSV, choose your CSV file, then click Next.
  7. On the “Edit Field Mapping: RH Capacities” screen, confirm that every column is mapped, then click Next. A file with the column headers listed above is mapped automatically.
  8. On the “Review & Start Import” screen, click Start Import, then click OK to view the import status.

Related Support Posts:

Ready to get started?

Schedule a call to see if Resource Hero is right for you

Book now