i have a custom field "check box" when i create a issue. However i would want to display this on the "Issue View Page" if the transition name is "A" but when i move this issue to other transitions like "B","C" etc this field should be hidden . i did try it using the behavior but doesn't seem to be working. Can anyone please help me on this.
Untitled.png
i have even tried adding this server side script on the behavior plugin for the custom field
import com.atlassian.jira.ComponentManager; import org.apache.log4j.Category; import com.atlassian.jira.workflow.JiraWorkflow ComponentManager componentManager = ComponentManager.getInstance() JiraWorkflow workflow = componentManager.getWorkflowManager().getWorkflow(issue); def wfd = workflow.getDescriptor() def actionName = wfd.getAction(transientVars["actionId"]).getName() FormField SaveAsDraft= getFieldById ("customfield_14905") String SaveValue = (String) SaveAsDraft.getFormValue() if(actionName != "Draft") { SaveValue.setHidden(false) } else { SaveValue.setHidden(true) }
This seems a little confused to me.
First, there's no such thing as "view" on a transition. A transition changes the status of an issue, and during a transition you can have a screen, but it's not a "view", it's an "edit"
So, there are two things I'm imagining you actually might mean:
Hi Nic..May be i wasn't clear much.i have attached a screenshot for the image above. There you can see a check box named "Save As Draft". i will explain the context below. The workflow has some states. Initial state is "draft" and then its "submit" state. Default behavior is whenever the issue is created it bypasses the "draft" state and issue is transitioned to the "submit" state. In case the user ticks the checkbox "Save As Draft" only then the issue is transitioned to "draft" state. But after this draft state when the issue further progresses to different state, the checkbox data "Save As Draft" : Yes , will always be displayed which is incorrect since the issue has moved out of the draft state. So i wanted to know how can we hide this after the draft state.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
The best answer here is "delete the draft field and educate your users to understand that they should look at the status" The next best option is to clear the checkbox on transition because the data is wrong. I'd put a post-function on the transitions out of "draft" to "not draft" status. Hiding it is the worst approach because you can still see it in reports, search for it and so-on. I'd just use the status correctly.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I agree with Nic... you don't have a "view issue screen for a transition". However from a cursory look at your code, you are trying to hide the field value, and not the field.
So you should use:
saveAsDraft.setHidden(true/false)
you don't need to get the form value at all.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks Nic and Jamie for explaining it so clearly. I managed to do it "Clear custom field" postfunction which Nic explained.
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.