Forums

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

How to copy a date field into a string field during automation?

Mya.Hauck
Contributor
November 10, 2021

I am trying to copy a date field value into a string field in automation. I was thinking I'd have the best luck using smart values.

 

customfield_10273 is a date field and customfield_10289 is a string field. I am trying to copy the date in 10273 into 10289 as a string.

 

I have tried:

{{issue.customfield_10273.value}}

 

{{issue.customfield_10273}}

 

{
"fields": {
"customfield_10289" : { "value": "{{issue.customfield_10273.value.asJsonString}}" }
}
}

 

Does anyone have any experience or suggestions for this?

 

advanced.PNGnormal.PNG

 

1 answer

1 accepted

1 vote
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.
November 10, 2021

Hi @Mya.Hauck 

Would you please post an image of your rule as that will give the community context to offer ideas?  Thanks!

If you are setting the text field with the date, you may want to use one of the date format functions to get the exact format you want: https://support.atlassian.com/jira-software-cloud/docs/smart-values-date-and-time-functions/

Kind regards,
Bill

Mya.Hauck
Contributor
November 10, 2021

Thanks @Bill Sheboy 

I updated the question.

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.
November 10, 2021

Two suggestions to try: 

  • Please write those values from your edits to the audit log to see if they have what you expect.
  • Try doing both of the edits in one action (selecting each field separately).  That may prevent walking on changes...if that is a possibility for automation rules.

Thanks!

Mya.Hauck
Contributor
November 10, 2021

So the screenshots here were just to show you all of the different ways I've tried to edit this field (advanced JSON and the normal "Edit Issue" action). 

 

I have been testing all of these scenarios individually, never together so there's no overwriting going on. 

 

This is the error I get when I try to edit the field with advanced editing: "RN-18 (Operation value must be a string (customfield_10289))"advanced error.PNG

 

And what it looks like when I try it with the normal "edit issue" action. Here it says success, but nothing is actually getting added to the field:

normal log.PNG

 

Again, I believe this is all happening because a date and a string are different types, and I need to figure out the syntax to translate the date into a string (if there is any).

Mya.Hauck
Contributor
November 10, 2021

Release Note Version is the same as customfield_10289

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.
November 10, 2021

Rather than performing the edit, if you just write the value to the audit log what does it show?  Trying that may reveal what is happening with the type.

Mya.Hauck
Contributor
November 10, 2021

Update: I was trying to do this with a hidden field (a field not on the screen)- turns out you can't do that. I got it working using the normal "Edit issue" action with "{{issue.customfield_10273.mediumDate}}" and put the field on the screen

Like Bill Sheboy likes this
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.
November 10, 2021

I am glad you got this to work, and puzzled as that is a new symptom for that problem.  Often that cause shows up as either a permission or unknown field error in the automation log.  Quite curious.

Suggest an answer

Log in or Sign up to answer