79082368

Date: 2024-10-13 03:58:56
Score: 0.5
Natty:
Report link

I believe your out-of-bounds error occurs because the position is beyond the index of tasks within your phase. This script works to assign value "bar" to text variable "foo" if your custom task is at the top of the phase, with index = 0. You just need to know or compute a valid position.

def addTaskToChangeVariable(varname, value):
    scriptTask = taskApi.newTask("xlrelease.ScriptTask")
    print("The task is {} ".format(scriptTask))
    scriptTask.script = "releaseVariables['{}'] = '{}'".format(varname, value)
    scriptTask.title = "{} ".format(varname)
    scriptTask = phaseApi.addTask(task.container.id, scriptTask, position)
    # taskApi.lockTask(scriptTask.id)

position = 1
addTaskToChangeVariable("foo", "bar")
Reasons:
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Unregistered user (0.5):
  • Low reputation (1):
Posted by: Dave