How update description from smart value ?

Alex
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 23, 2023

Hello Atlassian Community!
I would like to know how you can update the Cf values ​​in the “description” field without losing the task description itself inside?
I've looked at the intellectual value, but I don't fully understand how to use it.

I have:
1. Automation .Issue created . Where field "CPU" copying the field to the description

and


2. Automation. Field changed(doesn't work well)


Your help is greatly needed!
I am attaching screenshots

CLE.png



triggerCreate.pngchange.png

Thanks!

4 answers

1 accepted

2 votes
Answer accepted
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 23, 2023

Hi @Alex 

First thing: why is this field stored in the Description field and in the CPU field?  Understanding the problem you are trying to solve may help the community offer other solution approaches.

Back to your question...

You appear to be re-storing the value of your CPU field in the Description, and storing multiple pieces of information in the Description field.  That causes challenges as you have changed the "meaning" of the description field and Jira has no logic to handle that meaning.

To do what you ask, your rule needs help by having something to indicate what to change in the Description.  A couple of ways to do this are:

  • Have a fixed structure to your Description field.  You may then use text functions to change the value at the specific location in the field.
  • A better still, have an indicator in the field, such as a prefix CPU:, to indicate the value's location.  That will make replacing it easier using the replaceAll() function with a regular expression.

Kind regards,
Bill

Alex
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 23, 2023

@Bill Sheboy Hi!

1.For developers, you need to add these field values ​​to the description. They said that it was very important for them that it be this way. For some kind of subsequent work..

I understood your message, but I can’t imagine how to implement this in jira.. Maybe there is documentation on a similar issue? Thank you

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 23, 2023

You appear to be using Jira Server, correct?  Here is the documentation on the text functions for automation rules: https://confluence.atlassian.com/automation/jira-smart-values-text-fields-993924863.html

Those include many helpful functions, to do the following...

As @Tom Lister and I described, you could have a format of your description, that your team uses when creating issues, that makes it easier to find / replace the value.

Let's assume your create an issue, with the description in this format where the first line with the CPU ends in a semicolon.

CPU: 4;
here is some description information

Now when your rule is triggered and you perform the edit, you can use the substringAfter() function to substitute in the correct value.

CPU: {{issue.customfield_23836}};
{{issue.description.substringAfter(";")}}

You and your team can decide on the format.  If you need something more flexible, work with the team to use the replaceAll() function with a regular expression to perform the replacement.

Like Tom Lister likes this
Alex
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 23, 2023

@Bill Sheboy , yes , I use jira-server. Thank you , I'll try to implement this and write the result. Thank you !

Like Bill Sheboy likes this
Alex
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 24, 2023

@Bill Sheboy Hi!

I tried adding these smart values and in the description, the cpu value has now begun to be updated -  it works well.

But the rest of the “description” (additional information for the task) still clears the value..

Maybe I need to add something?

Thank you

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 24, 2023

Please post images / examples of:

  1. Text initially entered to create the issue  (i.e., what was typed in)
  2. Your current complete rule, the edit action details, and the audit log showing the rule execution
  3. The issue description after the rule has executed

Together those will provide context to help explain this symptom.  Thanks!

Alex
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 24, 2023

@Bill Sheboy  Hi!I tried to cover everything and not miss anything.

Another problem is that I need to update three values ​​at once: (i.e. so that it looks like this in the description)


cpu: 2 :cpu

ram: 2 :ram

disk size: 50 :disk size

screen create:


screencreate_subt.png

twoscr_creat_sub.png

 

screen 1.automation (create)

autm_creat.png

screen 1.automation (create)Auditlog

log_aut_creat.png

 

 

screen 2.automation (update)

autom_updt.png

screen 2.automation (update)Auditlog

log_udat.png

 

screen before create:

 

view_screen_subt.png

Alex
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 24, 2023

@Bill Sheboy 

Expected Result :

the value is updated when any of the three fields (cpu, ram, disk size) changes, the main description is NOT overwritten 

ozhidaemuy_result.png

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 24, 2023

To make automation like this work, the format entered for the Description field must be consistent and predictable.

Earlier you described having existing values in the Description, such as the CPU followed by some text.  And so I suggested using a semicolon as a delimiter.  However your example does not show that.  Instead your Description is just text, with no existing values.  Or, it contains multiple values other than the Description.

What do you expect people to enter in the Description field when creating an issue? 

As the developers on your team have asked for this, please confirm what they need and why they need it.  (Aside: IMHO, if a person in a "developer role" is asking for this, when the data already exists in other Jira issue fields, you may want to assess their other working methods and results for challenges.)

Once you have defined that consistent and predictable format, I recommend:

  1. create test cases for all possible formats
  2. show those test cases to the requestors (your developers) to validate them
  3. create a spreadsheet with example issues for each possible format / test case, including the relevant issue fields
  4. create a test Jira project to validate your rule
  5. adjust your rule to handle the test cases
  6. test your rule by importing issues into the project from the spreadsheet
  7. repeat steps 5-6 until the rule works and the tests pass
  8. copy the rule to your desired Jira project
  9. test manually to validate the rule works as expected
  10. if the format changes in the future, repeat all of these steps
Alex
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 24, 2023

@Bill Sheboy Thank you!

The structure will always be like this (on the edit/view screen):

 cpu: 2 :cpu

ram: 2 :ram

disk size: 50 :disk size

 

any text after

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 24, 2023

Great!  Now you have a template to create your 16 test cases (assuming the numbers have values) or 128 (assuming the numbers are empty or filled).  I recommend pausing to create those before updating your rule.

As long as those "numeric tokens" are not used the "any text after", you could use the replaceAll() function I noted earlier, such as:

cpu: {{issue.yourCpuField}} :cpu
ram: {{issue.yourRamField}} :ram
disk size: {{issue.yourDiskSizeField}} :disk size
{{issue.description.replaceAll("(cpu:.*:cpu)","").replaceAll("(ram:.*:ram)","").replaceAll("(disk size:.*:disk size)","")}}
Like Alex likes this
Alex
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 24, 2023

@Bill Sheboy Thank you . I'll write here after I add this expression to my automation

Alex
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 25, 2023

@Bill Sheboy Hi!

I added your expression to my automation and it works perfect! Thank you very much for your help! :)

Best wishes, Alex!

Like Bill Sheboy likes this
1 vote
Vishal
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 23, 2023

Hi @Alex 

I think you need to copy the value of Description into another custom field before updating it, lets call it Previous Description. Then update the description field with the two smart values as you are doing. You may also hide this Previous Description field from your view screen so that it'll not be visible to anyone.

So, now the description should look like {{cpu}} {{Previous Description}}

Give a try, it should work.

Alex
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 23, 2023

@Vishal Hello ! Thanks, I'll try to do this and write the result

1 vote
Tom Lister
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
October 23, 2023

Hi @Alex 

I can see you are cumlatively adding values to the description on each pass.

If you put you value between some markers you can process, e.g. [ ] , you can use combination of the string handling functions to remove the data between markers and add a new value.

Alex
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 23, 2023

@Tom Lister  Hi!

I can ask you to show an example of how this can be done? I'm completely new to this. Thank you

0 votes
Aein Bagheri
Banned
November 15, 2023

Suggest an answer

Log in or Sign up to answer