Forum Discussion
Add-PnPFieldFromXml - Assistance
- Jan 09, 2021
cawool Glad my approach worked for your original question.
For Current Error:
You are getting this error because whenever you create any field it converts the number and special characters in Name attribute to hexadecimal values to store it as internal name of your field. Maybe it is not liking the '4' character at the beginning of field name.
So, you can pass the different DisplayName (which you see in list view and list forms) and Name (internal name) in your XML like:
$docCreationDate = '<Field Type="DateTime" Format="DateOnly" DisplayName="Document Creation Date" Required="TRUE" Group="some group name" ID="{an iD}" Name="DocCreationDate" Description=""/>' Add-PnPFieldFromXml -FieldXml $docCreationDate $fourDate = '<Field Type="DateTime" Format="DateOnly" DisplayName="4 Date" Required="TRUE" Group="some group name" ID="{an iD}" Name="FourDate" Description=""/>' Add-PnPFieldFromXml -FieldXml $fourDate
Please click Mark as Best Response if my post helped you to solve your issue. This will help others to find the correct solution easily. It also closes the item. If the post was useful in other ways, please consider giving it Like.
cawool Hi,
Have you tried Get-PnPProvisioningTemplate? It simplifies your work even further with much more possibilites in deploying conten types, lists, pages etc.
Yours sincerely,
Aref Halmstrand