Hi,
I have created a custom issue type where I have to set the summary of that issue type to the custom field value (Email). Here is the code that I am using. The code works fine and sets the summary. I have question about the way I am assinging the value to the summary.
def cf1 = ComponentAccessor.customFieldManager.getCustomFieldObjectByName("Email")
def cfVal1 = issue.getCustomFieldValue(cf1).value
cfVal = "" + cfVal1
issue.summary = cfVal
In the above code I have to do ( cfVal = "" + cfVal1 ) to convert the value (cfVal1) to string otherwise it fails when I assign it summary. I tried changing the declaration
def cf1 = ComponentAccessor.customFieldManager.getCustomFieldObjectByName("Email")
string cfVal1 = issue.getCustomFieldValue(cf1).value
issue.summary = cfVal1
However that doesn't work. I don't see any errors but the script doesn't work. Any idea why I can't directly assign cfVal1 to Summary ( issue.summary = cfVal1)?
Thanks for your help!
Rama
I created a custom listener to update the summary when issue is created/updated. Below is snippet from code and my listener is working absolutely fine.
def cf1 = ComponentAccessor.customFieldManager.getCustomFieldObjectByName("Email")
def cfVal1 = issue.getCustomFieldValue(cf1).value
cfVal = "" + cfVal1
issue.summary = cfVal
My question is why I have have the 3rd line ( cfVal = "" + cfVal1 ) where I am apparently converting the value to string before assigning it to summary.
Why can't I simply do this? (this fails to work)
def cf1 = ComponentAccessor.customFieldManager.getCustomFieldObjectByName("Email")
def cfVal1 = issue.getCustomFieldValue(cf1).value
issue.summary = cfVal1
I am using Regular Expression Custom Field ( Kepler Custom Fields plug-in).I just now also tried with Text Field (single line) and it appears to work this way.
Thanks for your help!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
What type of field is "Email"?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You are trying to set the summary of an issue from a custom field value? In what context? In what way doesn't it work?
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.