Announcement

Collapse
No announcement yet.

hide form fields based on groups

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • hide form fields based on groups

    Hi.

    I need to hide some personal information fields from a form, let's say "formA". In other words, some user can see those fields some others can not. I am going to do this way:

    i will duplicate "formA" and call the duplicate "formA_nopersonal". Then in this copy i will hide the fields i need to hide. Then i will link both the forms in the same menu that will be the top menu of my project.

    i will assign user1 the right to see "formA" but not "formA_nopersonal" because he can see every field. Then i will assign user2 the right ti see "formA_nopersonal" but not "formA". This should prevent that the user1 and user2 see duplicate items in the menu. is it right or they will see menu items ttwice? (one for the formA and the other one for formA_nopersonal)?

    there is a more proper way to achieve this goal?

    Thanks

  • #2
    It should be easier to maintain if you keep one form only. You can hide/show fields conditionally using SC macros.

    Comment


    • #3
      Ok,

      Which one is the right macro to be used for this purpouse?
      Thanks.

      Comment


      • #4
        http://www.scriptcase.net/docs/en_us..._field_display

        Even easier if you group all fields you want to hide in a block:
        http://www.scriptcase.net/docs/en_us..._block_display

        Comment


        • #5
          Ok great... so how do I check what group a user is in so I can hide the block based on the entire group?

          Comment


          • #6
            Answering my own question.... Look it up in the security database.

            Comment


            • #7
              Hello, yourguide. What do you mean? If the group not allowed to see field 1 is named "group1"the syntax is this?

              if ({what_should_i_write_here} == "group1")
              {
              sc_field_display({field1}, off);
              }
              else
              {
              sc_field_display({field1}, on);
              }



              thanks

              Comment


              • #8
                I agree that the single form is easier. What I usually do is create a global variable in the log in app in the onValidate event. When you load the form app, you can check what group the user is in, and hide the fields that are not appropriate for that group. You can do it field by field, but as mentioned above, if you can put them all in a block, then you can just hide or show that block. I typically end up doing it field by field, as the show/hide fields tend to be scattered throughout the form.

                You can do a variety of macros, depending on your desired outcome. For example:

                if ( [global_group_member] == 4 )
                {
                sc_field_readonly({Field_01}, 'on');
                sc_field_display({Field_02}, 'off');
                sc_field_disabled("Field_04");
                }

                Comment


                • #9
                  I have not yet applied the Security module. I suppose
                  Global_Group_member is set by tbe Security module itself in One of the many tables it creates when you apply it.

                  Thanks

                  Comment


                  • #10
                    No, that is not set by default. You have to do a lookup on the security groups table, then assign it to a global. I do that in the onValidate event in the log in app.

                    Comment


                    • #11
                      woudn't it be better to put this macro in the onload event of the form that has the fields to hide?. if i have many applications and i have to hide fields in let's say "form1".
                      if i put that macro in the log in app, will those fields remain hidden even if i jump from one app to another and come back on the "form1"?

                      Thanks again

                      Comment


                      • #12
                        Originally posted by mhanu70 View Post
                        woudn't it be better to put this macro in the onload event of the form that has the fields to hide?. if i have many applications and i have to hide fields in let's say "form1".
                        if i put that macro in the log in app, will those fields remain hidden even if i jump from one app to another and come back on the "form1"?

                        Thanks again
                        Sorry for the misunderstanding. You add the macro to hide fields in the form app. I mentioned that I create the global variable in the log in app. "create a global variable in the log in app in the onValidate event.". You will want to control the form fields within the form itself. However, you can look to the global variable to see what group the user is in, which was created in the log in app.


                        Comment

                        Working...
                        X