Match values between variables/smartvalues

Mauricio Heberle
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 27, 2023

Scenario:
We have an Asset object called "Employees", which has among other attributes, one called "Apps list" that stores all applications an user has access to.

Theres another object called Systems which contains all systems and their Sys Admins.

When someone leaves the company, I want to create an automation that creates tasks for the Sys Admins, but only for the apps the user has access.

Ex: John has access to App A and App B, one task for each system and for each sys admin if different.

Within the issue, I have an Asset field with the "Employees" object. From this field, I can find the apps listed in the Employees attribute using the smart value: 

{{issue.Employees.App List}} or {{issue.Employees.App List.Name}}

I can do what I want creating tons of "ifs", but I want to make something better. I tried to store the smart value {{issue.Employees.App List}} in a var called {{empApps}}. It works.

Then, I created a lookup table and set App Names grouping by sys admin and that the user in the issue contain it. After that, I created another var to transform the lookup table into string.

The problem is that when I try to do something like: {{tableStr.match("({{empApp}})")}} it just doesnt work. Any thoughts on this?

2 answers

0 votes
Mauricio Heberle
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
October 10, 2023

@Bill Sheboy any chance you have faced something similar? Maybe I dont even need lookuptables for what i need. Thanks

Bill Sheboy
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
October 10, 2023

Hi @Mauricio Heberle 

To use a dynamic regular expression with match, such as based on smart values, you need to first store the expression in a created variable.

For an example from the last paragraph in your original question...I am assuming that your tableStr is a comma-separated values list.  If not, you may want to investigate the improvements to Lookup Tables to learn what might help: https://community.atlassian.com/t5/Automation-articles/Update-Create-lookup-table-action-improvements/ba-p/2427798

  • action: create variable
    • name: varMyRegularExpression
    • value: .*({{empApp}}).*
  • action: something to use the match result
    • {{tableStr.split(",").match(varMyRegularExpression)}}

 

Kind regards,
Bill

Mauricio Heberle
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
October 10, 2023

I did find a solution, but couldnt use the lookuptable to list my assets. Thank you anyways!!

0 votes
Kian Stack Mumo Systems
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
July 28, 2023

@Mauricio Heberle

This sounds like a really interesting use case, but I'm not quite sure I understand what you are trying to do with 100% clarity. Would you be able to explain exactly which tasks you want created and based on what criteria? 

Thanks,

Kian

Mauricio Heberle
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 28, 2023

Sure, I'll try to be clearer.

 

Issue containing Asset field object (my own user for testing):

Captura de Tela 2023-07-28 às 16.12.09.png

This is the Employee object. I can extract the value from the obj attribute with {{issue.Employees.System Name}}:

Captura de Tela 2023-07-28 às 16.13.19.png

Now, lets say someone is the Sys Admin for Jira Software, Figma and OpsGenie. My user has access for Jira Software and Figma, but not OpsGenie. When the IT Offboarding is created, I want to create subtasks for the SysAdmin of those apps, but only for Jira Software and Figma, because those are the ones my user has access.

Eg: Task 1: Remove Access to Figma. Task 2 Remove Access to Jira Software. It doesnt matter if linked or child issue. Example:

Captura de Tela 2023-07-28 às 16.24.40.png

The lookup table grouping by the sys admin:
Captura de Tela 2023-07-28 às 16.14.27.png

Turning it into string:

Captura de Tela 2023-07-28 às 16.14.34.png

I can manipulate this data using match, but what I really want is to compare with the smart value var. This var works, I logged action this and got the right result

Captura de Tela 2023-07-28 às 16.14.42.png

The idea here is to create a branch with the {{tableStr.match("({{empApp}})")}} to create an issue for each system. I know its a bit long explanation, but hopefully I made myself clear haha

Kian Stack Mumo Systems
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
July 28, 2023

So I found that I can't get the "match" function to work, but I did find that I could do this: 

 

{{tableStr.substringAfter(empApp).subStringAfter("=").subStringBefore(",")}}

 

Where EmpApp is each individual app the user has.

Mauricio Heberle
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 30, 2023

Hmm, that didnt work. Could you show me your rule, please?

Kian Stack Mumo Systems
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
July 31, 2023

I was just having it log to the audit log with some test variables.

 

Are you looping over each value in the empApp variable?

Mauricio Heberle
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 31, 2023

I just added the smartvalue you sent to the audit log and no results appeared :(

Kian Stack Mumo Systems
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
July 31, 2023

Have you tried to branch based on the values stored in empApps?

Mauricio Heberle
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
August 3, 2023

Yes, I did and no results. :/ I 

 

When I changed to  {{tableStr.substringBefore(empApp).subStringAfter("=").subStringBefore(",")}}

it showed me only one result of two.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events