Confluence has been updated to version 6.15.9

Page tree
Skip to end of metadata
Go to start of metadata


Synchronize Custom Field Values
/**
 * Available since TGE 1.19 only!
 */
import com.atlassian.crowd.embedded.api.User
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.security.JiraAuthenticationContext
import com.atlassian.jira.user.ApplicationUser
import com.atlassian.plugin.PluginAccessor
 
// get current user
JiraAuthenticationContext jiraAuthenticationContext = ComponentAccessor.getOSGiComponentInstanceOfType(JiraAuthenticationContext.class);
Object userObject = jiraAuthenticationContext.getLoggedInUser();
User user = userObject instanceof ApplicationUser ? ((ApplicationUser) userObject).getDirectoryUser() : (User) userObject;
 
// get data manager
PluginAccessor pluginAccessor = ComponentAccessor.getPluginAccessor();
Class dataManagerClass = pluginAccessor.getClassLoader().findClass("com.idalko.jira.plugins.igrid.api.data.TGEGridTableDataManager");
def tgeGridDataManager = ComponentAccessor.getOSGiComponentInstanceOfType(dataManagerClass);
 
// initialize synchronization
StringBuilder result = new StringBuilder();
try {
    tgeGridDataManager.synchronizeCustomFieldValues(user);
    result.append("Custom field values synchronization is initialized.\n");
} catch(Exception e) {
    result.append("Custom field values cannot be synchronized due to error: " + e.getMessage() + "\n");
}
 
println(result.toString());
return result.toString();
  • No labels