queryOpenDocument error in XPages

Hi, I’m trying to reproduce a simple logic that I have on my Notes form using an XPage.

On my form I have some LotusScript on QueryOpen event that checks for status field and changes it’s value under certain criteria.

I created an XPage for this and I’m using queryOpenDocument event under Data property:

print(“Opening Task”);

var tasktype = document1.getItemValueString(“TaskType”);

print(tasktype);

switch (tasktype) {

case "Informative":

	print("Informative");

	document1.setValue("Status", "4");

	document1.setValue("Percentaje", 100);

	document1.setValue("ReceivedDate", @Today());		document1.setValue("ClosedDate", @Today());



	document1.save();

case "Resolution Required":		

	print("Resolution Required");

	print("Informative");

	document1.setValue("Status", "2");

	document1.setValue("ReceivedDate", @Today());

	document1.save();

}

However, I’m getting an error trying to access the document1 (my data source).

If I move the code to the event postOpenDocument it works, but, doesn’t reflect the changes on fields.

ERROR


Exception

Error while executing JavaScript computed expression

Script interpreter error, line=1, col=17: Reference error: ‘document1’ not found

Javascript code

1: print(document1.getItemValue(“Status”));

Subject: I’d like to take a close look…

Hi Pablo,Do you have a sample that shows this happening and could you send it on to me for a closer look?

Regards,

Paul.

paul_hannan@ie.ibm.com

Subject: Db sent…