Hi,
I'm trying to create a issue linked to another based on a transition.
I would like the summary of the new ticket be as follows:"CustomFieldFromParent CustomText ParentSummary"
I have managed to get it working except for the customfield from the parent.
I have had no issue in trying to reference a text custom field, the script I used for this can be found here:
import com.atlassian.jira.ComponentManager; import com.atlassian.jira.issue.CustomFieldManager; import com.atlassian.jira.issue.fields.CustomField; import com.atlassian.jira.issue.IssueManager; import com.atlassian.jira.issue.Issue; import com.atlassian.jira.issue.MutableIssue; CustomFieldManager customFieldManager = ComponentManager.getInstance().getCustomFieldManager(); CustomField CustomFieldName = customFieldManager.getCustomFieldObjectByName( "CustomFieldName" ); issue.summary = issue.getCustomFieldValue( CustomFieldName) + ' txt ' +issue.getSummary();
However for some reason I can't seem to reference a Date Picker type customfield.
Is there something I would need to change in this script?
Also the custom field I'm trying to reference has spaces in the name, does that complicate things?
Thanks in advance,
In the end the main issue was trying to use [ in my custom text.
I'm not succesfully using the code below:
import com.atlassian.jira.ComponentManager; import com.atlassian.jira.issue.CustomFieldManager; import com.atlassian.jira.issue.fields.CustomField; import com.atlassian.jira.issue.IssueManager; import com.atlassian.jira.issue.Issue; import com.atlassian.jira.issue.MutableIssue; CustomFieldManager customFieldManager = ComponentManager.getInstance().getCustomFieldManager(); def cf = customFieldManager.getCustomFieldObjectByName('CustomField') val = issue.getCustomFieldValue(cf).toString().split(" ")[0] issue.setSummary(val + ' Custom text ' + issue.getSummary())
Thanks for the tips.
I think the following should work
def cf_2 = customFieldManager.getCustomFieldObjectByName('Starting Date') val_2 = issue.getCustomFieldValue(cf_2).toString().split(" ")[0] issue.setSummary(val_2 + issue.getSummary())
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I think you should convert the date time field value to string
The following should work
issue.summary = issue.getCustomFieldValue(CustomFieldName).toString() + ' txt ' +issue.getSummary();
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
I did some additional testing and included your transform to string.
What I noticed was that If I use customfields which have spaces in the name such as "Custom Field" it gives error regardless of the customfield type.
I tried using the following, can you see if i made some mistake in the way I reference to the customfield?
import com.atlassian.jira.ComponentManager; import com.atlassian.jira.issue.CustomFieldManager; import com.atlassian.jira.issue.fields.CustomField; import com.atlassian.jira.issue.IssueManager; import com.atlassian.jira.issue.Issue; import com.atlassian.jira.issue.MutableIssue; CustomFieldManager customFieldManager = ComponentManager.getInstance().getCustomFieldManager(); CustomField 'Custom Field' = customFieldManager.getCustomFieldObjectByName( "Custom Field" ); issue.summary = issue.getCustomFieldValue('Custom Field').toString() + ' txt ' +issue.getSummary();
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
To be honest i do not know if spaces in name creates this type of error. But, in order to avoid this is better to get your custofields with the id. The code should be like
CustomField customField_test = customFieldManager.getCustomFieldObject( customField_test id );
That way you have a better control in your references and you don't have to change your script in case you rename the custom field.
Hope that helps.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
> CustomField 'Custom Field' = customFieldManager.getCustomFieldObjectByName( "Custom Field" );
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I only have access to the JIRA administration in which I'm using a test project and am testing via Script Post-Function on transitions and checking the result if I execute the transition.
The only testing tool I have is GroovyConsole in which I can't reference to JIRA to check what exactly is going wrong, only if my logic seems correct..
def date = new Date() def formdate = date.format("yyyy-MM-dd"); println formdate
The above seems to work just fine so I'm unsure of what is going wrong.
As such I'm trying to solve the issue using your vast knowledge of issues like this.
Please find the update below:
I have been trying to fix the issues I'm having but no luck so far.
I have managed to eliminate the first part of the issue only to walk straight into the next one.
This is the current situation:
CustomFieldManager customFieldManager = ComponentManager.getInstance().getCustomFieldManager(); def variable1 = customFieldManager.getCustomFieldObjectByName( "customfield" ); def variable1 = variable2; issue.summary = "[" + issue.getCustomFieldValue(variable2).toString() + "]" + " txt " + issue.getSummary();
output:
summary of the cloned issue is:" [2014-04-10 00:00:00.0] txt OriginalSummary"
close to the goal now... only thing we need to do is remove the 0's from the summary..
I tried the following but it doesn't proccess:
CustomFieldManager customFieldManager = ComponentManager.getInstance().getCustomFieldManager(); def variable1 = customFieldManager.getCustomFieldObjectByName( "customfield" ); def variable1 = variable2.format('yyyy-MM-dd'); issue.summary = "[" + issue.getCustomFieldValue(variable2).toString() + "]" + " txt " + issue.getSummary();
output:
issue isn't even created.
I feel like I'm missing something simple, please advise.
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.