shareplum icon indicating copy to clipboard operation
shareplum copied to clipboard

Add colums in list

Open robinostlund opened this issue 7 years ago • 6 comments

Hi, I have tried to create my own template in Sharepoint and then try to use that one because i want to add data to multiple columns, but as soon as i change from: site.AddList('Test list 1, description='Great List!', templateID='Custom List') To: site.AddList('Test list 1, description='Great List!', templateID='My list template')

It says Traceback (most recent call last): File "./fetch_deskpro_invoices.py", line 53, in sp.create_invoice_list() File "/Users/robin/git/work/layer5/billing_collector/modules/sharepoint.py", line 36, in create_invoice_list site.AddList('Robin Test Lista', description='Great List!', templateID='InvoiceTemplate') File "/Users/robin/.venv/python3/lib/python3.6/site-packages/shareplum/shareplum.py", line 103, in AddList templateID = templateIDs[templateID] KeyError: 'My list template'

So my question is, how can i configure sharepoint so i can use a template with my own columns or can i add columns from shareplum?

Thanks / R

robinostlund avatar Feb 28 '18 15:02 robinostlund

And when i am trying to add a column except Title, then it fails Traceback (most recent call last): File "./fetch_deskpro_invoices.py", line 54, in sp.upload_data_to_list() File "/Users/robin/git/work/layer5/billing_collector/modules/sharepoint.py", line 45, in upload_data_to_list new_list.UpdateListItems(data=my_data, kind='New') File "/Users/robin/.venv/python3/lib/python3.6/site-packages/shareplum/shareplum.py", line 545, in UpdateListItems self._convert_to_internal(data) File "/Users/robin/.venv/python3/lib/python3.6/site-packages/shareplum/shareplum.py", line 270, in _convert_to_internal raise Exception(key + ' not a column in current List.') Exception: Ticket id not a column in current List.

def upload_data_to_list(self):
    site = self._get_site('')
    new_list = site.List('My Test List')
    my_data = [
        {'Title': 'hello', 'Ticket id': 'Test' }
    ]
    new_list.UpdateListItems(data=my_data, kind='New')

robinostlund avatar Feb 28 '18 15:02 robinostlund

templateID is hard coded for the generic template's provided by Microsoft. I'm not sure if you can create a new Sharepoint site with a template that you yourself created. I'll have to look into that.

jasonrollins avatar Mar 02 '18 01:03 jasonrollins

Yes that would be awesome, i guees that it would be possible to get templateid from somewhere.

Gr8 work by the way.

Brg Robin

robinostlund avatar Mar 05 '18 09:03 robinostlund

Hey, I am stuck with a similar problem. Could you solve this one?

ShreyaRai18 avatar Apr 10 '20 12:04 ShreyaRai18

So I've add some Site functions to try to solve this issue: site.get_form_collection, site.get_list_templates, site.get_site_templates.

But. Alas, I don't think it can be done as far as I can see with my version of SharePoint (365). There seems to be a method GetCustomListTemplates, but I can't figure out how to get to it through the SOAP or REST API and I'm not sure you can. There seems to be a forum that suggests that this can't be done.

jasonrollins avatar Apr 11 '20 19:04 jasonrollins

I see, thanks for your explanation!

ShreyaRai18 avatar Apr 15 '20 11:04 ShreyaRai18