Forums

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

Datepicker in Jira Product Discovery is formattet incorrectly in rest api

Dennis Hansen November 28, 2023 edited

I've found that the datepicker field when added as custom field in Jira Product Discovery is incorrectly formattet in the rest API.

 

Is there a way to format this so i can get the start date of the object returned?

 

"customfield_10146":"{\"start\":\"2023-11-29\",\"end\":\"2023-11-29\"}"

 If it followed the other customfields with more properties i would have expected it to look like "[{"start":""2023-11-29","end":"2023-11-29"}]"

I'm trying to access it like this but it does not give a result because the object is saved as a string:

{{triggerIssue.fields.customfield_10146.start}}

 

I tried doing a remove("\\") on the string but i'm still not able to select the values.

 

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

Hi @Dennis Hansen 

Yup, that is the "date" format for Jira Product Discovery (JPD): it is a text string representing a range of dates...with no typing or attribute information (at least in automation rules).

You can find other posts where customers used the text functions in automation rules to get at the values in the field, and I suspect the same would be needed to access a date with the REST API functions.  I just double-checked and the REST API issue function with ?expand=names does return dates in that format.

Kind regards,
Bill

Dennis Hansen November 28, 2023

Too bad that Atlassian did not consider using the same formats, i hope this is included in future optimizations.

 

I ended up doing a string handling of the field to get the start date of my datepicker in my automation (trigger issue being my issue in project discovery):

{{triggerIssue.fields.customfield_10146.remove("\\").substring(10,20).toDate}}

 

I used it as part of a compare to see if the date was before or after the other issue in an advance compare:

First value: {{triggerIssue.fields.customfield_10146.remove("\\").substring(10,20).toDate.diff(issue.fields.customfield_10015).days}}

Condition: Greater Than

Second value: 0

 

And then i found an article describing how to update the datepicker from in an advance editing of the field using below format:

 

{
"fields": {
"customfield_10146": "{\"start\":\"{{triggerIssue.customfield_10015.jiraDate}}\",\"end\":\"{{triggerIssue.customfield_10015.jiradate}}\"}"
}
}

So it is possible to read and write to the field, but my god it's cumbersome.

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

I am glad to learn you have something that works.  Another way to do that would be to use the match() function with a regular expression, as that will be easier to adjust in the future...

As some Atlassian employee posts in the JPD community pages indicate automation work is in progress, I also wonder if that format of that field will change when accessed by automation rules and the REST API.  Regardless, I would keep a watch on that rule to ensure it works as expected.

ngonzalez December 15, 2023

Thanks, this was very helpful!

Like Bill Sheboy likes this

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
PREMIUM
TAGS
atlassian, atlassian government cloud, fedramp, webinar, register for webinar, atlassian cloud webinar, fedramp moderate offering, work faster with cloud

Unlocking the future with Atlassian Government Cloud ☁️

Atlassian Government Cloud has achieved FedRAMP Authorization at the Moderate level! Join our webinar to learn how you can accelerate mission success and move work forward faster in cloud, all while ensuring your critical data is secure.

Register Now
AUG Leaders

Atlassian Community Events