If the user needs to close the work orders using the script, use the following function,
let completionRecord = record.transform({
fromType: record.Type.WORK_ORDER,
fromId: workorderID,
toType: record.Type.WORK_ORDER_CLOSE,
isDynamic: true,
}).save();