KBEC-00230 - Recovering the user that authorized a state transition

Description

It would be convenient if the name of the person who initiated a manual transition were readily available.

Solution

The name is available from the Commander Workflow Log. In the UI, clicking on the "View Log" link on the top right corner of the workflow section. Navigate to the transition in question and the name of the user you initiated the manual transition is available.

Given a state name and a workflow name, the below Perl script retrieves the user that authorized a state transition.


use strict;
use ElectricCommander;
$| = 1;
 
my $state = "state1_transition";
my $workflowName = "workflow_44_201206291819";
 
my $ec = new ElectricCommander();
my $xPath = $ec->findObjects("logEntry", {
    filter => {  propertyName => "containerName" ,
                operator => "equals" ,
                operand1 => "$workflowName" }
    });
 
my $countOfLastTransition = $xPath->findnodes_as_string("count(//logEntry[subjectName = '$state'])");
#print "$countOfLastTransition" . "\n";
 
my $principal = $xPath->findnodes("(//logEntry[subjectName = '$state']/principal)[$countOfLastTransition]")->string_value();
my $time = $xPath->findnodes("(//logEntry[subjectName = '$state']/time)[$countOfLastTransition]")->string_value();
 
print "Most recent transition of \"$state\" was taken at $time, by user \"$principal\"" . "\n";


Note

The following post also talks about this.

https://ask.electric-cloud.com/questions/1873/who-kicked-off-a-manual-transition-on-a-workflow.html

Have more questions? Submit a request

Comments

Powered by Zendesk