Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Set Form Value for Time Spent in Log Work

Burak Kaya
Contributor
February 25, 2021

Hi Folks,

I would like set a default value for Time Spent field by setFormValue function by using behaviour.

I've tried the code below but it does not work properly. Is there any suggestion?

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.fields.CustomField;
import com.atlassian.jira.issue.CustomFieldManager;
import com.onresolve.jira.groovy.user.FieldBehaviours;
import com.atlassian.jira.issue.Issue;
import groovy.transform.BaseScript

import org.apache.log4j.Level
import org.apache.log4j.Logger

@BaseScript FieldBehaviours fieldBehaviours

String className = "tr.com.as.behaviour.OysmSetTimeSpent10Min";
Logger logger = Logger.getLogger(className);
logger.setLevel(Level.ERROR);
logger.debug ("Script " + className + " started");

def timeSpent = getFieldByName("Time Spent");

timeSpent.setFormValue("10m");

Jira Version: 8.5.4
Script Runner Version: 6.19.0

Kind Regards,
Burak

1 answer

Suggest an answer

Log in or Sign up to answer
0 votes
Jeroen Poismans
Community Champion
February 8, 2021

Hi,

Can you provide some extra info:

  • Is the User Picker field on the Edit screen, in other words can it be changed with an issue update or only in a transition?
  • Same question for the assignee.

I am asking because if you want to do this kind of validation, you would have to have a "trigger" event for the validation BEFORE the issue is updated.

The update of one of these fields can not be the trigger because by then the value would already have been changed, in other words the validation would be too late.

You can do the validation when these fields are updated in transitions. 

 

Regards,

Jeroen

TAGS
AUG Leaders

Atlassian Community Events