How to reference user email from initiator variable?

81 views Asked by At

I'm trying to start one workflow from another. One of the things I would like to pass to the second workflow is the initiator of the first one.

However, when I try to log the value in the console like this:

def initiatorVarTest = {{initiator}}
loggerApi.info('Initiator: ' + initiatorVarTest)

I see the following in the console: Initiator: Script31$_run_closure3@6d9d597c

How can I extract the user email from the auto-generated initiator variable?

Originally I had this {{initiator}} line in the builder to start another workflow, but there I got the error that it's expecting a string and that this method cannot handle Script31$_run_closure3@6d9d597c.

1

There are 1 answers

0
Tijs Bijnens On

I used How to get all method names of a class without inherited methods with Groovy? to find out what methods this class has.

def methods = initiatorVarTest.getClass().declaredMethods.findAll {
    !it.synthetic && !it.getAnnotation(groovy.transform.Internal) 
}.name
loggerApi.info('Methods: ' + methods)

Which returned:

Methods: [doCall, doCall]

I then used:

def initiatorVarTest = {{initiator}}
def initiatorEmail = initiatorVarTest.doCall()

to get the initator email.