Attempting to use an example in the following link called "Set one field based on another field with information provided by the server", that is I'm trying to update a value based on the value of a select list. I'm new to Jira, I don't know groovy, etc. I'll try to get a log in the meantime, don't have access to the server.
It appears others have had the same issue (see following link), don't see a resolution, I'm on Plug-in v0.5.3, Jira 5.1.4. If that is the issue, please let me know! Otherwise read on. here's an issue with the example. I added the first line of my code based on this issue, still doesn't function.
I'm not sure why the "String componentLead" line of code was included. Is it needed or is some code missing?
import com.atlassian.jira.bc.project.component.ProjectComponent FormField formComponent = getFieldById(fieldChanged) FormField formAssigneeOtherField = getFieldByName("Assignee Other") String componentLead List<ProjectComponent> components = formComponent.getValue() as List // List components = formComponent.getValue() as List // if any components have been set, set the user field to the component lead of the first component // otherwise unset it if (components) { formAssigneeOtherField.setFormValue(components.first().lead) } else { formAssigneeOtherField.setFormValue("") }
Questions:
1) do I need to reindex?
2) do I always need to clear serverside cache?
3) is there another way to set a field value based on another field value?
Thanks.
Our company decided to not use the Behaviours plug-in due to this issue and several others Recently I've been using the Script Runner plug-in with "Has Custom Field value equal to". I put the logic on the Create Issue Workflow transition. This is ok for the creation of an issue but the validation only fires on the create. If someone opens the issue in Edit, the validation doesn't fire. Javascript is another option, but I haven't found good examples that work consistantly. I think some of the plug-ins work well for simple validation, but when the validation is complex the plug-ins don't always work or it's difficult to code. In some cases, we have just created another issue type to eliminate doing validation of select lists.
I'm using a server-side script.
import com.atlassian.jira.bc.project.component.ProjectComponent
FormField formComponent = getFieldById(fieldChanged)
FormField formAssigneeOtherField = getFieldByName("Assignee Other")
FormField formDateOnLetterField = getFieldByName("Date on Letter")
List<ProjectComponent> components = formComponent.getValue() as List
//I added this setFormValue to display the contents of the component to the Date on Letter field
formDateOnLetterField.setFormValue(formComponent.getValue())
if (components) {
formAssigneeOtherField.setFormValue(components.first().name)
}
else {
formAssigneeOtherField.setFormValue("")
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Jamie, thanks for your replies. I've made progress, I can get the value that I select in a Component to display in another field. But if I remove everything from a component, the related field does not get refreshed properly. Since I don't have access to the log files yet I'm displaying the contents of the component to another field and it shows there is data in that component even though the component field displays on the screen as empty and the red * redisplays. See attached pdf, thanks!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Lead is the component lead. Make sure your behaviour is actually mapped to a project, and that the script is attached to the components field. But you will need to look at more examples to do what you want.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks for the quick response.
I may be confused about the use of the term "lead". I'm looking at the field called Component/s, there are four possible values: Email, Fax, Letter, Phone.
I thought whatever value I selected of the four values was the "lead"...is this incorrect? Likely.
I'd like to either pass the value I selected to field Assignee Other or take the value and do some logic on it. Such as, If "Email", set field Assignee Other to USPS or If "Fax", set Assignee Other to Sprint, etc. I can't seem to get Assignee Other to populate with anything.
Thx. I can send a screenshot.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
The purpose of doing this with the behaviours plugin is it sets the value in the form as the user make changes. If you want the user can then change the "assignee other". If you just want to set the value of a field it's easier to do this in a post-function or a listener.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
That's just an example that sets a field to the component lead. What is it that you're trying to do? This code will only work if you have a field called "Assignee Other", and your components have a lead defined.
-> String componentLead
It's not needed in the code above.
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.