Hi Team,
I want to transfer the date time field value into the text field,
Please advice me how can I achieve this.
Hi Fabio,
Sorry for the late reply, I was on leave.
The code which is provided by you, I just added this code into the post function in the step of create and it is successful. But the same field value is getting chage into the next step, So when I put the same code into the next step post function I am getting the error in log "1 of 2 custom field is already in used"
can you please help me on this!
Regsrds,
Najmul
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello Najmul,
here your post-function script code :
import com.atlassian.jira.component.ComponentAccessor; import com.atlassian.jira.issue.CustomFieldManager; import com.atlassian.jira.issue.Issue; import com.atlassian.jira.issue.fields.CustomField; import java.text.SimpleDateFormat; import com.atlassian.jira.issue.MutableIssue; import com.atlassian.jira.issue.IssueManager; import com.atlassian.jira.event.type.EventDispatchOption; SimpleDateFormat sdf = new SimpleDateFormat("yyyy/MM/dd"); IssueManager issueManager = ComponentAccessor.getIssueManager(); Issue issue = issue; CustomFieldManager customFieldManager = ComponentAccessor.getCustomFieldManager(); CustomField dateField = customFieldManager.getCustomFieldObjectByName("Date Field"); CustomField textField = customFieldManager.getCustomFieldObjectByName("Text Field"); if(issue.getCustomFieldValue(dateField)!=null){ Date val = (Date)issue.getCustomFieldValue(dateField); MutableIssue mIssue = (MutableIssue) issue; mIssue.setCustomFieldValue(textField, sdf.format(val)); issueManager.updateIssue(ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser(), mIssue, EventDispatchOption.DO_NOT_DISPATCH, false); }
Please, update Fields Name and date format at your convenience.
Hope this helps,
Fabio
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Fabio,
Its worked fantastically!
but with a problem, Its showing the time which is entering in the database means Singapore time. I want to show the time which is currently in the date field same in the text field.
Please give your valuble answer!
Regards,
Najmul
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
please could you provide me the desired format?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Fabio,
After creating the ticket the date time field showing me the time as per Indian time zone. As per my knowledge, In database it storing in the form of Singapore time zone.
So when I am trying to run your code it give me the date which is present in the database.
My requirement is that, The date should be come in Inian time zone in the text field.
If you need any more clarification then et me know.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Najmul,
at database level a date is stored as a date (universal) and not as specific timezone. You can define the presentation date format editing the date format into JIRA System Administration panel.
What we need to fix your issue is the desidered date format for your text field :
example yyyy/DD/mm , mm/DD/yyyy, mm-DD-yyyy and so on.
Hope this clarifies,
Fabio
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Please, could you mark this answer as accepted if your question has been resolved?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Najmul,
do you need to do that in a transition? if so, you can setup a scripted post function for that purpose.
Let me know.
Regards,
Fabio
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Fabio,
What are the code that I have to write into the Post function. How can I copy the value from date field to simple text field.
Please suggest your answer on the same.
Many thanks in advance!
Regards,
Najmul
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.