0

Is there any way to change the default Start Time (just the date) for New Item's to the date that the user clicked on? I have tried setting the start time to (none) and to Today's Date and both of them result in pre-populating it with todays date. We will be scheduling items in the future so when a user clicks on a date in the future, I wanted the new item to default to the date the user just clicked on to add the new item. Is that possible?

My bad..... I wanted the default for a new item to be an all day event so I added the info below to a text file and it is working but apparently it overrides the default of the start date. I guess I have a choice of either getting the default to be all day or the default start time to be the date the user chose but not both! But at least now I know why it's not defaulting to the date the user clicks on.

<script src="/is/technologyservices/applicationservices/Documents/jquery-2.1.1.min.js" type="text/javascript"></script>
if (!$('span[title=All Day Event] > input').attr("checked")) { $('span[title=All Day Event] > input').click(); } //hide check-box //$('tr:has(span[title=All Day Event])').not('tr:has(tr)').hide();
  • Your question is unclear, please rephrase. – ssdar Feb 6 '15 at 17:44
0

I'm guessing what you want if the user to change the "default Start Time" based on a New Item's Start Time selection. You may want to create an event receiver that triggers on a NewItemAdded. The logic would browse out to the specific list and update the default value. This is pseudo code, but should be mostly correct.

public override void ItemAdded(SPItemEventProperties properties)
        {
            //base.ItemAdded(properties);
            using (SPWeb web = properties.OpenWeb())
            {
                try
                {
                    SPList list = web.Lists["SPList"];
                    DateTime starttime = properties.Item["Start Time"];
                    list.Fields["Start Time"].DefaultValue = starttime;
                    list.Update();
                }
                catch (Exception ex)
                {
                    throw ex;
                }
            }
        }

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.