Some days ago, while I was deploying a release package to the UAT server, I had to face a strange issue. There was a release step in the release note to execute a PowerShell script after installing the solution, in order to update some of the metadata fields in a Document Library.
There is a field within the document library columns which has been created using a custom field type, which is deployed through a farm solution. The given farm solution had web application scoped resources therefore it was deployed only to the Web Front End server and not globally deployed.
Now the issue was, when executing the PowerShell script to update some metadata in the document library items, the values already existent in the above custom field had got emptied although this field was not touched through the script.
After digging into the problem, I found that the root cause for this problem was because I was executed the script within the Application server. The farm solution had only installed the definition of the custom field type to the WFE server. This can happen to the feature definitions as well. Therefore, when retrieving the list item object through PowerShell code, the value of the custom field was not included. That's because the field type cannot be retrieved when trying to access it from the APPs server. As the list item object does not include this custom field property, it had emptied while updating list item back.
Finally, I changed the server and ran the script in the WFE server and everything worked properly.
Therefore, as a best practice and also as recommended, we
have to keep in mind to execute these kind of PowerShell scripts inside the WFE
server when the multi server architecture is used.
No comments:
Post a Comment