Script to refresh identity cache in 4.7?

  • 25 November 2016
  • 8 replies
  • 12 views

Userlevel 3
Badge +16

Anyone got a script for refreshing the K2 user identity cache in 4.7? Old scripts no longer work and not having much joy getting any resolution from support thus far.


8 replies

Badge +15

Hi,

 

From what I can tell in 4.7, there is not much changes to the Identity.Identity table. The old script to refresh the cache should still work:

 

UPDATE [Identity].[Identity]
SET [ExpireOn] = GETDATE()
,[Resolved] = 0
,[ContainersResolved] = 0
,[ContainersExpireOn] = GETDATE()
,[MembersResolved] = 0
,[MembersExpireOn] = GETDATE()
GO

 

You may want to elaborate further what you mean by the script is not working.

Userlevel 3
Badge +16

Hi,

 

Thanks for the info... Basically, support used Visual Studio code to create a K2 process for updating the Identity Cache (not sure what the code looked like as they created it for us).

 

This code has worked fine pn older K2 versions, but I tried to use Package and Deployment to migrate it to our new v4.7 server, but pakage and deployement fails to package up the process, i get these errors:

 

'MaintainADGroupsMaintainMembership' Process is referencing the 'Read' method on the 'PostScanning_BasketMetaData_BasketMembership' SmartObject that could not be found.

 

'MaintainADGroupsMaintainMembership' Process is referencing the return type 'read' of the 'Read' method on the 'PostScanning_BasketMetaData_BasketMembership' SmartObject that could not be found.

 

'MaintainADGroupsMaintainMembership' Process is referencing the 'PostScanning_BasketMetaData_BasketMembership' SmartObject that could not be found.

 

So i can't package up the process from the source server to deploy to the new one.

 

Any chance of showing me how to create the process from scratch using your code in v4.7? I've never created a process from Visual Studio.

 

Thanks

Badge +13

It seems like your SmartObject isn't in the package, and have nothing to do with Identity cache/refresh.

Badge +15

Peter is correct. Try including the SmartObject stated in the error message into your package. If the same error still appears, check if that SmartObject has the method stated, and that it is currently working. You can just the SmartObjects Service Tester to check if your SmartObject is working properly.

Userlevel 3
Badge +16

I've looked everywhere and can't find any Smartibject called "PostScanning_BasketMetaData_BasketMembership"...

 

Where would it be, the project was done in Visual Studio by K2 Support and then a process created from it.... any ideas?

 

I can open the process in K2 Studio - i just have a Start and a Default Client Event with a Deafult Server Event (Code) inside.

 

I obviously can't see the code in K2 Studio, so i've viewed the code In Visual Studio. -> On the Server Event Code -> View Code - Event Item. There is nothing in that code that mentions the BasketMembership Smartobject at all....

 

How this process is supposed to work is, User adds a AD user account to a Group via the K2 Form. When the user is added, a rule runs the Process and sends it the UserID of the AD User, which is used to do the K2 identity cache refresh...

 

Any ideas?

Badge +10

I think you're best bet is to go and find that SmartObject that's missing.  Then deploy that to the other environment and then your P&D should work.  With that said the P&D should typically pick up a smartobject that's used by a process and include it in the original package if you have the include depencies checked off.  Maybe the package wasn't created correctly.

 

Another option to find that smartobject is the SmartObject Tester Tool.  It has a search feature to look for that SmartObject..

http://help.k2.com/onlinehelp/k2blackpearl/userguide/4.7/content/resources/projects/advancedsmartobjects/smartobject-service-tester.htm

 

If that still doesn't help maybe submit a support ticket.

 

 

Userlevel 3
Badge +16

Hey Tim, how ya doing?

 

I've had K2 support on, we can't find the Smartobject anywhere. We tried using the Tester Tool, SQL Management studio, but can't be found.

 

In k2 Studio, when we open the process and look at the "references" section, we can see the reference to this Smartobject, but it then says Smartobject not found.

K2 are not usre whether this Smartobject was internal to them when the original fix was provided.

 

Obviously without that "basket" smartobject i can't package up the process. So i'm kinda stuck right now.

Badge +10

I'm doing well. Thanks

Okay this shouldn’t be too hard to resolve. In that case what if you create a stored proc using that identity sql script, wrap it in a SmartObject and then call it inside of K2 Studio like any other SmartObject.

 

Here is an example of a Stored Proc that you could add to a database (doesn’t necessarily have to be the K2 Database since that would be unsupported :)) but I tested it on the same sql server that contains the K2 database. Maybe have your SQL guy do a quick check of the stored proc but conceptually I see no difference than running the SQL script directly against the K2 database like recommends.

 

http://help.k2.com/onlinehelp/k2blackpearl/icg/4.6.11/webframe.html#User_Manager_Introduction.html#Refresh_the_User_Manager_Cache

 

SET ANSI_NULLS ON

GO

SET QUOTED_IDENTIFIER ON

GO

-- =============================================

-- Author:           <Author,,Name>

-- Create date: <Create Date,,>

-- Description:      <Description,,>

-- =============================================

CREATE PROCEDURE RefreshK2ServerIdentityCache

 

AS

BEGIN

       -- SET NOCOUNT ON added to prevent extra result sets from

       -- interfering with SELECT statements.

       SET NOCOUNT ON;

 

    -- Insert statements for procedure here

UPDATE [K2].[Identity].[Identity]

SET [ExpireOn] = GETDATE()

,[Resolved] = 0

,[ContainersResolved] = 0

,[ContainersExpireOn] = GETDATE()

,[MembersResolved] = 0

,[MembersExpireOn] = GETDATE()

 

 

 

END

GO

Reply