在工作流中创建多个必填字段

时间:2015-07-29 18:16:26

标签: youtrack

我需要在创建问题时设置多个字段。

我试过这个

rule Mandatory 

when <issue created or updated> { 
  Swimlane.required("Must have a swimlane"); 
  UtgmsVehicleName.required("Must be attached to a vehicle "); 
  Subsystem.required("Subsystem must be set"); 
  Assignee.required("Assignee must be set"); 
  Fix versions.required("Fix versions must be set/"); 
}

它会不断要求设置所有字段。什么是满足要求的最佳方式。

基于Alex的建议,我得到了这个

rule MandatoryFields 

when !isReported() { 
  var assigneeSet = Assignee != null; 
  var subSystemSet = Subsystem != null && Subsystem != {No subsystem}; 
  var fixedVersionSet = Fix versions != null; 
  var assigneeValue = Assignee.oldValue; 

  var messageValue = "Mandatory fields:"; 
  if (!assigneeSet) { 
    messageValue = messageValue + " Assignee"; 
  } 
  if (!subSystemSet) { 
    messageValue = messageValue + " Subsystem"; 
  } 
  if (!fixedVersionSet) { 
    messageValue = messageValue + " FixedVersion"; 
  } 
  assert (assigneeSet && subSystemSet && fixedVersionSet): messageValue; 

  if (assigneeSet) { 
    Assignee = assigneeValue; 
  } 
}

1 个答案:

答案 0 :(得分:0)

您可以拥有类似

的内容
var noSwimlane = Swimlane == null;
var noSubsystem = Subsystem == null;
...
var message = "You need to fill the following fields: ";
if (noSwimlane) {
  message += "Swimlane";
}
...
assert !(noSwimlane || noSubsystem || ...) : message;