does anyone know how to use the SPListItemCollection ReorderItems method? I cannot seem to find sufficent documentation on this method. What I want to do is order the list in decending order by date. I am not sure what the required values are, http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.splistitemcollection.reorderitems.aspx, thanks for all the help.
the link you stated gives you all the information you need.
You can get more info from refactoring:
Microsoft.SharePoint.ApplicationPages.dll in the ReorderPage class' BtnSave_Click event.
Probably, the issue you are having has to do with the fact that the list in question needs the allow ordering set to true. google for this, or check this url if still working.
Related
Firstly, I am amazed at how simple and performant ServiceStack is. Can't believe I've gone without sing this for so long.
I'm especially loving the AutoQuery and Admin feature, but for the life of me, I'm struggling to find documentation on how to extend the response. What I am trying to do is provide a hyperlink in a response to enable navigation right from a row that is returned.
For example, if a list of records are returned from /records, and the primary key (Id field) could actually be a link (ie ABC123) that is its own DTO.
I've noticed the AutoQueryMetadataFeature, so suspect this provides some hints, but very new to the whole solution so any pointers would be very much appreciated.
Cheers
Craig
I ran across a problem for which I found no documented solution, but inadvertently found the solution myself. So I wanted to document this here for others who may encounter the same problem.
I was using a CAML query within SPServices to retrieve list items, then referencing "ows_{fieldname}" as usual to retrieve the field value for each list item. The field value was reported as "undefined" for all items. I quintuple-checked that I was specifying the proper name of the field and that my query was properly constructed.
I eventually discovered that the fields I was trying to reference were not displayed in the default view of the list. As soon as I changed the list properties to include the fields in the default view, the proper field values were returned within my javascript.
I don't know how much of Sharepoint's underpinnings work, but I was very surprised at my finding because it implies that the SPServices GetListItems method gets its data from the list's default view, not the actual underlying list. I realize I could be wrong in this interpretation, but I imagine others could run into this same problem.
The default, although unreliable, way GetListItems works is that it's suppose to returns all fields displayed on the default list view if you don't specify ViewFields on input. This is unreliable. Although you got it working - now - someone could come along later and change the default view thus breaking your sweet customization. Bummer. :)
I suggest always listing the ViewFields you are interested in on the GetListItems method. This ensures that your will get them if they are set. That's right. You could still get rows with an undefined field. This happens mostly on fields of type Lookup that are not set on a row.
Hope this helps you understand what is going on. Over the years I have created my own wrappers around SPServices to ensure I get back a reference to all fields requested, even if they are not in the response by Sharepoint.
When using SPServices' GetListItems method, be sure that any fields that you reference from the list are included in the list's default view, otherwise an undefined value will be returned.
We have the sharepoint 2010 environment with Document ID's enabled.
Given (part of) a Doc ID, we want to programmatically retrieve the document(s) matching that ID. The problem seems to be that this column is rather special, in that it might need special handling.
Using an SPSiteDataQuery, fetching the _dlc_DocId field as part of the viewfields works fine. However, including it as part of the where query never results in any documents being fetched.
Using the Search API has gotten us nowhere at all.
Has anyone pulled this off, or any suggestions on how to tackle this problem?
[Update] Turns out we were fooled by subtle errors in the XML and bad debugging misinterpretations. This stuff just works fine.
I don't normally contribute to these sorts of things because cleverer people than I always get there before me, but as this is an old one with no proper answer I think I'll add my thoughts for those who find this page.
I was struggling with this but after a little digging around and learning a bit of Caml I got this working.
I am using the SharePoint Client Object Model against SharePoint 2010 and Office365 beta.
Start off your query by looking at the all list items query:
Microsoft.SharePoint.Client.CamlQuery.CreateAllItemsQuery().ViewXml
"<View Scope=\"RecursiveAll\">\r\n <Query>\r\n </Query>\r\n</View>"
Stick a where child inside the query
Then add in
<Eq><FieldRef Name="_dlc_DocId" /><Value Type="Text">MDXC2KE55ASN-3-80</Value></Eq>
replacing MDXC2KE55ASN-3-80 with the doc ID you are looking for inside the where.
Also don't forget you might want to make use of these too:
<ViewFields><FieldRef Name="_dlc_DocId" /></ViewFields>
<RowLimit>1</RowLimit>
Then use List.GetItems() method to bring back the ListItemCollection.
Just in case nobody comes with a slick solutions from the depths of the Sharepoint infrastructure:
What would Google Do?
Slice is, Dice it and dump it in a reverse index.
Solr and Lucene offer supreme tools for this. The idea is to cut the DocId's in small pieces and add the location of the document to the bucket for that piece.
Say We have "A real nice document" with Id ABCD123. You would add it to the buckets
ABCD, BCD1, CD12, D123
When searching for a partial ID (+ other data like dates, types, ...) you (well the search engine) creates the union of the buckets + applies additonal constraints.
To make this happen you need to write a spider for the sharepoint server and a routine which makes a record of data elements to be indexed.
Put a nice REST interface in frnt of it (actually SOLR already has that), integrate it in the main sharepoint server, and nobody needs to know there is something else running behind it.
These products can also incrementally update the indexes, so they can be kept up to date.
you could use the following to get the Document ID.
SPFile file = MethodToUploadFileToServer(web, filepath);
SPListItem item = file.Item;
string DocID = item.Properties["_dlc_DocId"].ToString();
I am doing a workflow for a document library. I put a OnWorkflowItemChanged, and I want to get the value of the column which is changed. I use the workflowProperties.Item["name"] and use the afterProperties. But when I use the workflowProperties.Item["column name"], I still got the original value. When I use the afterProperties, it's NULL.
Then I make another workflow that is the same as above for a list. I can use the workflowProperties.Item["column name"] to get the new value in OnWorkflowItemChanged.
Has anyone come across this problem before? Can you give me some help?
The question seems to mix up Item with ExtendedProperties. As to why a difference is seen on a List/Document Lib, it might have something to do with versionining or perhaps the internal serialization is different. Anyway, some of my experience is outline below. I hope it may be of use:
Use the GUID (as a Guid object, not a string) to access the Before / After ExtendedProperties field. Using the Display Name in the ExtendedProperties will not work. The documentation on it is wrong. You can use SPList.Fields to go from Display Name to Column ID (Guid).
I bind all "Before" to MyWhatever_PreviousProperties and all "After" to MyWhatever_Properties, only accessing MyWhatever_[Previous]Properties after the appropriate event(s)).
I'm trying to create a feature that both creates a list template and an instance of that list (using the <ListTemplate> and <ListInstance> elements. I would like for content approval to be turned on by default. According to the docs on ListTemplate, setting the EnableModeration attribute to TRUE should do it. However, when I try to install the solution, I get the following error:
The 'EnableModeration' attribute is
invalid - The value 'TRUE' is invalid
according to its datatype
'http://schemas.microsoft.com/sharepoint/:TrueFalseMixed'
- The Enumeration constraint failed.
A bit more searching reveals that the value accepted is actually "True", not "TRUE". That installs fine, but it seems to have no effect when the list is created - it still doesn't require content approval. Any idea what I'm doing wrong?
Edit: If anyone could even confirm for me if they've seen "True" or "TRUE" work before, that would at least narrow down my search.
Update: I've found that I can enable content approval using code in a feature receiver:
list.EnableModeration = true;
list.Update();
That's a bit of a hack, so it'd still be nice to be able to do this through the XML instead.
I ended up just using the feature receiver approach, since I just needed to move on. However, I later found that the List element used for defining your list schema also has ModeratedList and ModerationType properties that look like they probably have something to do with this. So if anyone else is having the same problem, I would recommend giving those a shot.
Does your custom list have a field of type 'ModStat' on it?
ModStat Specifies Content Approval
status. Corresponds to the
SPFieldModStat class and to the
ModStat field type that is specified
on the Field element. Value = 23.
from the SPFieldType Enumeration docs
I set ModeratedList="TRUE" ModerationType="TRUE" for List element and EnableModerate="True" for ListTemplate element . It works for me. Well it does not matter to use TRUE or True both are same.
You only have to set ModeratedList="TRUE" for List element and EnableModerate="True" for ListTemplate element. I just checked that and work fine for me. But this only will be affected for new list instances.
I had similar question - where to enable versioning and moderation from code.
In ListInstance, go to <ListTemplate> and set following attributes:
VersioningEnabled="TRUE" for versioning and EnableModeration="True" for automatic moderation.
Link: http://msdn.microsoft.com/en-us/library/ms462947.aspx