Forum Discussion

cawool's avatar
cawool
Copper Contributor
Jan 05, 2021

Add-PnPFieldFromXml - Assistance

Hi,   New here, far from being any kind of developer but always looking to learn.  This time around for me its Add-PnPFieldFromXml and specifically adding multiple site content types. As I'm learn...
  • ganeshsanap's avatar
    ganeshsanap
    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.

Resources