1

I need to inform client to set All Day Event to True depending on another column value. Example if column Leave Type is Whole Day Leave, then All Day event must be Yes, that is, user must tick it. If he forgets the form will not be processed but the alert comes up to adjust or Leave Type or tick the All Day Event.

Any ideas?

1

You can add preSaveAction JavaScript function to the list form which will execute the logic before the Save operation.

This method more helpful especially this kind of cascading field validations.

Here is an example how it looks

<script type="text/javascript">
function PreSaveAction()
{
    var status = $('input[title="Status"]').val();
    if(status == "In Progress") {
        $( "input[id*='AllDayEventField']" ).prop("checked",true);
    }
}
</script>

You can add a script editor web part to the list form and add the above script. I have added jQuery library from my master page.

How to: use preSaveAction method

Alternate Idea for your requirement

You can also add a javascript value change event to your dropdown and check the "All Day Event" flag set to Checked. You can refer the following example script to achieve this.

<script type="text/javascript">
$(document).ready(function(){
   $("#dropdownFieldId").change(function(){
          if($(this).val() == "abc") {
                $( "input[id*='AllDayEventField']" ).prop("checked",true);
          }
   });
});
</script>
  • Thanks Venkat, tried the first script but did not work, in fact form did not work. Do I need to install something on the masterpage? if so I do not have such rights. To test what I did I changed title="Status" to title="Category" and status == "In Progress" to status == "Meeting" to try default fields. NO SUCCESS, the form does not even work.. Tried alternative idea. changed #dropdownFieldId to Category and abc to Meeting . Still form worked but no success. What you suggested is to modify the field. Can it be done via list validation? Just notify user to tick the box ? – Aaron Cauchi Jul 5 '17 at 5:02
  • Do yu have the jQuery library reference added? I have tested and working on my end. – Venkat Konjeti Jul 5 '17 at 15:17
  • I do not think so, where should it reside? Note that I have administration right only to my subsite (intranet) and have limited access. Still can via SharePoint Designer and sub site back-end put files there. So any assistance how I can go around the installation and refer code to the residing files will be of great help. – Aaron Cauchi Jul 9 '17 at 5:15
  • Add this line of code <script src="https://code.jquery.com/jquery-3.2.1.min.js" integrity="sha256-hwg4gsxgFZhOsEEamdOYGBf13FyQuiTwlAQgxVSNgt4=" crossorigin="anonymous"></script> before the above javascript. – Venkat Konjeti Jul 10 '17 at 22:23

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.