my jira version is 4.4.1.
i put a validator on "description".and add the validation script below,but the field "description" gets no result.
import com.atlassian.jira.project.version.VersionManager FormField formDescField=getFieldById("description") List<VersionManager> versions=getVersionsReleased(10101,true) as List formDescField.setFormValue(versions.first().getName())
anyone knows how to use the method "getVersionsReleased"
While you’re developing this, you should turn on logging for the Behaviours plugin and check the logs when something goes wrong. In this case, you’d see that your code is throwing exceptions and never even gets to the part where setFormValue is executed.
The problem here is that you can’t just call getVersionsReleased as a bare function. It’s a method of a VersionManager object, but you never got a VersionManager object. You only imported the class, which isn’t enough.
To get the VersionManager object, you can first get the ComponentManager object and call getVersionManager() on it, and to get the ComponentManager object you can import com.atlassian.jira.ComponentManager and call getInstance() on the class. getInstance() is a static function.
(I wish I could point you to some docs on this, but there don’t seem to be any good ones. I had to learn it by puzzling over example code.)
Try this:
import com.atlassian.jira.ComponentManager import com.atlassian.jira.project.version.VersionManager ComponentManager componentManager = ComponentManager.getInstance() VersionManager versionManager = componentManager.getVersionManager() FormField formDescField=getFieldById("description") List<VersionManager> versions=versionManager.getVersionsReleased(10101,true) as List formDescField.setFormValue(versions.first().getName())
thanks,Cedric
it works using your code.
another question:
you say Behaviours Plugin can logging.so i turn on logging for the plugin.
i searched out the JIRA installation location,can only find log files in JIRA\Atlassian\Application Data\JIRA\log.and found three log files:atlassian-jira.log,atlassian-jira-security.log,atlassian-jira-slow-queries.log.
open atlassian-jira.log,i didn't see any error messages about this plugin if i put wrong script into the plugin on purpose.
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.