How to lock a Rich Text field after click a button from a Lotus Note document?

Posted on 2010-09-22
Last Modified: 2013-12-18
For any other field type (not rich text field), I can use following solution from my previouds question:
 The easiest way to do it to have two fields for each field that you want to lock, for example Field1 and Field1_R
Field1 would be your editable field
Field1_R would be computed for display (i.e. read only) field with the formula Field1

When user clicks on the button, the button would set a flag , i.e. some hidden field. You will use this flag field in the "hide when formula is true" formula to hide FIELD1 and display FIELD1_R instead.

this is how it works:
user opened a document
Flag_Field="0"  (default value)

FIELD1 is visible (hide when formula is ... Flag_Field="1")
FIELD1_R is not visible (hide when formula is ... Flag_Field="0")

user click on a button that set Flag_Field="1"

FIELD1 is not visible (hide when formula is ... Flag_Field="1")
FIELD1_R is visible (hide when formula is ... Flag_Field="0")

However, above approach does not work for Rich Text field. How can I lock(change to uneditable) a Rich Text field after click a button?
Question by:dominoPgr
  • 6
  • 5
  • 2
  • +1
LVL 17

Expert Comment

ID: 33736778
the rich text field is a bit more trickier

you can put FIELD1  and FIELD1_R  into different sections and hide them depending on the flag or  put fiels into different subforms and display them depending on the flag as it was suggested

Author Comment

ID: 33738132
I'm new to lotus notes development. Still trying to understand how can I sync the value between FIELD1 and FIELD1_R after FIELD1 is being edited? For rich text field, we don't have "Computed for Display" field type. I can only set it as "Computed". After I added FIELD1_R as Computed field, and set it's value as FIELD1, the first time I open the documant I see FIELD1_R has got the same value of FIELD1. However, after I edited FIELD1, and save the document, Field1_R is not being updated.

Accepted Solution

iPinky earned 250 total points
ID: 33741173
you could (depending on the layout) put an access controlled section around the richtext field.

make the formula such that upon Flag_Field = "0" the access formula is "*" and otherwise "[Designer]:[Admin]"

eg.: formula for access controlled section:

@if( "0" = Flag_Field; "*"; "[Designer]:[Admin]" );

this would effectively only give users with role Designer or Admin edit access to that field.

the only drawback is that this process only works after "reopening" the document, but this can easily be handled in your button as well
Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.


Expert Comment

ID: 33746062

This is one of the big holes in Lotus. There is no effective way to do this without closing and reopening the doc. The closest I have come to this is by using the "Entering" event.
Something like this
Sub Entering(Source As Field)
 Dim ws As New NotesUIWorkspace
 Dim thisUI As NotesUIDocument
 Set thisUI=ws.CurrentDocument
 If thisUI.FieldGetText ("flagfield") ="jumpval" Then
 End If
End Sub
This is untested code and mostly done from memory. It is placed in the "Entering" event of the field.  
flagfield is the name of a field that is set to "jumpval" when you want to lock down this field. There must be an editable field after your richText field.
This can not be written in formula. It is not available for this event. It can be done in the onFocus event also but I have not tried it here.

Author Comment

ID: 33748490
I like the idea of using Access Controled Section as I have 20+ fields to work with.

However, when I tried to put some fields in access controled section, all fields becomes un-editable even my Flag_Field is 0. Is following formula correct for setting Editable?
@if( "0" = Flag_Field; "*"; "[Designer]:[Admin]" );

Is "*" for every one to have edit access?

Expert Comment

ID: 33748498
jjphardy… I honestly hope this piece of code is not implemented in your applications.

It is NEVER a good idea to work with uiDocument.FieldGetText( "" ).. it's slow and ALWAYS returns text, even when the value is date or number, or error.

big hole? a hole to me is something bad in security, but this ain't related to security at all..

Expert Comment

ID: 33748692
yes "*" is for everyone, I guess you need to put the formula the other way.. sorry I didn't check it really..

i usually call such fields: Flag_Hide then a "0" would mean no hide,

so I guess @if( "1" = Flag_Field; "*"; "[Designer]:[Admin]" ); would be correct.
the Flag_Field (usually for such fields) is supposed to go on top of the page and "hidden" always (I usually use a "style" which hides and makes hidden text red (or any other color to identify easily)

withIN the access controlled section you would ONLY put the RichText fields! but you can create an access controlled section for each richtext field (if they are scattered on the form, eg. you can even use access controlled sections within a table)

Author Comment

ID: 33775788
Sorry for the late response. My access controlled section is still not working right. I got all fields in the access controlled section editable. But after I changed the Flag_Field from a button click, the fields are still editable.

I'm using Lotus Notes version 7. Which LN version are you using?

Expert Comment

ID: 33786020
you need to close and reopen the document, otherwise something with your formulas is wrong, maybe you post the db and I have a look

Expert Comment

ID: 33789865
The security of a section does not override the ACL. Just like an editors field. If the ACL grants you Editor, or above, you can edit the doc or section. Does not matter what is in the list.
If you are testing this from the same ID you are designing from, you can not lock yourself out.

Expert Comment

ID: 33790031
sorry jiphardy.. that's absolutely not true..

a simple test would have proven that this ain't correct...

it is "finegraining" the ACL... same as reader fields..

if there is a reader field and you are not part of it.. even Manager access to the DB won't make the document visible to you!

and that's exactly how it's supposed to work

but as I said: a reopen of the document is required after setting the flag field

Author Comment

ID: 33794070
I found what caused by problem: In the Type field above the Access Formula, I chose Editable which is wrong. I still have a few other choices:
Computed when composed
Computed for display
Which one should I choose?

Author Comment

ID: 33794136
Actually, type Computed worked for me. Thanks!

Author Closing Comment

ID: 33794149
It worked for me. Thanks a lot!

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This is an old article, please see an updated version of this article, located here:
Lack of Storage capacity is a common problem that exists in every field of life. Here we are taking the case of Lotus Notes Emails, as we all know that we are totally depend on e-communication i.e. Emails. This article is fully dedicated to resolvin…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

803 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question