Disable input for certain fields based on criteria

Hi experts,

I've got a form that contains many combobox fields and I want to disable certain fields from being editable when the current user is not the creator.
The criteria to check whether the fields should be enabled is based on the comparison of 2 computed fields. I've managed to do it for the web using javascript using these codes in the onLoad event:
if(document.forms[0].authUser.value != document.forms[0].lName.value)
{
      document.forms[0].UserName.disabled = true;
      document.forms[0].Company.disabled = true;
      document.forms[0].Department.disabled = true;
      document.forms[0].probCategory.disabled = true;
      document.forms[0].probDesc.disabled = true;
}
This works fine for the web but in the notes client it does not work so I hope someone can help by providing a lotusscript or formula version of my current JS codes. (I dont know what is the field property in LS that controls editability)

I've tried using:
authUser = lName
in the Input Enabled of the fields but still doesnt work. I've also tried using the Javascript in client but doesnt work too.

Thats all! Thanks in advance for any help.



Regards,
zZR
lianaizhouzhiruoAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
qwaleteeConnect With a Mentor Commented:
And, you CAN use access controlled section even with disperesed fields.  Yu don't want it to look messy, so here's how:

1) Do the above steps separately for each field
2) For each section, go to section properties, hide-when, and check off both Notes and Web

Now, the section chrome is hidden, leaving just the field visible -- but the section "security" still applies, and the section conetnt isn't hidden, just the section UI
0
 
madheeswarCommented:
u need to use Controlled sections for this.
This wil work both on Notes and Web.

See Help for more details.
0
 
Bozzie4Commented:
Is it R6 ?  Then there is a new field property available you can use.

cheers,

Tom
0
The 14th Annual Expert Award Winners

The results are in! Meet the top members of our 2017 Expert Awards. Congratulations to all who qualified!

 
lianaizhouzhiruoAuthor Commented:
Hi Madheeswar, my fields are laid out in different places so I cant use controlled sections. Is there any other way?

Hi Tom, my designer is r6 but i think the server is on r5. Anyway what is this new field property?
0
 
Sjef BosmanGroupware ConsultantCommented:
You could use the "old-fashioned" way: have two fields adjacent to each other, make one editable and the other computed for display, with a formula that has only the name of the first field in it. Give both fields a hide-when formula, the first field must be shown when the creator (or someone with a [Manager] role?) is editing the form, the second when it's someone else. To prevent some comments from my colleagues ;), you can replace the computed for display field with computed text with the same formula.
0
 
ZvonkoSystems architectCommented:
Create for every field that you want to be able to disable editiong also a read-only version.
For example for Department field add the field dspDepartment.
Now the field Department has hide-when set for Readers, and the field dspDepartment has hide-when set for editors.
The value for the dspDepartment field is simply: Department
0
 
ZvonkoSystems architectCommented:
Is that old-fashioned?
Now I am too long out of business :(
0
 
Bozzie4Commented:
If you are on an R5 server, I wouldn't use it, but here is how you use it :

It's the Input Enabled fieldproperty (it's there together with Input Validation etc.).  Put this in (as an example):

@If(@ThisValue="";@True;@False)

This will set the field enabled for input if it's empty, but once it has a value, the field will be disabled for input.

cheers,

Tom

0
 
lianaizhouzhiruoAuthor Commented:
Hmm, I tried bosman/zvonko's method and it works for most of the fields except a Rich text field. Is there any way to make this RTF uneditable except by the creator?

I tried that and it didnt work Tom thanks though.
0
 
lianaizhouzhiruoAuthor Commented:
BTW, the hidewhen formula didnt seem to work for the RTF
0
 
ZvonkoSystems architectCommented:
You have a typo in the hidewhen.
Hidewhen work also for RTF.

Do you realy need Rich Text or do you use it only because of rows and columns in <textarea>?

0
 
Bozzie4Commented:
For richtext, the new method doesn't work, but it certainly works for ordinary fields (since I use it myself).

To recalculate the enable/disable, you do have to use F9 (to refresh the document) in this example case.

You can hide richtext, if you use a simple trick : put it in a table or put text in front of the field and behind, and hide that text.  That will hide your richtextfield too.

cheers,

Tom
0
 
Sjef BosmanGroupware ConsultantCommented:
Hiding a RTF I usually do differently, but hey, don't we develop or own methodsm constantly?

I used to do the following:
- put the RTF in a subform
- add a computed subform to the form
- formula like: @If(mustbevisible; "subformname"; "")

But maybe Tom's trick is shorter. Hiding RTF's is more difficult, since you can use hide-whens INSIDE a richtext field!
0
 
qwaleteeCommented:
Has nothing to do with R5 server or R6 server... it depends on whether you users all hae R6 clients or not.  Same as if you had a bunch of users who have old versions of Navigator that don't have the support for .disabled.

If all users will be sing this on the server, not rpelicated locally, the following will work:

1) Select the fields that you wish to disable
2) Create->Section->Access Controlled
3) Specify computed for display
4) FOrmula is: @Name([Canonicalize]; authoName)
0
 
lianaizhouzhiruoAuthor Commented:
Hi people thanks loads for all the replies. I'll be back at the PC tomorrow to try these out! Will check back in 24hours


Cheers!
0
 
Bozzie4Commented:
Qwaletee, although using R6 functions in an R6 client is possible on an R5 server, I still wouldn't use them - there is also a webinterface here, which means on server, hence 'R5 ONLY'

cheers,

Tom
0
 
qwaleteeCommented:
Yes, but these attributes are only used in the Notes client part of the form.  The web server will ignore form attributes and field attributes that it does not know about, much as Hide From Notes 4.6 would not break an app on a 4.5 server.  For that matter, Hide From Web would be ignored on the 4.5 server, so thae page would dispay, although not what you expect in that case
0
 
lianaizhouzhiruoAuthor Commented:
Hi Qwaletee,

Tried your method and it works fine in Notes(section arrows dont appear, which is great).
On web however, when the document is opened for reading, the fields are totally empty. And when I open the document for editing, the fields are totally editable even though they shouldnt be.
0
 
lianaizhouzhiruoAuthor Commented:
Just in case I wasn't clear enough, on the web the whole section and the field that it controls is not visible when document is opened for reading but when opened for editing, the fields appear without the section arrow.
0
 
lianaizhouzhiruoAuthor Commented:
I kept the sections and got over the problems for the moment by creating duplicate fields that are hidden from notes and when opened for editing with default value formula of the original fields.
Hope to hear other solutions soon


Cheers!
0
All Courses

From novice to tech pro — start learning today.