I'm trying to make a script that collects values from other fileds and from these datas create some string and insert it to another custom field. The problem is that it't doesn't works. Somehow I have to fill two times the same information to the workflow screens fields to see them in the custom filed where I need to have them. This is a self transition. You can see the source below. Any suggestion is appreciated.
You should add some log.debug() calls to log some variables and code status information to your log file. Before that you should set the log level to DEBUG (log.setLevel(org.apache.log4j.Level.DEBUG)). "log" ist already available and an org.apache.log4j.Category object.
On which position in the post function list do you call your post function?
Please post code as code (see "CODE" button in the toolbar).
Please try your post function as the last postfunction in the list of postfunctions.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Or, you could try the get the values from the issue object and not from the custom field object:
issue.getCustomFieldValue(cf)
In this way the at this point not stored values will be returned. If you try to get the value from the custom field it's read from the stored values.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Yes, under the fire a ... event...
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I don't know about your script, but if you are just looking for a way to update fields based on other fields, Update issues post function from Conditioned Workflow Functions for JIRA
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
The target field has wiki style renderer.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
As I see, the main problem is that I can't put the newest value into the filed. I can see the "second newest" under the header. When start the transition again with other values, I'm going to get the vaules before this transition.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
import com.atlassian.jira.issue.Issue import com.atlassian.jira.issue.CustomFieldManager import com.atlassian.jira.issue.fields.CustomField import com.atlassian.jira.ComponentManager import com.atlassian.jira.issue.customfields.option.LazyLoadedOption import java.sql.Timestamp import java.text.SimpleDateFormat import com.atlassian.jira.issue.util.DefaultIssueChangeHolder import com.atlassian.jira.issue.util.IssueChangeHolder import com.atlassian.jira.issue.ModifiedValue import com.atlassian.jira.util.ImportUtils import com.atlassian.jira.component.ComponentAccessor import com.atlassian.jira.issue.IssueUtils import com.atlassian.jira.issue.fields.layout.field.FieldLayoutItem; import com.atlassian.jira.issue.MutableIssue; Issue issue = issue; String EVENT_TYPE = "Event Type"; String EVENT_SUMMARY = "Event summary"; //az élesen "Event Summary" legyen a mező neve String EVENT_DATE = "Event Date"; String NEXT_STEP = "Next Step"; String THREAD_HISTORY = "Thread History"; String THREAD_HISTORY_HEADER = "||Event Type||User name||Event Date||Event summary||Next Step||Due Date||"; String lineSeparator = System.getProperty("line.separator"); ComponentManager componentManager = ComponentManager.getInstance(); CustomFieldManager customFieldManager = componentManager.getCustomFieldManager(); CustomField type = customFieldManager.getCustomFieldObjectByName(EVENT_TYPE); LazyLoadedOption option = type.getValue(issue); String eventType = option.toString(); if (!eventType){ return false; } CustomField summary = customFieldManager.getCustomFieldObjectByName(EVENT_SUMMARY); String eventSummary = summary.getValue(issue).toString(); if (!eventSummary){ return false; } CustomField date = customFieldManager.getCustomFieldObjectByName(EVENT_DATE); Timestamp Date = date.getValue(issue); String eventDate = new SimpleDateFormat("yyyy-MM-dd").format(Date); if (!eventDate){ return false; } CustomField step = customFieldManager.getCustomFieldObjectByName(NEXT_STEP); String nextStep = step.getValue(issue).toString(); if (!nextStep){ return false; } Timestamp due = issue.getDueDate(); String dueDate = new SimpleDateFormat("yyyy-MM-dd").format(due); if(!dueDate){ return false; } currentUser = ComponentManager.getInstance().getJiraAuthenticationContext().getUser(); currentUserName = currentUser.getDisplayName(); if(!currentUserName){ return false; } String newLine = lineSeparator + " | " + eventType + " | " + currentUserName + " | " + eventDate + " | " + "{noformat}" + eventSummary + "{noformat}" + " | " + nextStep + " | " + dueDate; String newValue = THREAD_HISTORY_HEADER + newLine; CustomField threadHistory = customFieldManager.getCustomFieldObjectByName(THREAD_HISTORY); String threadHistoryValue = threadHistory.getValue(issue); if (threadHistoryValue != null && threadHistoryValue != "") { int idx = threadHistoryValue.indexOf(lineSeparator); if (idx != -1) { newValue += threadHistoryValue.substring(idx); } } //if (issue instanceof MutableIssue) {//((MutableIssue)issue).setCustomFieldValue(threadHistory, newValue); //} FieldLayoutItem fieldLayoutItem = ComponentManager.getInstance().getFieldLayoutManager().getFieldLayout(issue).getFieldLayoutItem(threadHistory); ModifiedValue modifiedValue = new ModifiedValue(threadHistory.getValue(issue), newValue); IssueChangeHolder changeHolder = new DefaultIssueChangeHolder(); threadHistory.updateValue(fieldLayoutItem, issue, modifiedValue, changeHolder);
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.