Hi, I need to let all users get notified for thier changes, I need toi set this value to true in database for all users, by default this value is set to false. user>profile>preferences
This can be achieved using a groovy script that is run in the Groovy Script Runner Plugin panel
import com.atlassian.crowd.embedded.api.User
import com.atlassian.jira.ComponentManager
import com.atlassian.jira.user.preferences.PreferenceKeys;
import com.atlassian.jira.user.preferences.UserPreferencesManager
import com.atlassian.jira.user.util.UserUtil
import com.atlassian.jira.util.JiraEntityUtils
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.IssueRelationConstants
// this script sets flag "notify about own changes" to true for a set of users
// change this if you don't want it for all users (jira-users)
String do_it_for="jira-users"
UserPreferencesManager upm = ComponentManager.getInstance().getUserPreferencesManager()
UserUtil userUtil = ComponentManager.getInstance().getUserUtil()
SortedSet<User> members = userUtil.getAllUsersInGroupNames([do_it_for])
String result = "Users that will be notified about own changes now:\n"
try {
members.each() {
User user = it
prefs = upm.getPreferences(user)
prefs.setBoolean(PreferenceKeys.USER_NOTIFY_OWN_CHANGES, Boolean.TRUE);
result += "- "+user.getName()+" ("+user.getDisplayName()+")\n"
}
return result
} catch (e) {
}
// make sure change is visible immediately
upm.clearCache()
return result
If you want to change the preference for other users, just change the group name in variable do_it_for
Great many thanks!!
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.