2

I'm working on a Sharepoint hosted App, that accesses List Data from the Hostweb as I outlined here: EventListener for List changes in Sharepoint Hosted app

I want to use the GetListItemChangesSinceToken method as mentioned by Sean in the answer of the question I linked above.

Now, it seems that I get the first request working and the raw answer to the POST looks quite good (sending a token as null value gives me a fresh token and a lot of list data).

But somehow the executeQueryAsync() method always calls the errorHandler method and returns this error message: Unexpected response from server. Even though the POST answer looks fine.

So here is my code so far:

    // get all the needed contexts and web for accessing the hostweb 
    // (this part is definitely working)
    var hostweburl = decodeURIComponent(getQueryStringParameter("SPHostUrl"));    
    var clientContext = new SP.ClientContext.get_current();
    var hostContext = new SP.AppContextSite(clientContext, hostweburl);
    var web = hostContext.get_web();
    var list = web.get_lists().getByTitle("My List Title");

    // create Query
    var cliQuery = new SP.ChangeLogItemQuery();
    cliQuery.set_changeToken(null);

    // apply getListItemChangesSinceToken to list and execute query
    list.getListItemChangesSinceToken(cliQuery);
    clientContext.executeQueryAsync(successHandler, errorHandler);

Am I doing something obviously wrong?

Thanks in advance!
Ben

  • If the idea is to get the last changes in the list, then it could be easier to return items with a modified date greater than X. I did some tests in the past with GetListItemChangesSinceToken and it was difficult to use.... – AymKdn Feb 11 '16 at 7:20
  • Hey, thanks for your answer. I agree with the difficulty of GetListItemChangesSinceToken. I threw that away. The solution I'm using now is a query, that returns all List Items where the Modified field time value is bigger than the time of the last query with an interval of queries. – bge Feb 19 '16 at 10:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.