1
votes

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
You did not save your change by doc.save();Frantisek Kossuth
I removed doc.save(); in testing... but with or without same error.xavier pages
Try using doc.replaceItemValue("fld", "val") instead of doc.setValue(). Don't think that method exists on a NotesDocument.Mark Leusink
Follow Marks advice. Also make sure to use XPages Log File Reader for easy access to your XPages error logs. They contain more details for your error.Per Henrik Lausten
Thank you... doc.replaceItemValue("Level", "10") did the trick in place of doc.setValue().xavier pages

1 Answers

1
votes

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.