Filtering lists by count since formulas to check logic on multiple line items isn't possible?
I have an InfoPath form library where the primary purpose is for users to manage a document through a series of approvals. Once the document reaches a final stage, it hangs out in the library for 1 - 3 years. The issue is the that approved documents are hindering what users really need to focus on, which are the non-finished items. I cannot filter by the completed status only...since then the user would have no indication that the review of that document number were finally complete. Ideally I'd like to be able to use a COUNTIF formula to say "COUNTIF SOP Number = SOP Number" to find all the occurrences of that item, but since that doesn't seem possible. Could I filter by COUNT? For example, "if Count = 1 and Status contains Approved then hide / filter" this record out of the list.
April 23rd, 2012 1:33pm

Hi stephaniettt, As far as I know, it is difficult to achieve it with filter your count column. So, I suggest you create a column with number. Then you can use object module as the following code, put every count of group in your number column. SPSite site = new SPSite("http://jack-7716f30e37:2012/personal/Test/"); using (SPWeb Web = site.OpenWeb()) { site.AllowUnsafeUpdates = true; Web.AllowUnsafeUpdates = true; Web.AllowUnsafeUpdates = true; SPList list = Web.Lists["YourList"]; foreach (SPListItem item in list.Items) { SPQuery query = new SPQuery(); query.Query = " <Where><Eq><FieldRef Name='Title' /><Value Type='Text'>" + item["Title"] + "</Value></Eq></Where>"; SPListItemCollection items = list.GetItems(query); if (items.Count > 1) { item["YourColumnNumber"] = items.Count; item.Update(); } } } Then you can filter your document library with your status and your column with number. Thanks, Jack
Free Windows Admin Tool Kit Click here and download it now
April 27th, 2012 4:29am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics