0

I am trying to add the column below via PowerShell

<Field 
    ID="{1920c575-d592-40eb-a163-5a302b78aa65}" 
    Type="Note" 
    DisplayName="1920c575d59240eba1635a302b78aa65" 
    StaticName="1920c575d59240eba1635a302b78aa65" 
    Name="1920c575d59240eba1635a302b78aa65" 
    Required="FALSE" 
    Hidden="TRUE" 
    Overwrite="TRUE" 
    ShowInNewForm ="FALSE" 
    ShowInEditForm="FALSE" 
    ShowInDisplayForm="FALSE" 
    xmlns="http://schemas.microsoft.com/sharepoint/" 
/>

However I get this error message:

Exception calling "AddFieldAsXml" with "1" argument(s): ""
At line:14 char:9
+         $destWeb.fields.AddFieldAsXml($fld.OuterXml)
+         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
    + FullyQualifiedErrorId : SPException

All other site columns are created correctly but not this one. I know this is related to a metadata column but at this point I am not sure if it is related. I have another identical column except the GUIDs that gets created with out problem. Any idea how to troubleshoot this?

I am using the code from this site http://get-spscripts.com/2011/01/export-and-importcreate-site-columns-in.html

1
  • Can you show the code context that's running this? You should not have to provision the hidden Note columns that accompany Taxonomy columns. Commented Feb 8, 2018 at 15:40

1 Answer 1

0

It seems that you have already created that field with that GUID.

What about if you export the columns? Do you get any field with that same GUID 1920c575-d592-40eb-a163-5a302b78aa65? If you don't see it, try to empty site's recycle bin and try to re-run the script.

Another possibilty, it's that as Internal Name is being repeated and SharePoint is adding one more character to make it unique, and that would overcome the limit of 32 characters limit. Try to change Internal Name to less characters.

1
  • Thank you. It was related to 32 characters limit. When use ID column to get the field I see the field is already there.
    – Aslan
    Commented Feb 8, 2018 at 20:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.