This project has moved and is read-only. For the latest updates, please go here.

query on updateListItems

Apr 13, 2010 at 12:55 PM


I went through the "updateListItems" documentation and have a question about the same.

My requirement is: whenever a list item/record has been added or modified, I need to run some validation on the column values and modify them if necessary.

Each item/record contains date columns. After a record has been added or modified, I am doing date diff on those columns using SharePoint calculated column; but the problem is it does not ignore non business hours such as weekends and nights. Business hours are 9 AM - 6 PM.  So I am wondering, if I can achieve this by using Marc's jQuery library.

If I can put the logic in "updateListItems" and call it whenever a list item/record is saved, I think it works for me. Please share your ideas.

- Thanks

Apr 13, 2010 at 1:14 PM

I think that this can work. SharePoint also "understands" business hours, so you may be able to get at those settings with the Web Services. That would be best so that you aren't hard-wiring anything.

Another approach would be to customize the form and using the date templates I talk about here:


Apr 13, 2010 at 2:48 PM

Thank you Marc. I cannot use the templates due to restrictions in my SharePoint site. Only place I can put some code is CEWP. I am already using the SP Services in my CEWP. So I think the best possible way for me to solve this is to go with "updateListItems".

Do I have to create a "preSave" function and update the column values? Sample code would help me a lot. I already looked at your documentation.


- Thanks


Apr 13, 2010 at 5:40 PM

Take a look at this blog post of mine.  It might help you get started:

Obviously you can use jQuery and/or plain JavaScript in the PreSaveAction (as long as you have the jQuery library referenced).