Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Is it possible to use a lookup table and smart values in a "replace" Automation rule?

Bill Ewald
Contributor
April 11, 2024

Scenario:  Each month we clone one particular Story so we do not have to manually create 30 Sub-Tasks.  We wish to condense our rule so we do not have to open each component, make the Month or Date Change, then save and edit the next component.  We have 7 components.  

Examples of Components:  After cloning the Story all the Sub-Tasks have the word "Clone - " added to the beginning of the summary field.  We use the following "Then: Edit issue fields" to remove "Clone - " - {{issue.summary.substringAfter("- ")}}.  This saves us from opening 30 Sub-Tasks and editing each summary.

15 Components have the Month present in the summary.  We use the following to find the old month and update with the current month:  {{issue.summary.replace("March", "April")}}

The remaining 15 Components have various dates that need to be replaced.  The following is one example:  {{issue.summary.replace("3/12/24", "4/15/24")}}

Each month the JQL is updated so that our rule only makes changes to the one Story in the project: project = ProjTest AND Parent = Story-1001 AND issuetype = Sub-task  order by created DESC

 

Question 1.  Is it possible to use a Lookup Table at the beginning of our rule so we only have to update that one component and not have to open and edit the other 7?  So far our attempts have failed.  Key = PriorMonth, Value = March.  Key = ThisMonth, Value = April.  Edit issue:  {{issue.summary.replace({{TEST.get("PriorMonth")}},{{TEST.get("ThisMonth")}})}}

Question 2.  If question #1 is possible can we adjust the Lookup Table Values with Smart Values?  March would = {{now.minusMonth(1)}} AND April would = {{{{now.Month}}}}.  This would eliminate the need to make this change each month.

1 answer

1 accepted

0 votes
Answer accepted
Kalyan Sattaluri
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.
April 11, 2024

Hello @Bill Ewald 

If I understand the ask correctly, every month you want to clone a story along with sub-tasks, once cloned you want to edit the fields in cloned issue to reflect either current month or current date? Can you clarify this?

Now, Month part is easy and I dont think you need lookup there.. Dates part need clarification.

You can use lookupTable for Dates, but is it truly needed?

Can you share what do these dates look like, as in, is there a logic? Third wednesday of each month? Monday of second week? or is it just random dates each month?

Also, So far you have mentioned that Summary has date in it for each month. What other fields have dates you need to update and what are those values? Are they the same values as what Summary will have or is it different. If different, whats their logic..

Share some details of various dates each month for different fields so community can suggest the cleanest approach, instead of brute force handling complete list in lookup. 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.
April 11, 2024

Hi @Bill Ewald 

Yes, and to @Kalyan Sattaluri suggestions...

The date's month could be found with the format("MMMM") function, such as:

  • prior month: {{now.minusMonths(1).format("MMMM")}}
  • current month: {{now.format("MMMM")}}

Although from what you described, there seems to be quite a bit more happening to determine and select the correct issues.  Clarifying the scenario and seeing your current rule will help.

Kind regards,
Bill

Bill Ewald
Contributor
April 11, 2024

You are correct.  The days (date) of the month is changing each month.  I believe I will be able to make that work once I can get the Month and one day (date) to work.  Bill - I have read your articles on this subject.  My syntax is incorrect.  Do you suggest using a Lookup Table?  If yes, how would the Key and Value be written for the Month change?

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.
April 11, 2024

If you only need the prior month and current month, as your original question asked, you may either use those values I noted in the replace() function, or with the lookup table as you tried.

The mistake in what you showed is the extra curly brackets: once inside a set of brackets, no more are needed for this situation.

{{issue.summary.replace(TEST.get("PriorMonth"),TEST.get("ThisMonth"))}}

 

Bill Ewald
Contributor
April 11, 2024

Thank you!  I will give it a try and respond tonight or in the morning.

 

Bill Ewald
Contributor
April 11, 2024

This worked!  

Used lookup table

{{issue.summary.replace(TEST.get("PriorMonth"),TEST.get("ThisMonth"))}}

April - 03/20/2024
Reverted my changes back to March - 03/20/2024
I was then able to change the day (date) using lookup table.

March - 04/20/2024

Reverted my changes back to March - 03/20/2024
I could not change both Month and Day (date) using the same rule using two components of "And: Edit issue fields".

 

Thank you both for your help!

 

Like Bill Sheboy likes this

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
PREMIUM
PERMISSIONS LEVEL
Product Admin
TAGS
AUG Leaders

Atlassian Community Events