Document toolboxDocument toolbox

Scripts for solving common problems

Hosting

DATA CENTER

Problems and solutions

Here are some scripts that address common Projectrak Data Center (DC) problems. These scripts should be executed in the Projectrak console, which can be accessed from the Manage Apps section and is only accessible to Jira Administrator.
Click here to learn more about the Projectrak Script Console console.

Most of the scripts make irreversible changes that can impact the proper functioning of the application. They should be used with caution.

Please contact our support team before using them.

 

Scripts for values

Problem: You need to delete values by their identifiers

Solution: The introduced identifiers are being traversed, and if they exist, they are deleted from the database.

import com.atlassian.jira.component.ComponentAccessor import com.deiser.jira.profields.ao.v2.projectvalue.ProjectValueMgr def VALUES_IDS = [x,x] def projectValueMgr = ComponentAccessor.getOSGiComponentInstanceOfType(ProjectValueMgr.class) def value = null def println = "" VALUES_IDS.each { println += "*** *** *** <br/>" println += "Value ID: " + it + "<br/>" value = projectValueMgr.get(it) if(value != null){ projectValueMgr.delete(value) println += "Deleted!! <br/>" } else{ println += "Can not found this Value <br/>" } println += "<br/><br/>" } return println

 

Problem: Delete all values from Projectrak within a set of projects.

Solution: All the introduced project identifiers are being traversed, and for each of them, all their values are being iterated to subsequently delete them.

import com.atlassian.jira.component.ComponentAccessor import com.deiser.jira.profields.ao.v2.projectvalue.ProjectValueMgr def PROJECTS_IDS = [x, x] def projectValueMgr = ComponentAccessor.getOSGiComponentInstanceOfType(ProjectValueMgr.class) def value = null def println = "" PROJECTS_IDS.each { println += "*** *** *** <br/>" println += "Project Value for Project: " + it + "<br/>" value = projectValueMgr.getByProject((Long) it) if(value != null){ projectValueMgr.delete(value) println += "Deleted!! <br/>" } else{ println += "Can not found this Value <br/>" } println += "<br/><br/>" } return println

 

Problem: The values in the columns where the value is stored in lowercase do not have the same equivalent value as those where the value is stored as raw data.

Solution: All existing values are verified. Each field type has a different validation check.

import com.atlassian.jira.component.ComponentAccessor import com.deiser.jira.profields.ao.v2.projectvalue.ProjectValueMgr import com.deiser.jira.profields.api.field.FieldService import com.deiser.jira.profields.api.field.FieldType def projectValueMgr = ComponentAccessor.getOSGiComponentInstanceOfType(ProjectValueMgr.class) def fieldService = ComponentAccessor.getOSGiComponentInstanceOfType(FieldService.class) def VALUES_IDS = projectValueMgr.get() def println = "*** Values different *** <br />" VALUES_IDS.each { def change = false def field = fieldService.get(it.field.ID) if(!(field.type.isCalculatedType() || field.type.isEquals("number") || field.type.isEquals("date") ||field.type.isEquals("duration"))) { if (it.value != null && !it.value.toLowerCase().equals(it.lowerValue)) { println += "VALUE: " + it.ID + "<br />" println += "Changing LowerValue <br />" it.setLowerValue(it.value.toLowerCase()) change = true } if (it.display != null && !it.display.toLowerCase().equals(it.lowerDisplay)) { println += "VALUE: " + it.ID + "<br />" println += "Changing LowerDisplay <br />" it.setLowerDisplay(it.display.toLowerCase()) change = true } else if (it.display == null && it.value != null) { println += "VALUE: " + it.ID + "<br />" println += "Set Display equals to Value <br />" it.setDisplay(it.value) it.setLowerDisplay(it.value.toLowerCase()) change = true } if(change){ projectValueMgr.save(it) println += "Change it! <br />" } } } return println

 

Problem: Information of values still exists in Projectrak for projects that no longer exist in Jira.

Solution: All value records are being traversed, and those where the project does not exist are being deleted.

 

Problem: There are projects with duplicate values for the same field.

Solution: Traverse all values and delete the duplicates, leaving the oldest value in the database.

Scripts for layouts

Problem: We have found non-existent fields in the structure of a layout.

Solution: Traverse the structure of all layouts to check if their fields exist, and if not, we delete them.

 

Problem: Within a layout, there is duplicated information and orphaned structures.

Solution: Traverse all the layouts and verify their internal structure. If they have duplicated or orphaned structures, we delete them.

 

Problem: We have found duplicate associations between layouts and projects.

Solution: Traverse all existing associations and remove the duplicates.

 

Problem: We have found associations of layouts with non-existent projects.

Solution: Traverse all associations and delete those that are associated with non-existent projects.

Scripts for items of list fields

Problem: We are experiencing issues with the items in the list fields, but we are uncertain about the root cause. We need to identify where the problem originates.

Solution: Display the information of the problematic items.

 

Problem: There are issues with the sequential order of items in list fields. They maintain their order, but it is not sequential.

Solution: Establish a new sequential order through the script.

Scripts for connections

Problem: Establishing a connection to a pre-existing database is required for certain fields of Projectrak's external list.

Solution: Through a set of IDs of external list fields, they are traversed to establish the selected connection using their respective ID.

Scripts for subscriptions

Problem: Know which subscriptions the instance has and who their owner is.

Solution: Retrieve all subscriptions stored in Projectrak along with their respective users.

Scripts for mapping to Jira custom fields

Problem: We have encountered Jira custom fields that have lost their association with Projectrak fields.

Solution: All Jira custom fields that belong to Projectrak are traversed to verify if they are related to a Projectrak field. If not, the Jira custom field is deleted.

 

Problem: The Jira custom fields related to Projectrak cannot be edited or deleted as they are currently locked.

Solution: All Jira custom fields that belong to Projectrak are traversed to unlock.

 

Problem: We want to regenerate the mapping of all Projectrak fields with the Jira custom fields.

Solution: Traverse the Projectrak fields that have mapping enabled to remove the current Jira custom field and generate a new one.

Scripts for gadgets

Problem: There are issues with data migrations related to the gadgets, and we want to identify the problematic gadget.

Solution: All users of the instance are being traversed to check the Projectrak gadgets. Both correct and erroneous gadgets are displayed on the screen.

Script for Projectrak cache

Problem: Need to enable or disable the Projectrak cache for testing purposes.

Solution: Set the desired value in the Projectrak configuration related to the cache.

Enable cache:

Disable cache:

Scripts for Projectrak database version

Problem: We want to know the latest Projectrak migration registered in Jira that has been performed. Please note that there may be other types of migrations that are not recorded in Jira.

Solution: Accessing the Jira tables where the migration code is stored.

 

Problem: We want to reset the latest Projectrak migration registered in Jira that has been performed. Please note that there may be other types of migrations that are not recorded in Jira.

Solution: Reset the record in the Jira tables where the migration code is stored.

Scripts for Oracle database

Problem: When making a change in the database properties, we encountered Clob-type columns in the Projectrak tables, which is causing errors in certain functionalities.

Solution: Execute three scripts to modify the column type. This involves creating a new column for data dumping and subsequently deleting the erroneous column. No information is lost during the execution of the scripts.

Project Values (Table: AO_00B950_AOPROJECT_VALUE)

Historical (Table: AO_00B950_AOHISTORICAL_FIELD)

List items (Table: AO_00B950_AOLIST_ITEM)

 

Related articles