Jan 29, 2018, 3:20 PM
68 Posts

error using adjustDay in Javascript

  • Category: Debugging
  • Platform: Windows
  • Release: 8.5.3
  • Role: Developer
  • Tags:
  • Replies: 1

I have a server Javascript library where I am re-writing a LotusScript agent in Javascript, so I can keep all the code in one place.  I need to adjust dates, and am attempting to use adjustDay, but it's just not working.  What is wrong with the following?

var lastdate:NotesDateTime = session.createDateTime(@Today());

lastdate = doc.getItemValue("LastDate"); // I have a handle on doc

lastdate.adjustDay(days)  // where days = an Integer;

I'm getting: "Error calling method 'adjustDay(number)' on an object of type 'java.util.Vector [Dynamic Java Wrapper, java.util.Vector]'

When I try lastdate:NotesDateTime = doc.getItemValue("LastDate") I also get an error on adjustDay

Jan 30, 2018, 5:20 AM
2 Posts
getItemValue does not return a NotesDateTime object
Instead, it returns a Vector, as the error message suggests.

You could try this instead:

var lastDateItem:NotesItem = doc.getFirstItem("LastDate");
if (lastDateItem != null && lastDateItem.Type == 1024) { //where 1024 == NotesItem.DATETIME
        var lastDate:NotesDateTime = lastDateItem.getDateTimeValue();