The Behaviours plugin can set conditional values based on other fields which is nice. I have everything working except I only want to set a default value during the "Create" of a new issue and never after that.
I can't seem to find a way to know whether you are creating a new field with this plugin and the scipting language. I tried looking for certain fields (like "id") buth that field is alway set (for both create and edit). I also tried to get the existing issue object with with MutableIssue and a call to the "issue" method but I have not had any success there.
It seems there must be a way to know that you are in the "create" step but the workflow choices in the plugin only include the "open" action and don't seem to expose the "Create" action that is in the JIRA 5.0 Design workflow screen.
If I can't figure this out, I was thinking if adding a field that only appears on the Create screen and checking for a value. Then either changing it after the create to know I am no longer in the Create step but this seems like adding another custom field is an inelllegent solution.
Anyone have any idea how to check if you are on the Create step especialy for Behaviors scripts?
There is a long conversation about this here: https://studio.plugins.atlassian.com/browse/JBHV-134.
As I said, shortly this will be easier:
I'm going to reopen this because I am adding new APIs: getAction(), getActionName(), getDestinationStep(), getDestinationStepName(), to make this much easier.
But, if you're only looking for the create step, if formContents["id"] is null, then it's the create step.
> I tried looking for certain fields (like "id") buth that field is alway set (for both create and edit).
You must be wrong here, it's not set for create.
I am using JIRA 5.0.2 and both of the following:
formContents["id"] getFieldById("id").getFormValue()
Return a number whenever the screen you were on is an issue screen. So, the returned value does not appera to be the value of the issue ID for the "Create Form" but for the whole HTML form. I think this may only be the case in JIRA 5.0 because of the new way the "Create" issue works. All I know is, its definatly returning the issue# of the active page for a "Create Bug" button at the top of the form. For example, if you navigate to the "Project" page, the call will fail because there is no "id" on the form but if you are on an issue browse page, it gets a numer.
This makes me wonder if other fields are not the current value but the value from the issue browse screen at the time of the Behavior call. I am very confused at the moment and I may be off but something does not look right.
Another indicator that something is not right is that this "id" will be blank (or a bad call) if you right click on the "Create Issue" button but not if you click on it and there is a current browed issue on the screen.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Its actualy worse than I thought. The same issue with Behavious with JIRA 5.0 and Project etc. If you set up a Behaviours action for "Project A" only, and you hit the "Create Issue" button and a "Project A" issue was on screen at the time, the behaviors will continue to fire even if you switch to "Project B" on the top of the create form. And the opposite is true. If you hit the "Create Issue" button while you are on a "Project B" issue, and then switch to "Project A" (where the Behaviour should now be triggered) nothing happens. If you are not at an issue page, it will work (I am guessing because there would be only one value for Project to find) but you are often sitting at one issue and creating another.
I have tested this quite a bit on JIRA (v5.0.2#725-sha1:5735107) and its reproducable for me.
I am entering the scripts using the Validation Script form on the Behaviours config page and not pointing to a file path on the server but I would think it would work the same either way.
I think I am going to bail on this and try a post-create event to set defaults in some situations but this will not be dynamic (where the users can override it during the create).
I will write this up as an issue and submit it. I keep getting the feeling that this changing Project/Type in the fly now in JIRA 5.0 will break a lot of plugins.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I'll look into it... 5.0.2 has not been tested much.
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 all the input and support of the plugin. Very much apreciated.
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.