YouTrack project name field can be changed after creating an issue in that project

Hello,

In a Youtrack project, when we create an issue, the 'Project' field is by default shown in the fields list on the top right side. The problem is, this 'Project' field is not read only meaning a user can change (by mistake) the Project name of an issue which links this issue to a different project. Once the issue created, Is it possible to make the Project field read only? Since it is not a custom field, we did not find any option in the YouTrack documentation.

I am attaching a screenshots for understanding.

Thank you for your support!

 

0
5 comments

Hi!

I'm Sergey from the YouTrack team.

Thank you for contacting us. I'm happy to help you.

Whether a user can change a project and which projects they can select depends on their permissions in these projects. Basically, if a user has access to projects and can create and/or update issues, then can change the issue's project. You can revoke these permissions, and the user won't be able to create or update issues and hence change projects. However, it won't work with specific conditions only. e.g., when an issue is reported.

Additionally, we have an automation tool called workflows. Among other things, you can forbid changing projects when specific conditions are met. If you are not familiar with this functionality, please refer to our tutorial.

For instance, the following code in the action section of the workflow forbids changing the issues' project.

workflow.check(!issue.isChanged('project'), 'Cannot change project!');

This rule must be attached to all the potential target projects. 

0

Hi,

Thank you for your help!

I created a workflow as you suggested.

const entities = require('@jetbrains/youtrack-scripting-api/entities');
const workflow = require('@jetbrains/youtrack-scripting-api/workflow');

exports.rule = entities.Issue.onChange({
  title: 'Test',
  action: (ctx) => {
    const issue = ctx.issue;
    workflow.check(issue.isChanged('project'), 'Cannot change project!');
  },
});

However, this does not solve our problem. With this workflow, a user can still change / edit the 'project' name of an issue. And this workflow prevents a user from changing any other field which we don't want.

We would like to have a solution which works the other way around, meaning we would like to prevent users from changing / editing 'project' name but users should still be able to edit other fields in that issue.

Did i miss something in the workflow or is there an issue with the proposed solution?

Best regards,

Abbas

0

Thanks for your response.

In general, the example was never meant to use as is. I shared it to showcase how one can forbid an action so that you then build a rule that covers your case. If you actually want to forbid changing the project at all times, then you can use the following (I've also slightly updated the example in the initial message to avoid further confusion):

const entities = require('@jetbrains/youtrack-scripting-api/entities');
const workflow = require('@jetbrains/youtrack-scripting-api/workflow');

exports.rule = entities.Issue.onChange({
  title: 'Test',
  guard: function(ctx) {
    return true;
  },
  action: (ctx) => {
    const issue = ctx.issue;
    workflow.check(!issue.isChanged('project'), 'Cannot change project!');
  },
});

The rule must be attached to the target project, i.e., the one you change the project to. If it applies to all the projects, then the rule must be attached to all of them.

0

Thank you very much for your answer!

That helped us a lot in solving our issue.

Best regards,

Abbas

0
You are welcome. Glad to hear that it helped.
0

Please sign in to leave a comment.