Count dates in a specific sharepoint list - InfoPath Dev
in

InfoPath Dev

Count dates in a specific sharepoint list

Last post 11-01-2011 06:10 AM by Michael Vasquez. 12 replies.
Page 1 of 1 (13 items)
Sort Posts: Previous Next
  • 10-26-2011 09:18 AM

    Count dates in a specific sharepoint list

    I have a Web form that submits multiple variables to a sharepoint list.  One of the variables is a simple date field called dDate, i.e., date submitted.  For now, lets ignore the creation date that is part of a sharepoint list.

    So, in this list, there will be multiple dates in the dDate variable in the sharepoint list.

     Now using Infopath, with rules, how do I get a count of dates for a certain date submitted.  For example, if several people submitted the form on 10/1/2011 and several on 10/2/2011, I need to know the count of how many forms were submitted on 10/1/2011.

    I have tried different ways and get no count.  I can count all the dates, which will give me a count of all the forms submitted for 10/1/2011 and 10/2/2011.

    I have also submitted this question a long time ago and got no answer.  May be this time I'll be lucky. 

     TIA.

    Mike

  • 10-26-2011 10:15 AM In reply to

    Re: Count dates in a specific sharepoint list

    I was able to get closer.  I have three dates 10/28/2011 in the list.  I was abe to run this rule in a test text box, count(xdXDocument:GetDOM("TestSharePoint Training")/dfs:myFields/dfs:dataFields/dfs:SharePoint_Training[substring-before(@Class_Date, " ") = xdDate:AddDays(xdDate:Today(), 2)]).  However, the interger 2 will change every day.  How can I get that to change?

     

    Mike V

  • 10-26-2011 10:30 AM In reply to

    Re: Count dates in a specific sharepoint list

    Hi - what exactly are you trying to do? I get that you need to count the number of forms for a specific date - but what is the logic for that date? That is - you say "the integer 2 will change every day" - can you help me better understand what you need to do?

    Hilary Stoupa

  • 10-26-2011 11:15 AM In reply to

    Re: Count dates in a specific sharepoint list

    I need to know the number of times a date is listed in a sharepoint list.  I want to get this number or count and put in into my InfoPath form.  Does this make better sense?  T

     he form is called a training request form and I am trying to get the available seats  for a specific date.  I want to know the number of dates in a specific date and return that number to infopath?

     

    Mike

  • 10-28-2011 11:46 AM In reply to

    Re: Count dates in a specific sharepoint list

    You should be able to do this with a count formula and a filter. I'm attaching a simple sample - save the file from the link, then right click and select design to open in design mode - from there you can preview.

    Hilary Stoupa

  • 10-31-2011 06:48 AM In reply to

    Re: Count dates in a specific sharepoint list

    It did not work.  Your example shows counting from one field in another group.  Both fields are in the Main datasourcem

    count(my:group1/my:group2[my:field2 = ../../my:field1]).

    I am trying to count from a secondary data source where the date equals the date in the main data sources.  For example when I tried this:

    count(/dfs:myFields/dfs:dataFields/dfs:SharePoint_Training/@Class_Date = my:SharePointTraining/my:dClassDate)

    I get an error, " Argument 1 must return a node-set."

     Is there something I need to add?

    Mike

  • 10-31-2011 07:02 AM In reply to

    Re: Count dates in a specific sharepoint list

    How's this:

     count(/dfs:myFields/dfs:dataFields/dfs:SharePoint_Training[@Class_Date = xdXDocument:get-DOM()/my:SharePointTraining/my:dClassDate])

    Jimmy Rishe / Software Developer / Microsoft MVP
    Qdabra Software
  • 10-31-2011 09:08 AM In reply to

    Re: Count dates in a specific sharepoint list

    Jimmy, looking at your function, it seems it should work but I get a value of 0.  I wonder if it would be a permission issue between the SharePoint Server and the database server.  Everything I have tried seems to fail.  I am thinking about creating a Web service to get the count for me. 

    I had another situation that a specific value of a SharePoint list did not return anything.  I created a Web service to access this SharePoint list and it returned the correct value.

    The SharePoint database is on another server.

     Mike

    Jimmy:

    How's this:

     count(/dfs:myFields/dfs:dataFields/dfs:SharePoint_Training[@Class_Date = xdXDocument:get-DOM()/my:SharePointTraining/my:dClassDate])

  • 10-31-2011 09:12 AM In reply to

    Re: Count dates in a specific sharepoint list

    Drag your data source in InfoPath that is connected to your SharePoint list onto your form temporarily so you can see if you are getting any data.

    Hilary Stoupa

  • 10-31-2011 09:39 AM In reply to

    Re: Count dates in a specific sharepoint list

    Hilary, I dragged the datasource, SharePoint Training(Secondary), Class_Date to the InfoPath form and I was able to view the data in InfoPath and also in the Web Form.  Strange that the InfoPath form sorts the list descending and the Web form is sorted ascending.  Since I know that I can see the data from the SharePoint list, how do I count the dates that equal the date on the main datasource (dClassDate).

     I just noticed that dClassDate is a data type date and the secondary datasource is a string.  Would that matter?

     Mike

  • 10-31-2011 09:49 AM In reply to

    Re: Count dates in a specific sharepoint list

    What does the text in the secondary data source look like?

    dClassDate, as a date, will store its data like this:

    2011-10-31T10:18:32

    What does the SharePoint data look like? You may need to use some string functions in the formula to make the two fields have the same format - if ShP is returning:

    2011-10-31 12:00 am

    for example, you'll never get a match.

    Hilary Stoupa

  • 10-31-2011 11:11 AM In reply to

    Re: Count dates in a specific sharepoint list

    Hilary's probably right.  Dates from SharePoint usually seem to be in that strange format with a space in the middle.  Could you give this a try?

    count(/dfs:myFields/dfs:dataFields/dfs:SharePoint_Training[substring(@Class_Date, 1, 10) = substring(xdXDocument:get-DOM()/my:SharePointTraining/my:dClassDate, 1, 10)])

    Jimmy Rishe / Software Developer / Microsoft MVP
    Qdabra Software
  • 11-01-2011 06:10 AM In reply to

    Re: Count dates in a specific sharepoint list

    Hilary was right, I used the following: 10 - count(xdXDocument:GetDOM("SharePoint Training")/dfs:myFields/dfs:dataFields/dfs:SharePoint_Training/@Class_Date[starts-with(., xdXDocument:get-DOM()/my:SharePointTraining/my:dClassDate)])

     Thanks again Hilary and all who contributed.

     Mike V

Page 1 of 1 (13 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.