Error when deploying validation pattern in package with PowerShell

  • 16 February 2021
  • 0 replies
  • 23 views

Userlevel 1
Badge +7

Issue

In the package XML, all objects have the deployment action set to "Default":

 

20097i47DA3CEC0D90FB2F.png

 

When attempting to deploy a package with PowerShell, the following error is shown:

 

20094i8EBE429B46639F12.png

 

But the package can be deployed with Package and Deployment tool.

 

20095i0E975E01FEBDC747.png20096iF82D40773902EA4A.png

 

Diagnosis

In general, K2 will compare the GUID, System Name, and Display Name of each object in the package with the one on the target environment to determine if the same object in the package already exists on the target environment. System Name must be unique across all objects, but it is possible to have multiple objects with the same Display Name.

 

Validation patterns are a little different as they only have a name and GUID. Each validation pattern will have a unique GUID and name. 

 

When deploying a package with the Package and Deployment tool, the default action that gets chosen for an object will depend on whether the object is found on the target environment. If the same object exists on the target environment, the Package and Deployment tool will default to using the existing object instead of deploying the object in the package. There are options to force the Package and Deployment tool to deploy that object.

 

The same logic also applies to packages deployed with PowerShell. If the same object already exists on the target environment, K2 will not deploy that object.

 

Using the same logic, the error shown above should not appear in the first place as K2 should have detected the validation pattern on the target environment and not deploy it.

 

But upon further investigation, the GUID of the validation pattern on the source environment where the package was created from, and the GUID of the pattern on the target environment, is different.

 

In such scenario, the Package and Deployment tool will look at the name and determine that the pattern in the package is the same as the one on the target environment, so it sets the default action for the pattern to "Use Existing ValidationPattern". There are no other option on the Package and Deployment tool to deploy the pattern, except for using the pattern on the target environment. 

 

20098i2FCDFF6DF60DFAC2.png

 

When deploying the package with PowerShell, the behavior is different. The validation pattern in the package is determined to be different from the pattern on the target environment, so the default action is to deploy the pattern. But because a pattern with the same name already exists on the target environment, an error on the validation pattern will be shown.

 

Resolution

To ensure this error does not show up again when deploying a package containing this validation pattern with PowerShell, make sure the GUID of this validation pattern on both the source and target environment matches.

 

Make sure no other changes, or new objects are created on the target environment. Changes should be made on the source environment, then create a package of the items, and deploy the package to the target environment. This will ensure the objects' GUID, System Name and Display Name are synchronized across both environments.

 

If faced with the error shown above, you can delete the validation pattern on the target environment, and redeploy a package containing the validation pattern. This ensures the same pattern will get recreated on the target environment, with the same GUID as the pattern on the source environment.

 

After redeploying the validation pattern, edit the forms and views that use that validation pattern, and check if the validation pattern is still being mapped properly. If not, reselect the validation pattern and check in the forms or views.

 

20099i00052531ED49AA03.png20100i0A1A1179024E2A14.png20101iFAFCDF281943B6C4.png

 

Related Links


0 replies

Be the first to reply!

Reply