views:

295

answers:

3

Yet another question.

So now my EventReceiver and its logic is working just fine. Except for one thing.

Basically it queries the whole list through CAML queries, and then passes the result to a DataTable object, and later on to a DataRow object...

Like all, in test environment, it works perfectly, but in production...

What happens is that the column I need updated gets update but not shown immediately. The item column receives the value I want, but it doesn't show at first refresh, you have to refresh the page again, then it appears...

The only difference is that in teste env. my list has like, 200 records, and in production, it has almost 5000 records.

Some questions:

  • Is there a way to define how many records you want? In CAML or in the DataTable object? Something like "SELECT TOP 100 ... "
  • If not, is there a way to make the refresh process stop and wait for the code execution?

Some Info:

  • It's WSS 3.0, and the event I'm intercepting is ItemAdded, which explains the refresh not waiting for my code.

Oh and considering changing to the ItemAdding event would be a little bit of a problem, because I need to capture the ID of the record, which is not yet available in ItemAdding because the list item has not been committed to the database yet.

Thanks in advance.

+1  A: 

Similar question and answer here. You should be able to use the Rowlimit property of SPQuery.

Temple
+2  A: 

The problem here was the "GetDataTable()" method. When I ran the CAML query and filled a datatable with the results, it'd lose the order by modifier. But if I get the results with a SPListItemCollection object, it returns the row exactly how I wanted.

As seen in another post... "This is a nasty issue".

Felipe Fiali
+2  A: 

After searching a lot, I ended up moving my code to the ItemAdding event, which is synchronous and will finish executing before SharePoint loads its page.

Even after I limited the result rows to 5, it would still load the page without the value I wanted to show.


Also, if you are considering capturing the value from a field that uses calculated value, and has a formula in it, be careful, because at least in my example, SharePoint didn't resolve the formula by event execution, so the field with the calculated value would always return null.

Felipe Fiali