Lotus Script keeping a value in a field

I have the following script on a button to check the answers to questions. When the answer is wrong I am writing “Incorrect” in a computed field. This does write if the score is below 70%, and then if they change answers and their score is 70% or over the value does not show anymore. If the first time they hit the button and their score is 70% or above it shows the incorrect value for a second but then the value disappears and does not show when you open the document again. Any suggestions?

Dim session As New NotesSession

Dim db As NotesDatabase

Dim workspace As New NotesUIWorkspace

Dim uidoc As NotesUIDocument

Dim score As Double

Dim askme As String

Dim doc As NotesDocument

Dim correct As Double

Dim item As NotesItem

Dim arraycount As Double

Dim answer As Double

Dim iscore As Double

Dim MTotal As String

Dim fieldname As String

Dim aname As String

Dim rtitem As NotesRichTextItem

Dim senddoc As NotesDocument

Dim sTo(1) As String

Set uidoc = workspace.CurrentDocument

Set doc = uidoc.Document

Call uidoc.Refresh

sTo(0) = uidoc.FieldGetText(“SendTo”)

sTo(1) = uidoc.FieldGetText(“Manager”)

score = uidoc.FieldGetText(“Total”)

MTotal = uidoc.FieldGetText(“Total”)

For arraycount = 1 To 7

fieldname = “a” & arraycount

aname = “c” & arraycount

iscore = Cdbl(uidoc.FieldGetText(fieldname))

If iscore = 0 Then

Set item = doc.ReplaceItemValue(aname,“INCORRECT”)

End If

Next

If score < .70 Then

askme = workspace.Prompt(PROMPT_OK,“Score”,“Your score is below 70% please check your answers”)

Exit Sub

End If

If score > .69 Then

askme = workspace.Prompt(PROMPT_OK,“Score”,"Congratulations, your score is " & MTotal)

Call uidoc.Save

Set db = session.CurrentDatabase

Set senddoc = db.CreateDocument

Set rtitem = New NotesRichTextItem(senddoc, “Body”)

senddoc.form = “Memo”

senddoc.Subject = doc.Test(0)

Call rtitem.AppendText(doc.Name(0) &" has taken the above quiz")

Call rtitem.AddNewline(2)

Call rtitem.AppendText("Quiz score is " & MTotal)

Call senddoc.Send(False,sTo)

End If

Call uidoc.Refresh

Call uidoc.FieldSetText(“Status”,“Done”)

Call uidoc.Save

uidoc.EditMode = False

uidoc.Close(True)

Thanks again

Subject: Lotus Script keeping a value in a field

before calling uidoc.save, try pushing ‘incorrect’ from backend to frontend via the uidoc.reload function

e.g.

uidoc.reload ’ <==

uidoc.refresh

uidoc.save

Subject: RE: Lotus Script keeping a value in a field

Thank you for your suggestions, however, neither one worked. I am not doing anything with the fields as far as hide/when. I tried the uidoc.reload which I placed after a doc.save but the field values do not stay. ???

Subject: RE: Lotus Script keeping a value in a field

Would have to be before the doc.save… that was sort of the point.

Subject: Just Guessing

You first refresh the user interface, so the fields do the calculations and you get your values set. Then, you do another refresh, which updates the hide-whens. But before the hide-whens take effect, the fields are displayed.

I would try adjusting your hide-whens so that they only appear when there is a problem, i.e. the score is less than 70. Not hidden when there isn’t a problem.