Convert between different Field Types

Hey guys,

we have a project where people choose criterias from fields (they range from 0-3) and I wanted to create a workflow that calculates a weighted result depending on these values.
As I read here http://forum.jetbrains.com/thread/YouTrack-1406 one can not convert between different field types in the workflow editor. However I need to have the enum value as integer, otherwise I can't do any calculations.
My new idea was to have an integer field instead of the enum field. The problem is that the values that have already been input into the enum field should be kept.
Unfortunately I only found a way to convert between type[1] and type[*]
So my question is (how) can I convert between enum and integer field keeping the values?

Cheers,
Marc
4 comments
Comment actions Permalink
It would be also fine to add the integer field, apply a command that does the conversion and then remove the old field if that is possible anyhow
0
Comment actions Permalink
You can do it by the workflow:
schedule rule convert string to integer 
 
yearly on September, 17 at 10:00:00 [<expression>] { 
  applyCommand("new_integer_field " + Type, project.getUser("root")); 
}
prettyPrint();

Please try it on a test environment first.
0
Comment actions Permalink
Alright, cool. The conversion worked on my testsystem. Is it, however, possible to silently apply a command within a workflow with the "applyCommmand" function? Because I don't want the whole company to be notified that some fields were updated.
0
Comment actions Permalink
Unfortunately, there isn't such ability, please vote for JT-24778.

As a workaround you can turn off the mail server in settings, make changes and turn it back on in several minutes.

Another workaround is to create a simple stateless and change the Priority by the command e.g. 'Priority Critical' in the Command Window under the project admin silently:
rule convert 
 
when Priority.changed { 
  var root = project.getUser("root"); 
  for each myIssue in root.getIssues(Everything, "") { 
    myIssue.applyCommand("new_integer_field" + Type, root); 
  } 
}
prettyPrint();
I suppose no one notification should be sent.
0

Please sign in to leave a comment.