JMWE Automated Approval based on User Entity Property

Matus Klaudiny [EXT] June 17, 2021

Hello,

I'm builiding an automated approval process based on user properties that i have fed into the JWME user properties via API. Currently having problem with finding the right syntax to extract accountId from email. Row in the editor looks like this: 
 

manager{"email":"xyz@zzz.com"}

 

Current script looks like this: 

{{ issue.fields.reporter | userProperty ( "manager" ) | dump | replace('{"email":"', "") | replace('"}', "") }}

I am replacing and trimming my string to have only email value at the end, but i am struggling to find a method how to convert that email into the user object and its accountId. Is there anyone that could potentially help me with this?

 

1 answer

0 votes
David Fischer
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
June 17, 2021

Hi @Matus Klaudiny [EXT] 

This is how you can extract the email:

{%set email = issue.fields.reporter | userProperty ( "manager" ) | field("email") %}

And to get the user that has that email:

{%set user = email | findUsers | first %}

Finally, to return the accountId (for use in a Set Field Value post function for example):

{{ user.accountId }}

The whole thing in one go:

{{ issue.fields.reporter | userProperty ( "manager" ) | field("email") | findUsers | first | field("accountId") }}
Matus Klaudiny [EXT] June 18, 2021

Thank you David! 

Suggest an answer

Log in or Sign up to answer