none
How to make Add new Item in custom list dependable on the days of week?? RRS feed

  • Question

  • Hii Everyone,

    i''ll try to explain my problem to you.I have attached screen shot below of my situation,i have made a Custom list in PWA site ,I want this Add new item,to bedisable on certain days of week for ex user should not be able to add new item in custom list on weekend(sat,sun) or any other days whatever is the requirement.if anyone has any idea,please letme know,any help will be greatlt appreciated

    Friday, January 20, 2012 5:54 AM

All replies

  • Hi Anuj,

    You can write a small JavaScript  which you can inject by using a Content Editor web part on the Allitems.aspx and other ASPX Pages related to this list:

    <script language="javascript">     _spBodyOnLoadFunctionNames.push("HideNewControls");      function HideNewControls() {     $('#Ribbon.ListItem.New.NewListItem - Large').hide();     $('#Ribbon.ListItem.New.NewFolder - Large').hide();     $('#idHomePageNewLink').hide();     $('#Ribbon.List.ViewFormat.Datasheet - Large').hide() } </script> 
    
    I did a similar stuff using JQuery to hide the options. Try to view the pafe source in IE developer tool by pressing the F12 & check the control ID, based on the you can modify the JScript & use it on load with check system datetime etc.

    hope that helps.
    Thanks, Amit Khare |EPM Consultant| Blog: http://amitkhare82.blogspot.com http://www.linkedin.com/in/amitkhare82
    Friday, January 20, 2012 6:44 AM
  • Hii amit,

    thanx for your response,i was trying to simply use your script to disable Add new item without applying any logic to check for Days of the week,but it was not working.May be i am not able to get the correct Control ID of Add new item.

    Control ID which i am getting through viewing the source code of the page is  Similar to original i.e Add new item.

    I AM NOT SURE ABOUT THIS CONTROL ID,CAN YOU PLEASE HELP ME IN THAT

    THANKS


    • Edited by anuj astro Friday, January 20, 2012 7:15 AM
    Friday, January 20, 2012 7:11 AM
  • Hi Anuj,

    I just tested on my machine & got the ID as "idHomePageNewItem", added an attribute as Display(CSS) as None, I was able to get that.


    Thanks, Amit Khare |EPM Consultant| Blog: http://amitkhare82.blogspot.com http://www.linkedin.com/in/amitkhare82
    Friday, January 20, 2012 7:29 AM
  • Hi amit,

    this is the jquery that i am placing in the Content editor webpart.Is this correct??Please let me know?

     

    <script type="text/javascript">
    function myHref(){

    document.getElementById('idHomePageNewItem').style.display = 'none';


         
    }
    </script>

    Friday, January 20, 2012 7:35 AM