1

I have a repeat control with buttons to select or deselect various docs - that works and I can identify each selected doc by the doc id. I have another button with the following SSJS. For the docs selected I want to set a field in the underlying doc. This script works if I do a simple doc.removePermanently(true)... but not if I try to manipulate a common field value for the selected docs. I'm getting an Error 500 HTTP Web Server: Command Not Handled Exception. What is the proper way to do this?

var docsForAction = sessionScope.get("myList");
var doc:NotesDocument;
for(i=0; i < docsForAction.length; i++){
    doc = database.getDocumentByUNID(docsForAction[i]);
    doc.setValue("Level","10");
    }
docsForAction = [];
viewScope.put("myList", docsForAction);
context.reloadPage();   

1 Answers1

1

You're probably getting an error 500 because you don't have an error page defined. Go to Xsp Properties and tick "Display default error page". You will then get a more meaningful error page displayed.

The error you'll see is probable on the setValue() line, the message being "null". That's because setValue() is not a method of NotesDocument, it's a method of the dominoDocument datasource (the "NotesUIDocument" XPages equivalent, if you know LotusScript).

Casting the variable (adding ":NotesDocument") is good because it allows you to take advantage of the typeahead support in the SSJS editor or the source pane. That will give you a list of valid methods and the valid parameter types taken.

Paul Stephen Withers
  • 15,699
  • 1
  • 15
  • 33
  • Thank you for Paul the suggestions... all very helpful. Using the method replaceItemValue("field","value") solved my problem. – xavier pages Dec 13 '14 at 00:11