• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1847
  • Last Modified:

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

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?
0
dominoPgr
Asked:
dominoPgr
  • 6
  • 5
  • 2
  • +1
1 Solution
 
fgrushevskyCommented:
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
0
 
dominoPgrAuthor Commented:
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.
0
 
iPinkyCommented:
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
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
jjphardyCommented:

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
  thisUI.GotoNextField
 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.
0
 
dominoPgrAuthor Commented:
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?
0
 
iPinkyCommented:
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..
0
 
iPinkyCommented:
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)
0
 
dominoPgrAuthor Commented:
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?
0
 
iPinkyCommented:
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
0
 
jjphardyCommented:
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.
0
 
iPinkyCommented:
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
0
 
dominoPgrAuthor Commented:
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
Computed when composed
Computed for display
Which one should I choose?
0
 
dominoPgrAuthor Commented:
Actually, type Computed worked for me. Thanks!
0
 
dominoPgrAuthor Commented:
It worked for me. Thanks a lot!
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 6
  • 5
  • 2
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now