Table of contents


Official Content

This article is useful if you need to assign/unassign a user role using Workflow API.

To do this, you can define and execute the following code in a Web Panel object.

Event Start
    &WorkflowServer.Connect(&UserName, &UserPassword)
Endevent

Event 'AssignRole'
    &WorkflowOrganizationalModel = &WorkflowServer.GetOrganizationalModel()
    &WorkflowUser = &WorkflowOrganizationalModel.GetUserByName(&UserName)
    &WorkflowRole = &WorkflowOrganizationalModel.GetRoleByName(&RoleName)
    &WorkflowUser.AssignRole(&WorkflowRole)
    commit
    return
Endevent

Event 'UnassignRole'
    &WorkflowOrganizationalModel = &WorkflowServer.GetOrganizationalModel()
    &WorkflowUser = &WorkflowOrganizationalModel.GetUserByName(&UserName)
    &WorkflowRole = &WorkflowOrganizationalModel.GetRoleByName(&RoleName)
    &WorkflowUser.UnassignRole(&WorkflowRole)
    commit
    return
Endevent

Where the data types variables are the following:

&WorkflowServer – WorkflowServer
&WorkflowOrganizationalModel – WorkflowOrganizationalModel
&WorkflowUser – WorkflowUser
&WorkflowRole – WorkflowRole
&UserName – Character(100)
&UserPassword – Character(30)
&RoleName – Character(100)

For further information about the Workflow API, go to API.

Last update: April 2024 | © GeneXus. All rights reserved. GeneXus Powered by Globant