Modify Guest role to to view/create issues but not edit them
I would like to modify the current permission for "Issue> Create Issue" to prevent those who are the role of "guest" to only create and view issues.
I've have a java script for what I'm looking for but I'm not sure how to get it to work properly
const entities = require('@jetbrains/youtrack-scripting-api/entities');
exports.rule = entities.Issue.onChange({
title: 'Restrict editing of issues to the reporter',
guard: (ctx) => {
// Only apply the rule when the issue is changed
return true;
},
action: (ctx) => {
const issue = ctx.issue;
const loggedInUser = issue.permittedGroup.users.find((user) => user.isLoggedUser);
const reporter = issue.reporter;
// Prevent non-logged in users and users other than the reporter from editing the issue
if (!loggedInUser || loggedInUser !== reporter) {
throw `Only the reporter is allowed to edit this issue.`;
}
},
requirements: {}
});
Please sign in to leave a comment.
Hello,
Thank you for the details. You can create a new role which would include only the required permissions and grant it to the Guest user.
Please let me know if you need further assistance.
I'm Lena from the YouTrack Team.
Could you please specify what you mean by a guest: our guest user, the group named 'guest', or a role with this name?
I would like to have the User "guest" (aka any anonymous user/unregistered user) only have the ability to create issues and revoke the ability to Edit/Draft any of the issues. Unfortunately its all grouped together under the "Create Issue" permission.
the roles observer do not offer that ability since that is only as the name states observing. If i can give the USER:guest the ROLE:Reporter without the ability to edit or draft an issue that would be ideal.
Yes i still need assistance. ill provide pictures to help you understand what I'm asking.
Guest is already given a role that has the following permission
which in the permissions description states "(also allows viewing and updating public fields in reported issues)"
I only want the role to have the ability to "Create new issues" and NOT "updating public fields in reported issues."
From my understand from this post https://youtrack-support.jetbrains.com/hc/en-us/community/posts/206579295-Permission-of-guest-user
you are able to create a javascript under workflow and modify the role permissions to allow such. Although in that post it changes the role permissions to allow "creating new issue" and save a "draft". I only want to allow "Create new issue". How do i apply the java script already provided to achieve what I'm asking.
First, you should create a new workflow as described here: https://www.jetbrains.com/help/youtrack/devportal/Quick-Start-Guide-Workflows-JS.html. You need the `On-change` module. In the editor, copy-paste this JS code.
Once you create the workflow, you should attach it to the project. Please follow these instructions: https://www.jetbrains.com/help/youtrack/cloud/Manage-Workflows.html#attach-workflow-project.