none
Automatically Populating Column in SharePoint 2007 View With Data From InfoPath 2010 Form

    Question

  • Hello everyone,

    I'm needing a little SharePoint/InfoPath help, please.  My situation is as follows:

    I'm working in SharePoint Server 2007 and I currently have 8 columns in the forms library view - Type, Name (linked to document with edit menu), Exception End Date, Modified, Modified By, Checked Out To, Check In Comment, and Version.

    I have an InfoPath 2010 form in that library.  On that form is a box for an exception end date (among other things.)

    In Exception End Date column in the library view, I need it to show the exception end date that's specified in the form.  I also need to color it red when the end date has passed.  Can this be done?  If so, how?

     

    Please and thank you!

    jeudi 23 février 2012 19:59

Réponses

  • Hi,

    Open the list view with SharePoint designer to apply conditional formating based on the dates of the columns.

    Regards

    Osvaldo


    Osvaldo Sousa http://inoblog.com

    vendredi 24 février 2012 10:33
  • Hi,

    I have something to confirm.

    1. Can you see the exception end date field as a column in the form library? If no, you need to republish the form template and add the exception end date field as the screenshot below.

      After republishing the template, in the form library you will find the field display as a column. And make sure the format of the date is the same as screenshot below.

                              

    2. The type of exception end date field in form template is Date Picker or Date and Time picker? (The code above is for Date Picker.)

    3. Can you visit internet on your machine? The JS package in the code need to be called via internet. Also you can download JS package from here (http://docs.jquery.com/Downloading_jQuery) and upload it to your site, and change the visit path of JS package in code.

    Thanks.

      


    Emir Liu

    TechNet Community Support




    jeudi 1 mars 2012 10:26

Toutes les réponses

  • Hi,

    We can achieve this via JavaScript.

    First we need to republish form template with exception end date field available as form field.

    Then, after republish the form template, we can find the date column in form library. Open the form library view, add a Content Edit Web Part to the bottom of the page, and copy the code below into Source Editor of it.
    <script type="text/javascript" src="http://code.jquery.com/jquery-latest.js"></script>
    <script type="text/javascript">
       $(document).ready(function(){
            var date1;
            var currTime=new Date();
            $(".ms-vb2").each(function(){
                 if($(this).text().substring(4,5)=="-" && $(this).text().substring(7,8)=="-")
                {
                      var formTime=$(this).text();
                      var formMonth=formTime.substring(5,7);
                      var formDate=formTime.substring(8,10);
                      var formYear=formTime.substring(0,4);
                      var fTime=formMonth+"/"+formDate+"/"+formYear;
                      date1=new Date(fTime);
                      if(date1<currTime.setHours(0,0,0,0))
                     {
                            $(this).css({background: 'red'});
                     }
               }
         });
       });
    </script>

    Thanks.


    Emir Liu

    TechNet Community Support

    vendredi 24 février 2012 09:44
  • Hi,

    Open the list view with SharePoint designer to apply conditional formating based on the dates of the columns.

    Regards

    Osvaldo


    Osvaldo Sousa http://inoblog.com

    vendredi 24 février 2012 10:33
  • Hi,

    Thanks for the suggestions.  I don't have SharePoint Designer so I opted to try the web part route first.  (Will try Designer later.)  Not too sure about the republishing part, though.  The exception end date is already a form field (date) so I skipped the republishing.  Hopefully, that's not an issue.  Otherwise, I followed the instructions, copied the code over to the web part, but nothing happened.  In fact, when I click Apply or OK, the page kind of "hamsters" there before asking me to log in and then ultimately displaying a message saying IE could not display the web page.  (Without the code, I've been able to make any changes and not ever encountered this problem.)  So ... is there a setting on the server side that needs to be "on" or am I missing something in the steps?  (I'm on SharePoint Server 2007, InfoPath 2010, IE9, Win7.)

    Please and thank you!

    mercredi 29 février 2012 16:41
  • Hi,

    I have something to confirm.

    1. Can you see the exception end date field as a column in the form library? If no, you need to republish the form template and add the exception end date field as the screenshot below.

      After republishing the template, in the form library you will find the field display as a column. And make sure the format of the date is the same as screenshot below.

                              

    2. The type of exception end date field in form template is Date Picker or Date and Time picker? (The code above is for Date Picker.)

    3. Can you visit internet on your machine? The JS package in the code need to be called via internet. Also you can download JS package from here (http://docs.jquery.com/Downloading_jQuery) and upload it to your site, and change the visit path of JS package in code.

    Thanks.

      


    Emir Liu

    TechNet Community Support




    jeudi 1 mars 2012 10:26
  • Thanks for the clarification, Emir.  I republished the form, this time with the exception end date column marked to show in the view.  That part works.  I've tested it with 3 different forms and it shows the the end date without fail.  But I still can't get the code to work.  I pasted it in the source editor in the web part like you said.  But it might be a problem on my end.  Clicking Apply or OK just makes it hamster and then it asks me to log in but, after awhile, IE9 returns the message that it can't show the page.  After that, nothing works.  Even clicking Exit Edit Mode causes it to hamster along with the unavoidable message that IE can't show the page.  I just end up having to close the browser and reopen it.  I'll check with our server admins to see what's going on and see if uploading the JS file to the server will make a difference.  (Yes, I am connected to the Internet from the machine.)

    BTW, Osvaldo, I did install SharePoint Designer 2007 but did not see the conditional formatting option available.

    Please and thank you!

    jeudi 1 mars 2012 16:56
  • Just a quick update.  I've got it working.  Couldn't get the JS to work but did a workaround using Osvaldo's suggestion.  (I finally found the conditional formatting after converting to data view - important missing link there.  Hehehe ...)  Thanks again, Emir and Osvaldo!
    vendredi 2 mars 2012 15:04