Error While Creating SharePoint Site Using Custom Site Template

I faced an issue while creating a SharePoint sub site using a custom site template with message “The field specified with name _AuthorByline and ID {1a7348e7-1bb7-4a47-9790-088e7cb20b58} is not accessible or does not exist”.

So, this column was referenced by some lists/content types from the web site from which custom site template was created.

Solution 1

Find the list or libraries in which the field is added/referenced,

  1. Write this custom code in console app, to loop through all the lists and then loop through all fields from these lists.

  2. While looping add a check if the field’s display name or internal name is the one for which you are getting error.
    1. string _accessToken = TokenHelper.GetAppOnlyAccessToken(TokenHelper.SharePointPrincipal, tenantUrl.Authority, TokenHelper.GetRealmFromTargetUrl(tenantUrl)).AccessToken;  
    2. using(var context = TokenHelper.GetClientContextWithAccessToken(projectReady, _accessToken)) {  
    3.     Web w = context.Web;  
    4.     context.Load(w.Lists);  
    5.     context.ExecuteQuery();  
    6.     FieldCollection fields = null;  
    7.     foreach(List list in w.Lists) {  
    8.         fields = list.Fields;  
    9.         context.Load(fields);  
    10.         context.ExecuteQuery();  
    11.         foreach(Field field in fields) {  
    12.             if (field.Title == "_AuthorByline" || field.InternalName == "_AuthorByline") {  
    13.                 Console.WriteLine("Got it");  
    14.                 Console.ReadLine();  
    15.             }  
    16.         }  
    17.     }  
    18.     context.Load(w.ContentTypes);  
    19.     context.ExecuteQuery();  
    20.     foreach(ContentType ct in w.ContentTypes) {  
    21.         context.Load(ct.Fields);  
    22.         context.ExecuteQuery();  
    23.         foreach(Field field in ct.Fields) {  
    24.             if (field.Title == "_AuthorByline" || field.InternalName == "_AuthorByline") {  
    25.                 Console.WriteLine("Got it");  
    26.                 Console.ReadLine();  
    27.             }  
    28.         }  
    29.     }  
    30. }  

Solution 2

If you still get an issue, follow the below steps,

  1. Download the template wsp file from SharePoint and rename the extension from wsp to cab.

  2. Open the cab file and select all and copy all the files to a folder.

    SharePoint

  3. Open this folder in Visual Studio. I opened the folder in Visual Studio Code.

  4. Press Ctrl + Shift + F to find the text in all the files in the folder and type the column name for which you are getting error.

  5. You should be able to find the references in the files. In my case I had issues in content types “Site Page” and “Repost Page”.

    SharePoint

  6. So, I removed the content types and added it again in the Site Pages library as there were no pages using these content types.

  7. Then saving the template again resolved the issue.