How to retrieve the role associated to a workitem?

45 views Asked by At

we are trying to generate a report to list an instance's log. We need to retrieve some attributes including the rol associate to the user who perform de action in the specific workitem.

Report required

The code right now is:

If &WorkFlowProcessInstanceId = 70  // Testing instance
            &WorkflowEventHistoryRepositories = &WorkFlowProcessInstance.Workitems
    Endif
    For &WorkflowEventHistoryRepository in &WorkflowEventHistoryRepositories
        &WorkflowEventHistoryId = &WorkflowEventHistoryRepository.ActivityId
        &WorkflowEventHistoryActivity = &WorkflowEventHistoryRepository.Activity.Name
        &WorkflowEventHistoryUser = &WorkflowEventHistoryRepository.Participant.Name
        &WorkflowEventHistoryCreated = &WorkflowEventHistoryRepository.Created
        &WorkflowEventHistoryEnded = &WorkflowEventHistoryRepository.Ended
        &WorkflowEventHistoryRole = ???
    Endfor

&WorkflowEventHistoryRepository: variable type WorkflowWorkitem

GXFlow Genexus 18 U8 Web .NET

1

There are 1 answers

1
Guido Lorenzatti On

Every &WorkflowEventHistoryRepository.Participant (Collection (WorkflowRole)) can have more than one role according to the documentation:

So, in order to obtain the participant Roles:

For &WorkflowEventHistoryRepository in &WorkflowEventHistoryRepositories
        &WorkflowEventHistoryId = &WorkflowEventHistoryRepository.ActivityId
        &WorkflowEventHistoryActivity = &WorkflowEventHistoryRepository.Activity.Name
        &WorkflowEventHistoryUser = &WorkflowEventHistoryRepository.Participant.Name
        &WorkflowEventHistoryCreated = &WorkflowEventHistoryRepository.Created
        &WorkflowEventHistoryEnded = &WorkflowEventHistoryRepository.Ended
        
        For &ParticipantRoles in &WorkflowEventHistoryRepository.Participant.Roles //&ParticipantRoles type:WorkflowRole - Collection:true
                // Do something with &ParticipantRoles.Id
                // Do something with &ParticipantRoles.Name
        EndFor
        // Do something with &ParticipantRoles

 Endfor

You can obtain more information about the WorkFlowRole datatype here.