Why Does an Error Occur When I Import an Application?
Symptoms
When I import an application, the import procedure stops, and this error message shows:
An Item with the same key has already been added.
Cause
- In the App Builder, you delete a file from an application.
The file is not visible in the Application Explorer, but in the AgilePoint workflow database, the file remains with the status is OBSOLETE.
- You export the application, and then import it to another tenant.
- In the imported application, you add the same file that was previously deleted.
- You delete the file again from the new version of the application.
Now 2 versions of the file exist in OBSOLETE status in the AgilePoint NX workflow database.
- You export the application, and then import it to another tenant.
During the import, this error shows, and the import stops:
An Item with the same key has already been added.
In earlier versions of AgilePoint NX, the error existed in the system, but the error message was suppressed, and a success message showed after the import.
Prerequisites
- This procedure applies to AgilePoint NX OnPremises or AgilePoint NX PrivateCloud v6.0 SP1 or higher.
If this error occurs in AgilePoint NX OnDemand, contact AgilePoint Customer Support.
Good to Know
- If you delete any files that are in a status other than OBSOLETE, the application will fail.
Resolution
- Open a SQL command line with access to the AgilePoint workflow database.
- Get the FILE_NAME and CONTENT_TYPE values for the files that are in OBSOLETE status in your application.
Format:
SELECT [FILE_NAME],[CONTENT_TYPE] FROM [WF_APPLICATION_FILE] WHERE [APP_ID] = (SELECT [APP_ID] FROM [WF_ENABLED_APPS] WHERE [APP_NAME] = '{application internal name}') AND[STATUS] = 'OBSOLETE'
The application internal name is a technical name for your application. This is an identifier for an application in the AgilePoint NX system.
Example:
SELECT [FILE_NAME],[CONTENT_TYPE] FROM [WF_APPLICATION_FILE] WHERE [APP_ID] = (SELECT [APP_ID] FROM [WF_ENABLED_APPS] WHERE [APP_NAME] = 'Budget Request Application') AND[STATUS] = 'OBSOLETE'
- Enter this SQL command with the FILE_NAME and CONTENT_TYPE for your OBSOLETE file in the FILE_NAME IN and CONTENT_TYPE IN clauses and execute the query.
Format:
Select [FILE_ID], [FILE_NAME], [DISPLAY_NAME], [VERSION],[STATUS],[CONTENT_TYPE] FROM [WF_APPLICATION_FILE] where APP_ID = (SELECT [APP_ID] FROM [WF_ENABLED_APPS] WHERE [APP_NAME] = '{application internal name}') and FILE_NAME IN ('{file names in OBSOLETE status}') and CONTENT_TYPE IN ('{content types of files in OBSOLETE status}') order by [FILE_NAME] ,[CREATED_DATE] desc
This query gives the value for the FILE_ID for your file.
Example:
Select [FILE_ID], [FILE_NAME], [DISPLAY_NAME], [VERSION],[STATUS],[CONTENT_TYPE] FROM [WF_APPLICATION_FILE] where APP_ID = (SELECT [APP_ID] FROM [WF_ENABLED_APPS] WHERE [APP_NAME] = 'Budget Application') and FILE_NAME IN ('Notification', 'Budget Request Process') and CONTENT_TYPE IN ('user\email' , 'user\processmodel') order by [FILE_NAME] ,[CREATED_DATE] desc
- Delete the files as necessary, depending upon the status of the file:
- If the latest version of the file is not OBSOLETE, you can delete all the records which are in OBSOLETE status for the specified file:
Format:
DELETE FROM [WF_APPLICATION_FILE] where FILE_ID IN ('{FILE_IDs of OBSOLETE files}')
Example:
DELETE FROM [WF_APPLICATION_FILE] where FILE_ID IN ('80BF000C297E17E1116663D4AF4C0C04', 'AD68507B9D1227BE11667FCE50ACA6AB', '02EA8FF73ACFE511829AC417FEEE8B44')
- If the latest version of the file is OBSOLETE, you can delete all the records which are in OBSOLETE status for the specified file, with the exception of the latest version of the file:
Format:
DELETE FROM [WF_APPLICATION_FILE] where FILE_ID IN ('{FILE_IDs of OBSOLETE files}')
Example:
DELETE FROM [WF_APPLICATION_FILE] where FILE_ID IN ('80BF000C297E17E1116663D4AF4C0C04', 'AD68507B9D1227BE11667FCE50ACA6AB', '02EA8FF73ACFE511829AC417FEEE8B44')
- If the latest version of the file is not OBSOLETE, you can delete all the records which are in OBSOLETE status for the specified file: