Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Next challenges

Recent achievements

  • Global
  • Personal

Recognition

  • Give kudos
  • Received
  • Given

Leaderboard

  • Global

Trophy case

Kudos (beta program)

Kudos logo

You've been invited into the Kudos (beta program) private group. Chat with others in the program, or give feedback to Atlassian.

View group

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage
Highlighted

How do I modify the ConfiForm date to the format needed by JIRA

I'm creating a form using ConfiForms to create a JIRA task. Here is the code that I currently have located in a IFTTT to create JIRA Issue. Then a No Format macro inside of that, which contains the following code:

{

  "fields": {
     "project":
     {
     "key": "TASK"
     },
     "summary": "[entry.summary]",
     "description": "[entry.details]",
     "issuetype": { "name": "Task" },
     "assignee": { "name": "[entry.user]" },
     "customfield_20721": [{"id":"[entry.categories]"} ],
     "duedate":"[entry.duedate]
  }
}

This code worked perfectly when the duedate was manually entered (coded date) with the expected format ("duedate":"2012-10-10" ). Unfortunately, the format that confiForms is passing through is MMM dd, yyyy; which causes a "Could not prepare JSON..." error. 

 

Q: How can I change the format from MMM dd, yyyy to the format that JIRA is expecting: yyyy-MM-dd?

3 comments

In case someone else comes across this issue. The solution was: "duedate":"[entry.duedate.jiraDate]"

Note:
The first "duedate" is the JIRA field that the data will go to.

The duedate in the [entry.duedate...] is the name of my confiform field that the data is being pulled from. 

I probably should not have named my form field the same as the JIRA field.

Please look at Virtual functions in ConfiForms. We have some helper functions for exactly your needs

jiraDate

Same as "formatDate" method above, but specifies constant dateformat pattern (yyyy-MM-dd), suitable for JIRA REST API

 

jiraDateTime

Same as "formatDate" method above, but specifies constant dateformat pattern ("yyyy-MM-dd'T'HH:mm:ss.SSSZ"), should be compatible with ISO 8601 standard as JIRA requires when setting timestamps to JIRA fields

Like Chris_Stewart likes this

This helper function is not available in the filter.action? How can I retrieve another date format than the double when using the search function of the REST api?

You can specify the "fields" parameter in REST API call as described here https://wiki.vertuna.com/display/CONFIFORMS/REST+API#RESTAPI-Searchentries to decorate/transform the field value as needed (with virtual functions)

Thanks Alex, it works.

Hi Alex ,

Is the "fields" parameter in REST API call applicable only to search entries ? shall we use it in create entry REST API call ? will it work ?

Not sure I understand the question here, sorry... the format for the JSON is based on the spec given by Atlassian.

 

https://developer.atlassian.com/server/jira/platform/jira-rest-api-examples/

 

This is where this "fields" node comes from

Hi Alex,

my question is as per below link we can use fields parameter in REST API for searching entries in confiforms. so is it possible to use the fields parameter to create an entry ?

 https://wiki.vertuna.com/display/CONFIFORMS/REST+API#RESTAPI-Searchentries 

Sorry, I dont quite understand... you refer to the API that helps you to search ConfiForms entries - how is this connected to "create and entry"? Creating an entry can be done using this API - https://wiki.vertuna.com/display/CONFIFORMS/REST+API#RESTAPI-Createentry

I have same issue.

 

JIRA DATE Format: '2020-05-12T17:36:00.000-0500'

Confiform date: entry.TestDate.jiraDateTime

 

Tried format: entry.TestDate.formatDate(yyyy-MM-dd'T'HH:mm:ss.SSSZ) ( Actual time is May 12, 2020 01:30 )

JIRA output: 11/May/20 8:30 PM

So in the mapping  you need to set this as 

"some_jira_datetime_field":"[entry.TestDate.jiraDateTime] 

 Assuming you have "TestDate" as a date/datetime field in ConfiForms 

I tried that one but didn’t help

In confiform I set field as datetime 

OK, and what is the problem? You have mentioned you are having the same issue, but what exactly is your issue? 

I see the time difference in your examples and that might be the difference in timezones you have for Confluence/Jira. Or the differences in how your profiles are set in Confluence /Jira and if they use the same "timezone"

am in central timezone.


Issues is the time which am choosing in confiform is central timezone but when I send to jira the time got change.

But when I am doing manually in jira I cloud see datetime in cst 

And you servers have different time? Are they in a different timezone?

And that time differs from your time 7 hours?

Confluence 

system timezone etc/utc 

 

jira

time zone gmt-06:00 chicago

And this is the answer, right? That is why you see a different time in Jira (compared to Confluence)

is that possible to format datetime ? 

Where? Where do you want to format datetime? In ConfiForms?

Yes, we do have various functions, including the one to formatDate (and time)

https://wiki.vertuna.com/display/CONFIFORMS/Virtual+functions

confiform, is there any way to substract time in formatDate? like -86400000 milliseconds

"date_field": "[entry.TestDate.formatDate(yyyy-MM-dd'T'HH:mm:ss.SSSZ)]" is that possible to do changes here for my requirement.

I’ve used the following in some of my projects to add or subtract time:

[entry.somedatefield.timestamp.add(86400000)]

to subtract just add a “-“ sign in front of the milliseconds.

this can be found on the Virtual Functions page Alex mentioned above by searching “add(number)”. It’s a very useful page.

Yes, that's right. Thanks @Chris_Stewart 

Then something like this:

[entry.somedatefield.timestamp.add(-86400000).jiraDateTime]

[entry.somedatefield.timestamp.add(-86400000).jiraDateTime] - worked

Thanks @Alex Medved _ConfiForms_ and @Chris_Stewart 

Comment

Log in or Sign up to comment
TAGS

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you