shareplum icon indicating copy to clipboard operation
shareplum copied to clipboard

KeyError: 'Title'

Open vicbruno opened this issue 6 years ago • 6 comments

I encountered a Sharepoint list where the 'Title' field has been deleted or renamed. Looks like Shareplum always expects it to be there.

C:\ProgramData\Anaconda3\lib\site-packages\shareplum\shareplum.py in init(self, session, listName, url, verify_ssl, users, huge_tree, timeout)

         self._disp_cols = {i['DisplayName']: {'name': i['Name'], 'type': i['Type']} for i in self.fields}
 
         title_col = self._sp_cols['Title']['name']
         title_type = self._sp_cols['Title']['type']
         self._disp_cols[title_col] = {'name': 'Title', 'type': title_type}

vicbruno avatar Sep 27 '19 17:09 vicbruno

I assume it's always there because I'm under the impression that it can't be deleted, just renamed. What version of Sharepoint are you using and how did you delete the 'Title' column?

jasonrollins avatar Sep 28 '19 14:09 jasonrollins

I also assumed it wasn't possible, but I find myself querying such a list. Sharepoint Server 2016.

I un-commented the code you had right right below the lines above to get past that.

        standard_source = 'http://schemas.microsoft.com/sharepoint/v3'
        self._sp_cols = {i['Name']: {'name': i['DisplayName'], 'type': i['Type']} for i in self.fields}
        self._disp_cols = {i['DisplayName']: {'name': i['Name'], 'type': i['Type']} for i in self.fields \
                        if i['StaticName'] in ['Title', 'Modified'] or i['SourceID'] != standard_source}

vicbruno avatar Sep 30 '19 21:09 vicbruno

I am seeing a similar issue, but with u'Title'. The workaround above does not solve the issue in my case.

File "C:\Python27\lib\site-packages\shareplum\shareplum.py", line 303, in List return _List(self._session, listName, self._url, self._verify_ssl, self.users, self.huge_tree, self.timeout) File "C:\Python27\lib\site-packages\shareplum\shareplum.py", line 337, in __init__ title_col = self._sp_cols['Title']['name'] KeyError: u'Title'

FerrumFatum avatar Jan 02 '20 14:01 FerrumFatum

I'm closing this issue as it relates to SharePoint 2016 and adding it to SharePlum2.

jasonrollins avatar Feb 16 '20 18:02 jasonrollins

I'm also seeing this with Sharepoint Online. Simple fix is in #109

When the Title column is referenced in fields by an alias, a KeyError occurs:

    207             # Convert to SharePoint Style Column Names
    208             for i, val in enumerate(fields):
--> 209                 fields[i] = self._disp_cols[val]["name"]
    210             viewfields = fields
    211             soap_request.add_view_fields(fields)

KeyError: 'Title'

logan-pugh avatar Jun 16 '20 02:06 logan-pugh

Seems it may apply to other fields with aliases as well, not just Title.

logan-pugh avatar Jun 16 '20 03:06 logan-pugh