Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
languagejs
import com.atlassian.jira.component.*;
import com.atlassian.jira.issue.*;
import org.slf4j.*;
 
//please enable logging for package "com.deniz.jira.worklog.scripting" from Administration/System/Logging and Profiling
Logger log = LoggerFactory.getLogger(com.deniz.jira.worklog.scripting.ScriptingService.class);
 
def script = '''
  var projectKeys = ["ERP", "ITSD"]; //Change this line and add your project keys here. 
  function getProjectKey() {
    var issueKey=AJS.$("#log-work-issue-picker").val()[0];
    if (issueKey) {
      return issueKey.split("-")[0].trim();
    }
    return "NO Project Key";
  }
  function setDefaults() {
    var projectKey = getProjectKey();
    if (projectKeys.indexOf(projectKey) == -1) {
      AJS.log("Non-special project:" + projectKey + "!");
      return;  
    }
    AJS.log("handling project:"+projectKey);
    
    AJS.$("#wp-copy-to-issue-comments").click();
  }
  
  AJS.$(document).on("change", "#log-work-issue-picker-field", function(evt) {
    setTimeout(setDefaults, 10);
  });

'''

worklogPreEntryParameters.jsScript = script;

return worklogPreEntryParameters;

Set Time Spent Field to a Default Value

Code Block
worklogPreEntryParameters.timeSpent = "10m"