Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / General MS InfoPath Questions / November 2006

Tip: Looking for answers? Try searching our database.

Querying Sharepoint for Library item count

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
bshea - 09 Nov 2006 22:46 GMT
I have a desire to query Sharepoint from an Infopath form to determine the
number of items currently in a form library.  

I have created a "request data" data connection called "Count New" which
points to my site, the the "New Requests" library, and gets the ID field.  It
is setup to automatically retrieve data when form is opened.

From this point I had hoped to use:
function CountNewRequests()
{
    // Counts the current New Requests
    var inNewCount;
    var obNewList;
   
    // Get data from Data Connection
    obNewList = XDocument.DataAdapters("Count New").QueryAdapater;
    inNewCount = obNewList.Count();
   
    return inNewCount;
}

When I do, the obNewList errors out with an "Object Null or Undefined"
message.  I believe my next line is not correct either but I can't test that
until I get the correct return from my query.

Any thoughts on the error, or better on how to get the count of items in my
sharepoint library?

Thanks for any pointers you can give!
S.Y.M. Wong-A-Ton - 12 Nov 2006 03:42 GMT
Using a simple count() on a repeating field from the data connection should
do the trick from within a formula. Any particular reason why you want to use
code?

But if you insist on using code, try using XDocument.DataObject["Count New"]
instead of XDocument.DataAdapters("Count New").QueryAdapater. Then use a
selectNodes on XDocument.DataObject["Count New"].DOM to retrieve all of one
of the repeating nodes (e.g. an ID field) in the data connection, and then
use the "length" property on the object returned by selectNodes to get the
amount of items. Note: The amount might be limited by the limit set on the
amount of items shown through the Default View of the library in SharePoint.
---
S.Y.M. Wong-A-Ton


> I have a desire to query Sharepoint from an Infopath form to determine the
> number of items currently in a form library.  
[quoted text clipped - 25 lines]
>
> Thanks for any pointers you can give!
bshea - 14 Nov 2006 17:31 GMT
I'm not set on using code, but the overall intent was to have this form count
the number of submissions in the library of new requests so it could alert
the person submitting a new request of "queue depth".  I'm essentially
counting the New and Accepted requests, then generating a ballpark SLA for
start time based on existing queue depth, delevery time, and SLA.  

I'll play around with both suggestions though and see what I can get to
work, many thanks for hte pointers and I'll post back with the final answer.

> Using a simple count() on a repeating field from the data connection should
> do the trick from within a formula. Any particular reason why you want to use
[quoted text clipped - 40 lines]
> >
> > Thanks for any pointers you can give!
bshea - 14 Nov 2006 17:57 GMT
Still failing.  Object null again.  This time on the DataObject line.  Going
to scrap this function as it clear doesn't work as I need / want it too.

Thanks anyway.

> I'm not set on using code, but the overall intent was to have this form count
> the number of submissions in the library of new requests so it could alert
[quoted text clipped - 49 lines]
> > >
> > > Thanks for any pointers you can give!
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.