Addition of Task fails with Return code 20766 when using Script Functions, MODIFY_TASK and ADD_TASKS and adding the same Task multiple times

Document ID : KB000087728
Last Modified Date : 14/04/2018
Show Technical Document Details
Issue:
Error Message :
U0020408 U0020766 MODIFY_TASK with opcode ' ' not possible for task ' ' (Lnr ' '). The task has not been added with ADD_TASK or the changes have already been activated.

When using script functions to add the same Task multiple times using the MODIFY_TASK and ADD_TASK functions, it fails to add the task with a return code of 20766 as shown above.  If you run the script again the Task is added.
 
If there is more than one task with the same name within a Workflow, a MODIFY_TASK command has to be used with an LNR, which is returned by ADD_TASK

In this case, instead of just using the Task Names you must to use the Task Number as well to avoid the error.
 
Example:

Following is an exampe of a working MODIFY_TASK which adds with ADD_TASK multiple times using the same Task but with different Names (ALIAS):
:SET &RET# = MODIFY_TASK(&RUNID#, STOP_MODIFY)
:SET &LNR# = MODIFY_TASK(&RUNID#, "&V_BACKUP_RESTORE#",,ADD_TASK)
:SET &RET# = MODIFY_TASK(&RUNID#, "&V_BACKUP_RESTORE#",&LNR#, MOVE_TASK, "&COLUMN#", "&ROW#")
:SET &RET# = MODIFY_TASK(&RUNID#, "&V_BACKUP_RESTORE#",&LNR#,ALIAS,"&ALIAS#")
:SET &RETCOMMIT# = MODIFY_TASK(&RUNID#, COMMIT)

Reference
Cause:
Cause type:
Configuration
Root Cause: If there is more than one task with the same name within the workflow a MODIFY_TASK command has to be used with an LNR which is returned by ADD_TASK.
So instead of just using the Task Names you have to use the Task Number as well.
Resolution:
N / A

Fix Status: No Fix

Fix Version(s):
N/A
Additional Information:
Workaround :
N / A