This article describes how to delegate a workitem using the Workflow API. Take into account that when you delegate a task using the API, constraints are not checked. So it doesn't matter whether you set the task the properties as Allow delegation, Delegation mode or Maximum length of delegation.
To do this, execute the following code:
&WorkflowOrganizationalModel=&WorkflowServer.GetOrganizationalModel()
&WorkflowUser = &WorkflowOrganizationalModel.GetUserByName(&userName)
&WorkflowWorkitem.Delegate(&WorkflowUser)
commit
Where the data types variables are:
&WorkflowServer – WorkflowServer
&WorkflowOrganizationalModel – WorkflowOrganizationalModel
&WorkflowUser – WorkflowUser
&userName – WorkflowName
&WorkflowWorkitem – WorkflowWorkitem