Automation to Sync Dates Between an Initiative in JIRA Software and an Idea in JIRA Product Delivery
Asked by Mike Gargano:

I've been working to setup JIRA Product Discovery for my group, and everything has been great thus far.

We use initiative tickets as parents to epic tickets, and we're using JIRA Product Discovery in our Product Team for Roadmapping, Prioritization, and Discovery.

I have setup a handful of automations that keep our initiative tickets that are linked delivery tickets in-sync with their idea counterpart.

However, I can not figure out how to get a date field to stay in-sync. I believe it has something to do with how dates are stored in JPD.

I tried using a custom JSON, because I couldn't target the date field in the simple automation UI.

```
{
"update": {
"customfield_10772" : { 
"set" : {
"{{triggerissue.customfield_10742}}"
}
}
}
}
```

This should work but I get an error:

Error while parsing additional fields. Not valid JSON.  
I believe this is because the field is returning the following based on some logging I setup :

```
{"start":"2023-01-28","end":"2023-01-28"}
```

I'm honestly not sure to go from here because I can't figure out how to get the field to format correctly to be accepted by a custom date picker in JIRA Software and vice versa with a field coming from JIRA Software going into Jira Product Discovery

I'm trying to get the date fields to sync for better roadmapping and preventing our PMs from having to do double the work between JIRA Software and JIRA Product Discovery.   

![Screenshot 2022-12-08 at 12.05.59 PM.png](https://community.atlassian.com/t5/image/serverpage/image-id/229679i4232945FC0E29D56/image-size/large?v=v2&px=999 "Screenshot 2022-12-08 at 12.05.59 PM.png")![Screenshot 2022-12-08 at 12.06.15 PM.png](https://community.atlassian.com/t5/image/serverpage/image-id/229680i291BCBFBAFEC0624/image-size/large?v=v2&px=999 "Screenshot 2022-12-08 at 12.06.15 PM.png")


Answers:
author: Tanguy Crusson
body: [@Mike Gargano](/t5/user/viewprofilepage/user-id/5068376) I've asked an engineer on the team to give more details about the format the field excepts.

comments: author: Mike Gargano
body: Awesome, thank you [@Tanguy Crusson](/t5/user/viewprofilepage/user-id/502312) !


author: Martin Sturm
body: Hello [@Mike Gargano](/t5/user/viewprofilepage/user-id/5068376) , the date field in JPD accepts a JSON string with the start and end property being ISO 8601 date strings.

This is because JPD dates are conceptually intervals as we allow for example values like "Q3 2023" or "Feb 2024".


author: Mike Gargano
body: Hey [@Martin Sturm](/t5/user/viewprofilepage/user-id/216097) , I appreciate you taking the time to respond.

So how would I parse that in JSON coming in from JIRA Software? or going from JIRA Product Discovery to JIRA Software which is setup differently.

I don't think I've ever run into anything like this, I'm not sure how to write the JSON for this, and I couldn't find anything using my google-fu.


author: Martin Sturm
body: Hello [@Mike Gargano](/t5/user/viewprofilepage/user-id/5068376) , unfortunately I am not very versed when it comes to A4J - what exactly are you getting from JSW?

If it's a string in YYYY-MM-DD (or you can convert it into such a string) would you be able to create a JSON string like this?

```
{
 start: $dateString,
 end: $dateString,
}
```

Then you could set the field with this string and it would show up in JPD correctly as a "date with day granularity".


author: Mike Gargano
body: Hey [@Martin Sturm](/t5/user/viewprofilepage/user-id/216097) , thank you for your response, I apologize for my delayed reply, I got kinda busy towards the end of the year. I will give this a try and report back with how it goes!


author: Mike Gargano
body: Hey [@Martin Sturm](/t5/user/viewprofilepage/user-id/216097)   

I tried this:

```
{
"update": {
"customfield_10742": { 
"set" : start: {{triggerIssue.customfield_10772}},
end: {{triggerIssue.customfield_10772}},
}
}
}
```

And I'm still getting an error "Error while parsing additional fields. Not valid JSON."


author: Mike Gargano
body: I tried formatting this a couple different ways. This also didn't work.

```


"customfield_10742": { 
start: {{triggerIssue.customfield_10772}},
end: {{triggerIssue.customfield_10772}},
}

```


author: Martin Sturm
body: Hello [@Mike Gargano](/t5/user/viewprofilepage/user-id/5068376) - as I said, I am no expert on this matter, but can you do some kind of string concatenation or a JSON.stringify on the value side of things?  
Because if I interpret your code correctly you would end up trying to set a string based custom field with an JSON object, right?

```
"customfield_10742": JSON.stringify({ 
start: {{triggerIssue.customfield_10772}},
end: {{triggerIssue.customfield_10772}},
}
```

and maybe the YYYY-MM-DD conversion for the value that you mentioned above already.


author: Tanguy Crusson
body: [@Bopanna](/t5/user/viewprofilepage/user-id/3901598) from our support team just found a workaround for this I believe!

He just shared this with me, and I believe it should help you [@Mike Gargano](/t5/user/viewprofilepage/user-id/5068376)

----

I tried to have a go at this by creating an automation rule and using advanced JSON editing to populate the JPD Date field. I was able to set the date using the below JSON format:

```
{    "fields": {        "customfield_10637":"{\"start\":\"{{now.jiraDate}}\",\"end\":\"{{now.jiradate}}\"}"}}
```

If we use {{\<date\>.jiradate}}, we should be able to format it to yyyy-dd-mm format as mentioned [here](https://support.atlassian.com/cloud-automation/docs/jira-smart-values-date-and-time/#:~:text=23%3A12.0%2B0000-,jiraDate,-1979%2D11%2D01)


author: Mike Gargano
body: [@Tanguy Crusson](/t5/user/viewprofilepage/user-id/502312) , I tried this and the automation kicked back an error:
> Error editing issues  
> FPD-304 (We couldn't save your changes. Copy your content, then try reloading the page.)

This is how I formatted the JSON:

```

{
"fields": {
"customfield_10742":"{\"start\":\"{{customfield_10772.jiraDate}}\",\"end\":\"{{customfield_10772.jiradate}}\"}"
}
}
```


author: Bopanna
body: Hello [@Mike Gargano](/t5/user/viewprofilepage/user-id/5068376)

Bopanna here from the Atlassian Cloud Support Team!

In order to investigate the error further on our end, I would kindly request you to raise a support ticket with us here, please: <https://support.atlassian.com>  

Thank you!  

Best,  
Bopanna


author: Mike Gargano
body: After working with Marcelo on the Atlassian Support Team we were able to determine I was missing the TriggerIssue Smart Variable. The Solution ended up being:

```
{
"fields": {
"customfield_10742":"{\"start\":\"{{triggerIssue.customfield_10772.jiraDate}}\",\"end\":\"{{triggerIssue.customfield_10772.jiradate}}\"}"
}
}
```


author: Tanguy Crusson
body: Awesome, thanks for letting us know [@Mike Gargano](/t5/user/viewprofilepage/user-id/5068376) ! I'll add this to the FAQ


author: Jamey Hawkins
body: I am receiving an error when attempting to use the answer above. Asking for the proper formatting and then when I try to implement a short text field it posts a bit of the code rather than a date at all. Any suggestions![error.jpg](https://community.atlassian.com/t5/image/serverpage/image-id/252814i801C33D00661CCDB/image-size/large?v=v2&px=999 "error.jpg")

```
{
"fields": {
"customfield_12448":"{\"start\":\"{{triggerIssue.customfield_12447.jiraDate}}\",\"end\":\"{{triggerIssue.customfield_12447.jiradate}}\"}"
}
}
```


author: Laura Kessell
body: Is this on the feature roadmap? It seems so important to keeping the two systems in sync!

comments: author: Tanguy Crusson
body: Yes, the team's currently investigating that one actually ?


author: Katja Arendt
body: Thanks to all for the solution. It worked fine for me. I just wanted to share my automation, as I included not only the trigger, when the Project Target gets changed but also the trigger, if a new delivery ticket gets added to the idea.

**Trigger is the value change of the Project Target (in my case customfield_10081)** {#toc-hId--380273770}
----------------------------------------------------------------------------------------------------------

#### Whole Picture {#toc-hId--1486663655}

![Screenshot 2024-04-03 144350.png](https://community.atlassian.com/t5/image/serverpage/image-id/316038i7D482D185BCF6AD4/image-size/large?v=v2&px=999 "Screenshot 2024-04-03 144350.png")

#### Detailed view of each step {#toc-hId-1000849178}

a. checking that i am in the right project

![Screenshot 2024-04-03 144614.png](https://community.atlassian.com/t5/image/serverpage/image-id/316039i9794D9241F776559/image-size/large?v=v2&px=999 "Screenshot 2024-04-03 144614.png")

b. branch that it changes the dates only on delivery issues of the idea

![Screenshot 2024-04-03 144923.png](https://community.atlassian.com/t5/image/serverpage/image-id/316041iDC067E106760CB28/image-size/large?v=v2&px=999 "Screenshot 2024-04-03 144923.png")

c. I restricted the update of the due date to specific types and projects. You can just leave that if you want to update the due date in every delivery ticket.

![Screenshot 2024-04-03 145123.png](https://community.atlassian.com/t5/image/serverpage/image-id/316044i703FA25C18AA708D/image-size/large?v=v2&px=999 "Screenshot 2024-04-03 145123.png")

d. I worked with a smart value variable. The smart value I put in was (thats what Mike here postet last as solution):  
**{{triggerIssue.customfield_10081.substringAfter("\\"end\\":\\"").substringBefore("\\"")}}**

![Screenshot 2024-04-03 145418.png](https://community.atlassian.com/t5/image/serverpage/image-id/316046i93385B532E4B7FE8/image-size/large?v=v2&px=999 "Screenshot 2024-04-03 145418.png")

e. put in the duedate in the related delivery tickets via edit issue advanced

```
{
"fields": {
"duedate": "{{endDate}}"
}
}
```

![Screenshot 2024-04-03 145629.png](https://community.atlassian.com/t5/image/serverpage/image-id/316047iE80FB4DFC907CF9B/image-size/large?v=v2&px=999 "Screenshot 2024-04-03 145629.png")

f: and in the end a litte log note to check what was inserted as the due date: via Log action:

Log message:

**DueDate in UDO Epics set to: {{triggerIssue.customfield_10081.substringAfter("\\"end\\":\\"").substringBefore("\\"")}}**

![Screenshot 2024-04-03 145806.png](https://community.atlassian.com/t5/image/serverpage/image-id/316050i661423B1DD118437/image-size/large?v=v2&px=999 "Screenshot 2024-04-03 145806.png")

DONE :)

Trigger is the adding of a new delivery ticket to an idea {#toc-hId--1507669863}
--------------------------------------------------------------------------------

Whole picture:

![Screenshot 2024-04-03 150006.png](https://community.atlassian.com/t5/image/serverpage/image-id/316052iA5535F6761784E60/image-size/large?v=v2&px=999 "Screenshot 2024-04-03 150006.png")

a. Trigger is that a new ticket is linked (implements, is implemented by)

![Screenshot 2024-04-03 150107.png](https://community.atlassian.com/t5/image/serverpage/image-id/316054iD4B4024AE700B6AA/image-size/large?v=v2&px=999 "Screenshot 2024-04-03 150107.png")

b. again I restricted the automation to a specific project. If you want to update every added delivery tickets just leave this step out

![Screenshot 2024-04-03 150251.png](https://community.atlassian.com/t5/image/serverpage/image-id/316055i8788DCB7CFA675AA/image-size/large?v=v2&px=999 "Screenshot 2024-04-03 150251.png")

c. again worked with a variable:

Smart value is: **{{destinationIssue.customfield_10081.substringAfter("\\"end\\":\\"").substringBefore("\\"")}}**

as you can see here you have to work with destinationIssue and not with triggerIssue.

![Screenshot 2024-04-03 150431.png](https://community.atlassian.com/t5/image/serverpage/image-id/316056iCF2A9AD7A3D417A0/image-size/large?v=v2&px=999 "Screenshot 2024-04-03 150431.png")

d: edit issue - issue due date to new linked delivery ticket

```

{
"fields": {
"duedate": "{{endDate}}"
}
}
```

![Screenshot 2024-04-03 162132.png](https://community.atlassian.com/t5/image/serverpage/image-id/316077i557C16AC11BFD41D/image-size/large?v=v2&px=999 "Screenshot 2024-04-03 162132.png")

e: and again a litte log note to check what was set as due date in the linked delivery ticket:

Log Message:

DueDate in new linked UDO delivery ticket set to: {{destinationIssue.customfield_10081.substringAfter("\\"end\\":\\"").substringBefore("\\"")}}

![Screenshot 2024-04-03 162256.png](https://community.atlassian.com/t5/image/serverpage/image-id/316078iB73DFE596140EE7B/image-size/large?v=v2&px=999 "Screenshot 2024-04-03 162256.png")

comments: author: Guy Geron
body: Hi [@Katja Arendt](/t5/user/viewprofilepage/user-id/4647048) ,

First thanks for all these tips! ??

QQ - how did you find the id of the Project target field?


author: Guy Geron
body: I've just found a "way" to find the custom field. This was suggested by [@Tom Rouillard](/t5/user/viewprofilepage/user-id/4349568) back in 2021: <https://community.atlassian.com/t5/Jira-questions/How-do-you-find-a-field-ID-in-a-team-project/qaq-p/1710958>  

Do a JQL search using the custom field exposed as a column in the search result, and click on the custom field column to sort.   
The JQL will automatically readjust the JQL to ORDER BY the custom field with its ID.


author: Guy Geron
body: I also tested your approach [@Katja Arendt](/t5/user/viewprofilepage/user-id/4647048) , and it works nicely! Thank you ??


author: Katja Arendt
body: Hi, also one easy way, which I use all the time is described here

<https://confluence.atlassian.com/jirakb/how-to-find-any-custom-field-s-ids-744522503.html>

It is option 2:

you can just copy that link (

* `<JIRA_BASE_URL>/rest/api/latest/issue/BS-1?expand=names` )

to your brower, insert your url and add it to your favorites in the browser.

For me it is the fastest way to find any custom field id of any field in any project. :)


Tags: automation

date

json