mmwheeler

Filtering and Limiting Date Pickers on Nintex Forms

 Computer, Sharepoint, Software  Comments Off on Filtering and Limiting Date Pickers on Nintex Forms
Mar 252019
 
Share

Had a project to create a service scheduling list. Certain services are only available during specific hours and specific days. The trick was to filter the date picker in relation to the service selected via Nintex javascript.

All of the code below goes into the Custom Javascript section of your form.

This first bit of code filters the available hours from the time part of the date picker.

NWF$("select[name$='Hours'] option").each(function(){
     if(NWF$(this).val().match(/^(([1-9]|12) AM)|(([5-9]|1[0-1]) PM)/g)) {
          NWF$(this).remove();
     }
});

The rest of the code filters the date picker days based on the service selected.

NWF.FormFiller.Events.RegisterAfterReady(function () {  
    NWF$('#' + Service).change(function(evt){
        switch(evt.target.value){
            case 'Oil Change' :
            NWF$('#' + dateCtrl).datepicker('option',{
            beforeShowDay: function(currDate){
                   if(currDate.getDay() == 1 )
                         return [true,""];
                   return [false,""];
     }
     })
                break;
 
         }
    });
    NWF$('#' + Service).change(function(evt){
        switch(evt.target.value){
            case 'Brake Repair' :
            NWF$('#' + dateCtrl).datepicker('option',{
            beforeShowDay: function(currDate){
                   if(currDate.getDay() == 5 )
                         return [true,""];
                   return [false,""];
     }
     })
                break;
 
         }
    });
 
    NWF$('#' + Service).change(function(evt){
        switch(evt.target.value){
            case 'Tire Repair' :
            NWF$('#' + dateCtrl).datepicker('option',{
            beforeShowDay: function(currDate){
                   if(currDate.getDay() == 2 || currDate.getDay() == 3 || currDate.getDay() == 4 )
                         return [true,""];
                   return [false,""];
     }
     })
                break;
 
         }
    });

Enforce Unique Values was also enabled on the Appointment Time to restrict duplicate appointments.

 Posted by at 10:21 pm  Tagged with:

SharePoint 2016 Copy Shortcut Context Menu

 Computer, Sharepoint, Software  Comments Off on SharePoint 2016 Copy Shortcut Context Menu
Dec 082018
 
Share

After an upgrade from SP2013 to SP2016, the ability to right-click on a document and copying a shortcut was removed. This is because the IE right-click menu has been replaced by a context sensitive menu that does not include an option for copying a shortcut to the document. The following code will put that back…

// Add "Copy Shortcut" option to document context menu
$(document).ready( function () {
// Use setInterval to run this every 100ms
setInterval(
function () {
// Check if a "Copy shortcut" button is already displayed
var n = $('#copyShortcutMenuItem').length;
var m = $('.ms-core-menu-list').length;
if (n == 0 && m > 0) {
var firstMenuItem = $('li.ms-core-menu-item:first-of-type');
var hlink = firstMenuItem.parent().parent().parent().find('div:first-of-type').attr('Url');
if (hlink.startsWith('/')) {
hlink = "https://" + window.location.host + hlink; 
}
// Build the HTML of the new list item
var newHtml = '

 	
  • Copy Shortcut
  • '; // Insert the list item $(newHtml).insertBefore(firstMenuItem); } }, 100 ); }); // Set the clipboard and hide the menu function CopyShortcutClick(t) { window.clipboardData.setData('Text', t); $('.ms-core-menu-list').parent().hide(); }

    Save this as CopyShortCut.js and put it in your root Site Assets library. Also download the latest JQUERY. Add the following to the <Head> of your master page.

    
    
     Posted by at 7:51 am