web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Service | Customer Service, Contact Center, Fie...
Answered

Field service mobile app(Resco) - offline js error

(1) ShareShare
ReportReport
Posted on by 144

Hi All,

I am trying to create bookableresourcebooking record using offline js as follows.

function createBooking(ResourceId, ResourceName, workorderId, workorderName, bookingStatusID) {

var startDateTime = new Date();
startDateTime = startDateTime.setMinutes(startDateTime.getMinutes() - 60);
startDateTime = new Date(startDateTime);


var endDateTime = new Date();

var newBooking = new MobileCRM.DynamicEntity.createNew("bookableresourcebooking");
newBooking.properties.starttime = startDateTime;
newBooking.properties.endtime = endDateTime;
newBooking.properties.duration = 1;
newBooking.properties.bookingstatus = new MobileCRM.Reference("bookingstatus", bookingStatusID, "Scheduled");
newBooking.properties.msdyn_workorder = new MobileCRM.Reference("msdyn_workorder", workorderId, workorderName);
newBooking.properties.resource = new MobileCRM.Reference("systemuser", ResourceId, ResourceName);
newBooking.save(function (err) {
if (err != null) {

document.getElementById("error").innerHTML += "<p> " + err + " </p>";
}
else {
document.getElementById("error").innerHTML = "<p> Sucessfully created a booking </p >";
}
}
);
}

But I am geeting following error

Server Error: Length cannot be less than zero. Parameter name: length

I hope this error comes due to start time and end time (when both are equal)

7750.pastedimage1574909237851v1.png

Could please someone help me to resolve this issue?

I have the same question (0)
  • Thomas David Dayman Profile Picture
    11,323 on at

    I think the error might be pointing somewhere else in the code.

    Are you using a parameter called 'length' anywhere?

  • aindike Profile Picture
    144 on at

    Hi Thomas,

    No. In the OOB form also getting this error when strat time and end times are equal.

    Thanks

  • Thomas David Dayman Profile Picture
    11,323 on at

    startDateTime = startDateTime.setMinutes(startDateTime.getMinutes() - 60);

    Maybe its this part of the code?

    Could you try putting static date times in the start and end time?

  • aindike Profile Picture
    144 on at

    Yes. I tried but still no luck.

  • Thomas David Dayman Profile Picture
    11,323 on at

    All I can think of is setting some alerts in your code and see what is being triggered.

    Maybe its the BookableResourceBooking javascript that could be causing the error? Maybe creating a new booking directly in the mobile could cause it to act strange ?

  • britman Profile Picture
    590 on at

    Hi, I am also receiving the same error. I am setting the bookable resource booking start date with current date. Did you find a solution?

  • Community Member Profile Picture
    on at

    could it be due to specifying a required field?

  • Fannie30 Profile Picture
    2,990 Moderator on at

    Questions :1) have you added any logic to the forms via rules? Have you changed the OOB form or OOB logic?  
    2) you said you updated the offline js?  Why?  

    I ask because I am able to create a booking in offline mode with zero issues. 

  • Verified answer
    aindike Profile Picture
    144 on at

    Hi All,

    I have found the error. This error occurs due to the wrong MobileCRM.Reference. I have used the wrong reference.

    newBooking.properties.resource = new MobileCRM.Reference("systemuser", ResourceId, ResourceName); The correct entity is the bookableresorce.

    Thanks

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the April Top 10 Community Leaders

These are the community rock stars!

Leaderboard > Service | Customer Service, Contact Center, Field Service, Guides

#1
FSRon Profile Picture

FSRon 23

#2
James White Profile Picture

James White 21

#3
AT-28040446-0 Profile Picture

AT-28040446-0 18

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans