PCJ-Exporting Service Management project fails due to Request Type referencing missing custom field

Problem Statement

When exporting Service Management project process fails with an error similar to the below message related to missing custom field.

Error Message 

An error occurred:

Trying to export Request Type found problem: Could not find object: Field with ID 'customfield_10122' used by Request Type 'Request Type Name'

At Most frequent errors found in export you can find advice to fix this problem

Location:

[Project Name] [Service desk Name] [Request Type Request Name@@Issue Type Name]

Log Entries 

2023-06-30 14:35:36,027+0300 JiraTaskExecutionThread-2 ERROR admin [c.a.projectconfigurator.projectconfigserialize.ProjectConfigSerializingContext] [Project Name] [Service desk Name] [Request Type Request Name@@Issue Type Name] Trying to export Request Type found problem: Could not find object: Field with ID 'customfield_10122' used by Request Type 'Request Type Name' com.awnaba.projectconfigurator.utils.errorhandling.ObjectNotFoundException: Could not find object: Field with ID 'customfield_10122' used by Request Type 'Request Type Name' at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) at java.lang.reflect.Constructor.newInstance(Constructor.java:423) at org.codehaus.groovy.reflection.CachedConstructor.invoke(CachedConstructor.java:83) at org.codehaus.groovy.reflection.CachedConstructor.doConstructorInvoke(CachedConstructor.java:77) at org.codehaus.groovy.runtime.callsite.ConstructorSite$ConstructorSiteNoUnwrap.callConstructor(ConstructorSite.java:84) at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallConstructor(CallSiteArray.java:59) at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callConstructor(AbstractCallSite.java:238) at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callConstructor(AbstractCallSite.java:250) at com.awnaba.projectconfigurator.groovytools.servicedesk.RequestTypeFieldGroovyTools.getRequestTypeAnyFields(RequestTypeFieldGroovyTools.groovy:77) at com.awnaba.projectconfigurator.jiraobjectfacades.RequestTypeToolsImpl.getFields(RequestTypeToolsImpl.java:209) at com.awnaba.projectconfigurator.projectconfigserialize.RequestTypesGlobalTable.exportFields(RequestTypesGlobalTable.java:112) at com.awnaba.projectconfigurator.projectconfigserialize.RequestTypesGlobalTable.insert(RequestTypesGlobalTable.java:76) at com.awnaba.projectconfigurator.projectconfigserialize.RequestTypesGlobalTable.insert(RequestTypesGlobalTable.java:1) at com.awnaba.projectconfigurator.projectconfigserialize.AbstractGlobalTable.lambda$0(AbstractGlobalTable.java:76) at com.awnaba.projectconfigurator.utils.SmartErrorReporter.wrapSafely(SmartErrorReporter.java:98) at com.awnaba.projectconfigurator.projectconfigserialize.ProjectConfigSerializingContext.wrapSafely(ProjectConfigSerializingContext.java:638) at com.awnaba.projectconfigurator.projectconfigserialize.AbstractGlobalTable.findOrInsertObject(AbstractGlobalTable.java:59) at com.google.common.collect.ImmutableList.forEach(ImmutableList.java:422) at com.awnaba.projectconfigurator.projectconfigserialize.ServiceDeskExporter.exportRequestTypes(ServiceDeskExporter.java:443) at com.awnaba.projectconfigurator.projectconfigserialize.ServiceDeskExporter.exportServiceDesk(ServiceDeskExporter.java:131) at com.awnaba.projectconfigurator.projectconfigserialize.ServiceDeskExporter.lambda$0(ServiceDeskExporter.java:117) at com.awnaba.projectconfigurator.utils.SmartErrorReporter.wrapSafely(SmartErrorReporter.java:98) at com.awnaba.projectconfigurator.projectconfigserialize.ProjectConfigSerializingContext.wrapSafely(ProjectConfigSerializingContext.java:642) at com.awnaba.projectconfigurator.projectconfigserialize.ServiceDeskExporter.export(ServiceDeskExporter.java:116) at com.awnaba.projectconfigurator.projectconfigserialize.ProjectGlobalTable.insert(ProjectGlobalTable.java:161) at com.awnaba.projectconfigurator.projectconfigserialize.ProjectGlobalTable.insert(ProjectGlobalTable.java:1) at com.awnaba.projectconfigurator.projectconfigserialize.AbstractGlobalTable.lambda$0(AbstractGlobalTable.java:76) at com.awnaba.projectconfigurator.utils.SmartErrorReporter.wrapSafely(SmartErrorReporter.java:98) at com.awnaba.projectconfigurator.projectconfigserialize.ProjectConfigSerializingContext.wrapSafely(ProjectConfigSerializingContext.java:638) at com.awnaba.projectconfigurator.projectconfigserialize.AbstractGlobalTable.findOrInsertObject(AbstractGlobalTable.java:59) at com.awnaba.projectconfigurator.projectconfigserialize.ProjectGlobalTable.findOrInsertObject(ProjectGlobalTable.java:75) at com.awnaba.projectconfigurator.projectconfigserialize.ExportManager.dumpProjectConfig(ExportManager.java:289) at com.awnaba.projectconfigurator.projectconfigserialize.ExportManager.createJAXBTree(ExportManager.java:245) at com.awnaba.projectconfigurator.projectconfigserialize.ExportManager.dumpConfigurations(ExportManager.java:93) at com.awnaba.projectconfigurator.operationsapi.impl.ConfigExporterTask.call(ConfigExporterTask.java:40) at com.awnaba.projectconfigurator.operationsapi.impl.ConfigExporterTask.call(ConfigExporterTask.java:1) at com.awnaba.projectconfigurator.operationsapi.impl.JobRunner.runSynchronousTask(JobRunner.java:129) at com.awnaba.projectconfigurator.operationsapi.impl.JobRunner.runJob(JobRunner.java:104) at com.awnaba.projectconfigurator.operationsapi.impl.ProjectConfigExporterImpl.callExport(ProjectConfigExporterImpl.java:106) at com.awnaba.projectconfigurator.operationsapi.impl.ProjectConfigExporterImpl.exportSynchronous(ProjectConfigExporterImpl.java:72) at com.awnaba.projectconfigurator.operationsapi.impl.CompleteExportTask.exportConfig(CompleteExportTask.java:219) at com.awnaba.projectconfigurator.operationsapi.impl.CompleteExportTask.call(CompleteExportTask.java:75) at com.awnaba.projectconfigurator.operationsapi.impl.CompleteExportTask.call(CompleteExportTask.java:1) at com.awnaba.projectconfigurator.longrunningtasks.TaskHelperImpl$WrappingTask.safeCall(TaskHelperImpl.java:206) at com.awnaba.projectconfigurator.longrunningtasks.TaskHelperImpl$WrappingTask.call(TaskHelperImpl.java:152) at com.awnaba.projectconfigurator.longrunningtasks.TaskHelperImpl$WrappingTask.call(TaskHelperImpl.java:1) at com.atlassian.jira.task.TaskManagerImpl$TaskCallableDecorator.call(TaskManagerImpl.java:528) at com.atlassian.jira.task.TaskManagerImpl$TaskCallableDecorator.call(TaskManagerImpl.java:486) at java.util.concurrent.FutureTask.run(FutureTask.java:266) at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) at java.util.concurrent.FutureTask.run(FutureTask.java:266) at com.atlassian.jira.task.ForkedThreadExecutor$ForkedRunnableDecorator.run(ForkedThreadExecutor.java:216) at java.lang.Thread.run(Thread.java:748)


Cause

A deleted custom field was once used by a Service Management Request Type. Upon deletion not all references to a deleted custom field gets removed. Some orphan records are left:

Solution

In order to identify and remove orphan entry or entries (in case multiple fields reported) you need to:

  1. Identify the entries

SELECT * FROM AO_54307E_VIEWPORTFIELD WHERE FIELD_ID = '<customfiled_ID>'* * custom field from error message SELECT * FROM AO_54307E_VIEWPORTFIELD WHERE FIELD_ID IN ('<customfiled_ID>',<customfiled_ID>...**) ** in case of multiple missing custom fields reported

2. Delete obsolete entry/ies

DELETE FROM AO_54307E_VIEWPORTFIELD WHERE FIELD_ID = '<customfiled_ID>'* * when single custom field reported DELETE FROM AO_54307E_VIEWPORTFIELD WHERE FIELD_ID IN ('<customfiled_ID>',<customfiled_ID>...**) ** in case of multiple missing custom fields reported

Note : Always back up your data before performing any modifications to the database. If possible, test any alter, insert, update, or delete SQL commands on a staging server first.

3. After entries deletion you can retry exporting the project.

Â