Solved

Disable input for certain fields based on criteria

Posted on 2004-10-26
319 Views
Last Modified: 2013-12-18
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
0
Question by:lianaizhouzhiruo
    20 Comments
     
    LVL 19

    Expert Comment

    by:madheeswar
    u need to use Controlled sections for this.
    This wil work both on Notes and Web.

    See Help for more details.
    0
     
    LVL 15

    Expert Comment

    by:Bozzie4
    Is it R6 ?  Then there is a new field property available you can use.

    cheers,

    Tom
    0
     

    Author Comment

    by:lianaizhouzhiruo
    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
     
    LVL 46

    Expert Comment

    by:Sjef Bosman
    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
     
    LVL 63

    Expert Comment

    by:Zvonko
    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
     
    LVL 63

    Expert Comment

    by:Zvonko
    Is that old-fashioned?
    Now I am too long out of business :(
    0
     
    LVL 15

    Expert Comment

    by:Bozzie4
    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
     

    Author Comment

    by:lianaizhouzhiruo
    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
     

    Author Comment

    by:lianaizhouzhiruo
    BTW, the hidewhen formula didnt seem to work for the RTF
    0
     
    LVL 63

    Expert Comment

    by:Zvonko
    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
     
    LVL 15

    Expert Comment

    by:Bozzie4
    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
     
    LVL 46

    Expert Comment

    by:Sjef Bosman
    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
     
    LVL 31

    Expert Comment

    by:qwaletee
    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
     
    LVL 31

    Accepted Solution

    by:
    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
     

    Author Comment

    by:lianaizhouzhiruo
    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
     
    LVL 15

    Expert Comment

    by:Bozzie4
    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
     
    LVL 31

    Expert Comment

    by:qwaletee
    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
     

    Author Comment

    by:lianaizhouzhiruo
    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
     

    Author Comment

    by:lianaizhouzhiruo
    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
     

    Author Comment

    by:lianaizhouzhiruo
    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

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    IT, Stop Being Called Into Every Meeting

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    Suggested Solutions

    Title # Comments Views Activity
    Validating Email Address 13 260
    Migration: Lotus Notes to Exchange 2013 10 300
    Add a cc field to email code 3 79
    Lotus Domino server 11 49
    Problem "Can you help me recover my changes?  I double-clicked the attachment, made changes, and then hit Save before closing it.  But when I try to re-open it, my changes are missing!"    Solution This solution opens the Outlook Secure Temp Fold…
    Notes Document Link used by IBM Notes is a link file which aids in the sharing of links to documents in email and webpages. The posts describe the importance and steps to create a Lotus Notes NDL file in brief.
    This video Micro Tutorial is the first in a two-part series that shows how to create and use custom scanning profiles in Nuance's PaperPort 14.5 (http://www.experts-exchange.com/articles/17490/). But the ability to create custom scanning profiles al…
    Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

    846 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

    Need Help in Real-Time?

    Connect with top rated Experts

    9 Experts available now in Live!

    Get 1:1 Help Now