Hi,
I need to have the custom fields to be empty when I am closing the issue so that while closing the issue I can update the latest values in that custom field. The custom field is Text single line type. I tried below code in validators, but getting an error. Kindly help.
import com.atlassian.jira.component.ComponentAccessor
def cf = ComponentAccessor.getCustomFieldManager().getCustomFieldObjectByName("Ground")
issue.setCustomFieldValue(cf, null)
Jira Version - 7.6
Hi, this is just static type checking, it is not a (blocking) error.It just says it does (can) not know the type of your cf variable (as you defined it by "def") and the null parameter. Nothing to worry about.
Save and your script will run (correctly).
I saved the script in validators and then published the workflow.
But when I moved the issue to the other transition, this filed is showing the previous valve only, and I tried to modify it, but still, it's showing as "Fill Grounding Box"
My need is, whatever the value given earlier should get cleared when I click Maintenance Complete step, and I need to give a new valve in the transition window.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Ok, I understand (I think :-))
First of all : changing (custom field) values in a "Validator" script does not make sense.
Second : You need the field to be cleared before the screen is shown, Validators are executed after the screen is updated by the user. But again, you cannot change custom field values in Validators!
Solution : you should clear the field in a Behaviors script (at screen initialization) and limit that to the specific workflow transition. See Behaviors documentation in Scriptrunner.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
As the solution mentioned, can you please share some details how to clear the field in a behavior script.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
For a field named "MyField" :
import com.onresolve.jira.groovy.user.FormField
FormField fldMyField = getFieldByName("MyField")
fldMyField.setFormValue(null)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Use a post function in the transition to clear the field :)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Yes i had used a post function in the previous transition and then it cleared the field when im in the current screen. But i needed to get the field cleared when i click maintanence complete from the current screen.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
So if I understood correctly you need to empty a field before you close it. So... Try to make an auto transition to clear the field after you move it to the last status before closed.
Example if you have the statuses In Progress -(Ready)> Ready For UAT -> Closed make an auto transition that will go from Ready to UAT in Ready to UAT when you press the Ready button(transition).
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@Mihai Schwarz
Not sure if you can help or understand why this happens but I want to simply clear a field prior to the transition screen. The odd issue is that in my UAT JIRA works perfectly and with a post-function it clears it up but in the PROD instance it waits till after. Both are the exact same Project, transition, clearing method and ranking in the the post-function(1st).
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@steven.mccaffrey- First check if you have edit permissions and also check the screens of the issue, if they match especially the edit screen.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I have edit rights because the clear action does happen just after the transition screen not prior like in my UAT. I compared the edit screens and they also are the same. I even re-indexed just to make sure as well.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@steven.mccaffrey- in your UAT env do you have a transition screen as well? As from my understanding is that in your UAT the transition and the post-fuctions works right away and in your production environment a transition screen pops up, am I right? If yes, you just have to eliminate the transition screen and it will behave the same.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Yeah but no both UAT and PROD are set up the exact same for some reason one triggers the post function prior to the transition screen and the other triggers the post function after the transition screen.
I'm honestly no sure which one is normal but what I just need my PROD Jira is to clear a custom field on the transition screen when that transition occurs.
Any ideas?
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.