jasonrollins / shareplum

Pythonic SharePoint
MIT License
179 stars 96 forks source link

How to query more than two columns in where clause #115

Open pm620wh opened 4 years ago

pm620wh commented 4 years ago

Hi

I need to query a SharePoint list in the same way that the SharePoint web interface permits i.e. where you enter a value in the search field and the search looks all text columns in the list automatically. To attempt to mimic this behaviour I've tried building my list of fields in the query using a loop, creating each tuple and adding it to the list and finally adding it to the dictionary but as soon as I add more than two field names I get an error 'shareplum.errors.ShareplumRequestError: Shareplum HTTP Failed: 500 Server Error: Internal Server Error for url: xxxxx/_vti_bin/lists.asmx' (where xxxxx obscures the real internal URL).

I resorted to a test query that only uses three columns just to see if there was a ceiling for the number of fields permitted in the search condition (my real code was trying to build a list equal to about 30 text fields). Here is my approach for testing:

listQuery = ['Or'] listQuery.append(('Contains', 'Title of proposal', 'underwrite')) listQuery.append(('Contains', 'Vendor', 'underwrite')) listQuery.append(('Contains', 'Classification', 'underwrite'))

query = {'Where': listQuery} list_data = sp_list.GetListItems(query=query)

Is the library limited for the number of criteria allowed in the conditional statement?

Thanks for any help you can provide

jasonrollins commented 3 years ago

It's not limited intentionally. The Query code is fairly hacky so I don't doubt that it could stumble on complex queries. You can use last sent to see if the library is building the query correctly.