Match values between variables/smartvalues
Asked by Mauricio Heberle:

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?


Answers:
author: Mauricio Heberle
body: [@Bill Sheboy](/t5/user/viewprofilepage/user-id/1685313) any chance you have faced something similar? Maybe I dont even need lookuptables for what i need. Thanks

comments: author: Bill Sheboy
body: Hi [@Mauricio Heberle](/t5/user/viewprofilepage/user-id/4973359)

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


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


author: Kian Stack Mumo Systems
body: [@Mauricio Heberle](/t5/user/viewprofilepage/user-id/4973359),   

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

comments: author: Mauricio Heberle
body: Sure, I'll try to be clearer.

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

![Captura de Tela 2023-07-28 a?s 16.12.09.png](https://community.atlassian.com/t5/image/serverpage/image-id/271897i3C94A60897D3EF13/image-size/large?v=v2&px=999 "Captura de Tela 2023-07-28 a?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 a?s 16.13.19.png](https://community.atlassian.com/t5/image/serverpage/image-id/271898i3C767F39CCCE73C1/image-size/large?v=v2&px=999 "Captura de Tela 2023-07-28 a?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 a?s 16.24.40.png](https://community.atlassian.com/t5/image/serverpage/image-id/271900iFA69D7514955AAD2/image-dimensions/422x315?v=v2 "Captura de Tela 2023-07-28 a?s 16.24.40.png")  

The lookup table grouping by the sys admin:  
![Captura de Tela 2023-07-28 a?s 16.14.27.png](https://community.atlassian.com/t5/image/serverpage/image-id/271901i8E1BCF0016F5C780/image-dimensions/457x251?v=v2 "Captura de Tela 2023-07-28 a?s 16.14.27.png")  

Turning it into string:

![Captura de Tela 2023-07-28 a?s 16.14.34.png](https://community.atlassian.com/t5/image/serverpage/image-id/271902i1D01F51065FBEE4A/image-dimensions/343x108?v=v2 "Captura de Tela 2023-07-28 a?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 a?s 16.14.42.png](https://community.atlassian.com/t5/image/serverpage/image-id/271903i2BCB8DA6BB7597FC/image-dimensions/409x125?v=v2 "Captura de Tela 2023-07-28 a?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


author: Kian Stack Mumo Systems
body: 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.


author: Mauricio Heberle
body: Hmm, that didnt work. Could you show me your rule, please?


author: Kian Stack Mumo Systems
body: I was just having it log to the audit log with some test variables.

Are you looping over each value in the empApp variable?


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


author: Kian Stack Mumo Systems
body: Have you tried to branch based on the values stored in empApps?


author: Mauricio Heberle
body: Yes, I did and no results. :/ I

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

it showed me only one result of two.