Code Fix: Migrating a K2 Worfklow process instance from one version to another causes an error

  • 16 February 2021
  • 0 replies
  • 139 views

Userlevel 5
Badge +20
 

Code Fix: Migrating a K2 Worfklow process instance from one version to another causes an error

KB003056

PRODUCT
K2 Five 5.2
K2 Five (5.2) Fix Pack 27

 

Issue Description

When migrating a K2 Workflow process instance from one version to another, the process instance stops and returns an error.

Error Message

The following error occurs: “Object reference not set to an instance of an object”.

Resolution

  1. Ensure you have K2 Five (5.2) installed.
  2. Download the K2 Five (5.2) FP27 from K2 Partner and Customer Portal.
  3. Install the K2 Five (5.2) FP27 to apply the fix.

Considerations

After installing the Fix Pack, any new workflows will work when you migrate an instance to another version. 

Two Possible solutions for workflows in a broken state: 

If Live Instance Management has been attempted only once: 

  • Navigate to your K2 Database where you will change the [ExecutingProcID] value located in the [Server].[ProcInst] table, edit the top 200 rows of the table and change the value to the previous ID before Live Instance Management was attempted. The previous value of the [ExecutingProcID] will in most cases be the value of [ProcID] for that process.
  • Following the same procedure as above the [ExecutingProcID] will also need to be changed to the same previous version in the [ServerLog].[ProcInst] table.
  • Restart all your host servers.
  • Please note: that this will only work if you have not deleted any previous versions of your process. 

If Live Instance Management has been attempted more than once follow these steps: 

  • If your process instance 19 was migrated from version 1 to version 3 and then to version 4.
  • Run the following script to get the previous values for both [ExecutingProcID] and [ProcID].
  • Please note: If you do not use the default K2 as your database name, you will need to change the [K2] database name to the name of your database in the script below before it can be run, for example [Your Database Name].[Server].[Proc] 

--Populate Process instance ID below

DECLARE @ProcInstId INT = <procid> 

--Get the ProcSetId

DECLARE @ProcSetId INT 

SELECT @ProcSetId  = [ProcSetID]

  FROM [K2].[Server].[Proc] AS [P]

       INNER JOIN [K2].[Server].[ProcInst] AS [PI] ON [PI].[ProcID] = [P].[ID]

  WHERE [PI].[ID] = @ProcInstId 

  SELECT [ProcInstID]

      ,[User]

      ,[Date]

      ,[Descr]

         ,[P].[ID] AS [ProcId]

  FROM [K2].[ServerLog].[ProcInstAudit] AS [PIA]

       INNER JOIN [K2].[Server].[Proc] AS [P] ON [P].[Ver] = CAST (SUBSTRING([PIA].[Descr], 38, LEN([PIA].[Descr])) AS INT)

       AND [P].[ProcSetID] = @ProcSetId

  WHERE [PIA].[Descr] LIKE 'Process instance migrated to version%'

       AND [PIA].[ProcInstID] = @ProcInstId

  ORDER BY [PIA].[Date] DESC

 

  • The first initial version of the process instance, before any migration had been performed will not be visible.
  • The query is sorted by date and in most cases the executing [ProcID] will have to updated to value second from the top as this should be the last successful Live Instance Management attempt.
  • Following the same procedure as above the [ExecutingProcID] will also need to be change to the same previous version in the [ServerLog].[ProcInst] table.
  • Restart all your host servers.

 


0 replies

Be the first to reply!

Reply