Hi All,
I am using the "Hide system or plugin UI element" from ScriptRunner Add-On to hide a Link in the UI and it works to hide it for all members of the project.
I have also found a script to hide to all the members except the project admin. I am able to perform the above for all project, but my condition is to restrict only one project.
Can anyone suggest How to restrict on one project based on project role.
Below is the script I found out and using
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.security.roles.ProjectRoleManager
def project = jiraHelper.project?.key
String roleName = "Administrators"
if (project != null) {
def user = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
ProjectRoleManager projectRoleManager = ComponentAccessor.getComponent(ProjectRoleManager);
def projectRole = projectRoleManager.getProjectRole(roleName)
return projectRoleManager.isUserInProjectRole(user, projectRole, issue.getProjectObject())
}
return false
Like even if i put something like this in the behavior tab, still nothing happens, would you be able to assist me.
I just tried your code and it worked for me.
You can change the code like this
def apply = getFieldById("customfield_19896")
log.error("apply: " + apply)
if (! apply.getValue()) {
apply.setFormValue("Hi do not replace the revision value kindly update here")
}
Then open the necessary screen and have a look in the logs.
In my case the log looks like this:
/rest/scriptrunner/behaviours/latest/validatorsByPid.json [c.o.j.groovy.user.FieldBehaviours] initForm field ID: customfield_23100, value: null
You see "field ID" is not null, which means that the custom field was found, and the value is null, which means that your if condition will work.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I tried the code above in the create screen.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Sure, @Alexey Matveev but after the using the code, I did have the edit screen not loading for ever, and I needed to refresh the page and edit which is not desirable at all.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Like if i remove the code from the behavior, the edit page loads fine. Is this fixable?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hmmm. that is strange why the code makes your edit screen freeze. Kindly have a look in the logs and try look for errors.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.