Field updates and Hide/When

Hi everyone.

I have a question, and I am sure it is pretty basic, but it has been giving me a lot of trouble.

I have a form (Lotus Notes 7.0.1) that is using several hide/when statements based on hidden field values. I have a button that calls a LotusScript function, and the function updates the hidden field which should trip the hide/when logic. Before the sub ends, I call RefreshHideFormulas. The problem is that my fields don’t hide when I first press the button, but the field value does change. What am I missing?

I tried a Refresh prior to the RefreshHideFormulas, but I get the “@Commands and other UI functions are not allowed in this context.” message.

Public Sub ShowAll(tbRefreshHideFormulas As Boolean)

Dim ws As New NotesUIWorkspace

Dim uidoc As NotesUIDocument

Set uidoc = ws.CurrentDocument	

'Storing the show and hide switches in fields

Call uidoc.FieldSetText("HideISFields","False")

Call uidoc.FieldSetText("HideFacilitiesFields","False")

Call uidoc.FieldSetText("HideFiscalFields","False")

Call uidoc.FieldSetText("HideAdminFields","False")

Call uidoc.FieldSetText("HideHRFields","False")



If tbRefreshHideFormulas Then

	Call uidoc.RefreshHideFormulas

End If

End Sub

Thank you for any help.

Ben

Subject: RE: Field updates and Hide/When

Forgive me for suggesting the obvious, but I see your call to RefreshHideFormulas is in a conditional. Are you sure tbRefreshHideFormulas is True at that point?

Generally speaking, if FieldSetText doesn’t give you an error, I don’t see why Refresh should. Perhaps this error is coming from a formula which is executed as part of the refresh, e.g. in a computed field formula. But you should not need to refresh for this to work. Do you get the same message if you press F9?

What is one of the hide formulas that doesn’t work? Does it work if you press F9?

Subject: RE: Field updates and Hide/When

Andre,

Thank you for the response.

The RefreshHideFormulas is getting executed, and I understand the need to check the obvious! More than likely I am missing something obvious.

I do not get an error messages when I press F9, and appears to have no effect on the form. The fields I want to hide/show do not hide/show. For testing purposes, I placed a button on the form that only does a RefreshHideFormulas, and when I click button after executing the code in the previous post, my fields hide/show correctly.

I may not have explained the problem very well in my previous post. The first time I execute the “showall” code, my hidden fields stay hidden, but the field values I set have changed. If I execute this button again it will work, but it is always a step behind.

Thanks.

Ben

Subject: RE: Field updates and Hide/When

You didn’t answer all the questions I asked.

Subject: RE: Field updates and Hide/When

Here is one of the Hide formulas: HideISFields=“True”. This references a text field whose value is set in the sub from the first post. I toggle the values betweei True and False.

No, the hide does not work when I manually change the value and press F9. It does work if I click the RefreshHideFormulas button I added for testing. Thanks.

Ben

Subject: RE: Field updates and Hide/When

I wonder whether it might help to put the “Hide” fields above the paragraphs that have the hide formulas.

Subject: Field updates and Hide/When

I had the same problem and I was able to resolve it by duplicating each uidoc.FieldSetText with uidoc.Document.ReplaceItemValue. It is not very nice, but it works.

For example, the line

Call uidoc.FieldSetText(“HideISFields”,“False”)

in your code, I would write as

Call uidoc.FieldSetText(“HideISFields”,“False”)

Call uidoc.Document.ReplaceItemValue(“HideISFields”,“False”)

Subject: Field updates and Hide/When

I had to leave a response as I’ve encountered the same problem and I’m wondering if it is a bug.FYI - I’m on version 6.5

I’ve got a command button and in LS I called a Prompt from the workspace and then set Field A with text. I then called the uidoc.RefreshHideFormulas. Field B has a hide/when formula that basically says if FieldA is Null then Hide otherwise display.

I really believe that the RefreshHideFormulas in LS does not work. I rewrote the code in formula and did the equivelant of the LS with @Command([RefreshHideFormulas]) and it worked. I was lucky that I only had a simple function and Formula language would suffice.

My very basic LS code

Sub Click(Source As Button)

Dim ws As New NotesUIWorkspace

Dim uidoc As notesUIDocument

Dim values(1) As Variant

values(0) = “Hello”

values(1) = “Test”

Set uidoc = ws.currentDocument

selection$ = ws.Prompt( PROMPT_OKCANCELLIST,“Title”, “Select one”, “”, values)

If selection$ <> “” Then

Call uidoc.FieldSetText(“FieldA”, selection$)

Call uidoc.RefreshHideFormulas

End If

End Sub

Again for Field B which is in a different cell of a table the Hide/When Formla was

FieldA = “”

I believe this is a bug.

Hope you found a way around your issue. I prefer LS so I’m disappointed this didn’t work.

Cheers