Resource management: Now compatible with DFFS

Change log
July 13, 2015
Changes in v2.42:
Added option to use {currentsite} in baseUrl variable.March 15, 2015
Changes in v2.37:
Fixed a bug where booked time range was missing the minutes – displayed as :00 – when using AM / PM time format.

August 20, 2014
Changes in v2.36:
Fixed bug where the validation messages did not show when the resource field was set to read only.

June 07, 2014
Changes in v2.35:

  • Fixed a bug in the field xml when creating or updating the list as the choices for the hours could not be set in datasheet view due to wrong case on the CHOICES tag. Update the list to fix this issue.
  • Added support for multiple ranges of bookable dates. A big thanks to Rudolf Vehring for extensive testing on this feature!

Please note that you must update the configuration list to the latest version. You find the instructions in the article below.

May 15, 2014
Changes in v2.2:
I have added back the missing features from v1.3. related to restricting bookable time range individually for each weekday. If you are upgrading form v2.1 you must look at the details below as you will have to update the configuration list with new fields (this is done automatically by the script when you trigger the update).

Please note that you must have the latest version of spjs-utility.js. If you use it with DFFS you must have v3.344 or later of dffs_min.js.

May 8, 2014
Changes in v2.1:
Added an option to configure bookable time ranges in a separate list. See detail below.

I have previously posted a solution for preventing double booking of resources. This is a remake of the resource management solution that is more lightweight, and can be used with DFFS. It can also be used as a standalone solution.
IMG

Please note:
This solution is made for unmodified SharePoint forms.
How to set it up with DFFS

Add a reference to SPJSRM_min.js from the CEWP or HTML Form Web Part where you include the DFFS solution. When using this with DFFS (v3.344 or above) you find the configuration in a separate tab like this:
IMG

If you have an older version of DFFS you can activate it by adding this code to the Custom JS section in the Misc tab:

var spjsRmArgs = {
"resourceField":"MeetingRoom",
"dateFrom":"StartDate",
"dateTo":"EndDate",
"timeFormat":24,
"bookableTimeRangeActive":false
};
spjs.rm.init(spjsRmArgs);
Use it as a standalone solution

You must include spjs-utility.js and add the code to the bottom of the form web part like this:

<script type="text/javascript" src="/Scripts/jquery-1.11.2.min.js"></script>
<script type="text/javascript" src="/Scripts/spjs-utility/spjs-utility.js"></script>
<script type="text/javascript" src="/Scripts/SPJSRM/SPJSRM.js"></script>
<script type="text/javascript">

var spjsRmArgs = {
"resourceField":"MeetingRoom",
"dateFrom":"StartDate",
"dateTo":"EndDate",
"timeFormat":24,
"bookableTimeRangeActive":false
};
spjs.rm.init(spjsRmArgs);
</script>
Setup
  • resourceField: This is the FieldInternalName of the field you have the “resource” in. This can be a lookup column (single choice), a people picker (single choice) or any other single choice field present in the form.
  • dateFrom and dateTo: This is the FieldInternalName of the date fields. This solution will NOT handle recurring events.
  • timeFormat: This is either 12 or 24 and is for displaying the time ranges in the overlap message in the correct format.
  • bookableTimeRangeActive: true or false to control whether or not to use a separate list to restrict the bookable time range for the resources. See below.
Bookable time range

When this is used as a standalone solution you must “manually” create the list to hold the bookable time range settings. This is done by calling a function like this:

// Use this to set up the "SPJS-RM-BookableTimeRange" list.
spjs.rm.verifyTimeRangeList();

When this is done you find the list in “All site contents”. Do not let this code persist after the list is initially created as it will slow things down due to an unnecessary request.

SharePoint 2007

If you are using SP2007 you must provide the list GUID or DisplayName in the argument like this:

var spjsRmArgs = {
"listName":"TheListGuidOfThisList",
"resourceField":"MeetingRoom",
...
Download

Get spjsrm.js here (ensure you use v2.2 or above) and spjs-utility.js here.

Localization

To localize the text in the various messages from this solution, add this object to the CEWP alongside the function call:

spjs.rm.text = {
	"overlapMsg":"{0} has already been booked by {1} between {2} and {3}.",
	"endBeforeStartMsg":"End time cannot be less than or equal to start time.",
	"empty":"{0} cannot be left empty!",
	"wrongDateFormat":"Please use this date format: {0}",
	"notInTimeRange":["{0} can be booked from {1} on a {2}.","{0} can be booked to {1} on a {2}."],
	"notInDateRange":["{0} cannot be booked before {1}.","{0} cannot be booked after {1}."],
	"bookableDateRange":"The bookable date ranges for {0} are:
{1}",
	"dayNumObj":{0:"Sunday",1:"Monday",2:"Tuesday",3:"Wednesday",4:"Thursday",5:"Friday",6:"Saturday"}
};

Translate the text as you like, but keep the {placeholders}.

Update from a previous version

The configuration list in v2.2 looks like this (please note that v2.35 has removed the time selector from the dates):
IMG

This list is created automatically for you by the script the first time you set up the solution, but to upgrade you must check “manually” like this:

With DFFS

Click the “Check for updates to the configuration list” text:
IMG

Standalone

Add this function call to the CEWP below where you have loaded the file SPJSRM.js:

spjs.rm.verifyTimeRangeList();

Please note that this code must be commented out when the update is done.

I hope you enjoy the solution. Please post any bugs below.

Alexander

29 thoughts on “Resource management: Now compatible with DFFS”

    1. Hi,
      You can add this to the CEWP right after the SPJSRM.js file has been loaded:

      <script type="text/javascript">
      spjs.rm.data.lcidToDateFormat["3082"] = "d.m.y"; // change "d.m.y" to correct format
      </script>

      If you tell me the correct format I can add it to the next release.

      Alexander

  1. Hello,

    Is there a way to have it check for double booking, notify of a double booking like it does now but overwrite it and allow the double booking if needed? (for emergency purposes for scheduling).

  2. Hi Sir,

    I tried implementing your latest DFFS along with Resource Management and is perfectly working with me using IE11 and Chrome except that all my users are using IE9 and if they book it accepting even duplicate date and resource.

    Any thought on this issue please?

      1. Thank Alex. I’ll try in custom js. I have an idea of create one more column in your list to insert only holidays, but this is for later. So my question is, if I create two items with the same resource field with differents intervals, the first item with time range of morning and the second item with time range of afternoon, will work?

  3. Hi Alex, I’m having some issues with the trial version of DFFS. I’m testing it out on my companies SharePoint site and using just the resource manager to check for double bookings on vehicle reservations.

    Here are my issues: The Form works fine when creating a new reservation. It does not work on Edit or DisplayForm.aspx. The DFFS opens fine and I can make see all the tabs but it won’t allow me to save anything I make changes to. It only has the Cancel button. Is this because it’s Trial Version? Also, if a users wants to make a recurring reservation, the DFFS doesn’t throw out an error but when the user hits the save button on the Newform.aspx, nothing happens. It won’t save. Any ideas?

    Thank you for your help and time, I like your work and would like for this solution to work for our company before we continue with buying it.

    1. Hi,
      First, the resource manager will unfortunately not handle recurring events.

      For your other problem, there is no such restrictions in the trial. Please open the developer console (hit F12 > Console) and look for clues (errors) there.

      Please note that the DFFS web parts must be added to each form individually – could this be the issue?

      Please post further questions in the forum: https://spjsblog.com/forums/forum/dynamic-forms-for-sharepoint/

      Alexander

  4. Hi Alex, I have the last update of spjsrm.js but in my newForm, the validation messages did not show when the resource field was set to read only.

  5. Hello Alex,

    You mentioned we need to add an argument if we are using this in 2007. Where exactly am I adding this argument too? Also is it exactly like you posted or do I need to replace any of that text?

    Thanks again for your help.

    1. Hi,
      You add it to the “spjsRmArgs” that you have configured in the CEWP – this is just another line above the “resourceField”

      var spjsRmArgs = {
      "listName":"TheListGuidOfThisList", // <<< This argument
      "resourceField":"MeetingRoom",
      "dateFrom":"StartDate",
      "dateTo":"EndDate",
      "timeFormat":24,
      "bookableTimeRangeActive":false
      };
      spjs.rm.init(spjsRmArgs);

      Alexander

  6. Hi Alex. I want to know if is possible to use two resources fields in the same form. I removed the configuration in the Resource Management tab and I created in custom js tab, two variable:
    var data_resource = {
    “resourceField”:”Sala”,
    “dateFrom”:”data_inicio”,
    “dateTo”:”data_fim”,
    “timeFormat”:24,
    “bookableTimeRangeActive”:false
    };
    var monitor_resource = {
    “resourceField”:”Monitor”,
    “dateFrom”:”data_inicio”,
    “dateTo”:”data_fim”,
    “timeFormat”:24,
    “bookableTimeRangeActive”:false
    };
    spjs.rm.init(monitor_resource);
    spjs.rm.init(data_resource);

    this is my code, but only works for one. For the second variable, the page stopped to work.

    1. Hi,
      Sorry, but this is not currently possible. The reason is that you could check that the room is free on “change”, but when finish filling in your form and hit save, someone else may have beaten you to it and already booked the room.

      Alexander

  7. Trying to Implement standalone version on SP 2013 on premises.
    Steps:
    Created Calendar, not modified, just added MeetingRoom (choice)column.
    Downloaded libraries to SiteAssets.
    Created . js script per post (edited links to libraries)
    Added js link to NewForm.aspx via CEWP, under new form.
    Issue:
    Can not create new item. (not showing any error message, just OK link dead)
    When clicking on mini gray quadrant below left – pop up message
    “this will open https://spjsblog.com in new window. proceed?” when proceed, site opens.

    Any suggestion appreciate

      1. Hi Alexander,
        thanks for the great plugin.
        I had exact same issue as malabarka, the problem was that the link to download spjsrm.js is pointing to version 2.0. Once replaced with correct spjsrm, everything works great.

        Regards,
        Marek

  8. Iam using Resource management on a calendar and everything seems to be working great except when I update the event. Simply put, if I have a meeting on Thursday, add the event but it gets changed to Friday and I edit the time and day the double booking doesn’t catch this new day and time. Am I doing something wrong or does the list “SPJS-RM-BookableTimeRange” not get updated upon edit of the event?

  9. Hey Alexander,

    Have you come across any issues with selecting All Day Event for a single day with Resource Management Plugin? When I try to book an all day event for example on Thursday, May 18th,I get an error “End time cannot be less than or equal to start time.” I have to make it for multiple days.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.