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. Therefore, it doesn't matter whether you set the task's properties to 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 as follows:
&WorkflowServer – WorkflowServer
&WorkflowOrganizationalModel – WorkflowOrganizationalModel
&WorkflowUser – WorkflowUser
&userName – WorkflowName
&WorkflowWorkitem – WorkflowWorkitem