Description: Sets the duration of a reason at a specified index. Index -1 selects the last reason; NULL duration is converted to 0. Optional target arguments allow editing another record.
Calling convention: SetReasonDurationByIndex("ContainerName": String, ReasonIndexInContainer: Integer, DurationToSet: Integer, ["TargetObjectName": String], [TargetDataID: Integer]): Boolean
Parameters:
ContainerName: reason-container entry name.
ReasonIndexInContainer: zero-based reason index, or -1 for the last reason; values below -1 are invalid and return False.
DurationToSet: duration value; NULL becomes 0.
TargetObjectName: optional external object name.
TargetDataID: optional external DATA_ID; both target arguments must be supplied together and neither may be NULL.
Returns: True when the reason is updated; False for a NULL container/index or an out-of-range index. Invalid target data can raise an error.
Availability: Default; requires a current record unless TargetObjectName and TargetDataID are supplied.
Example:
SetReasonDurationByIndex("DowntimeReasons", -1, 3600);