9 Replies Latest reply on Mar 31, 2015 12:27 AM by LoganSmart

    Scripts to hide fields in specific situation

    LoganSmart

      Title

      Scripts to hide fields in specific situation

      Post

      Hi, guys!

      That's the question:

      i have *.xls file (http://piccy.info/view3/7916400/9e04767b432dd70c58679126a4d943ee/);

      have *.fmp12 (http://piccy.info/view3/7916449/e8671f358611e07429cd79735eb09187/) as well.

      I need 2 scripts that:

      1. can hide empty fields when i create a new record;

      2. can move to another layout if in the field 'Status' of seleted record typed 'spoilage' when i call this record in find menu or so on.

      I really need help with this stuff. Please, help!smiley

       

       

        • 1. Re: Scripts to hide fields in specific situation
          philmodjunk

          You need to explain what you want in more detail. At the time you create a new record, all fields that don't auto-enter data will be empty so it makes no sense to me to hide empty fields at that point as you would be preventing the user from entering data into the empty fields of that new record. If this is FileMaker 13, that you are using "Hide Object When" can hide those fields, I just can't help thinking that there's a significant detail missing here.

          2. How's that again? Do you mean "Find all records where status contains the word "Spoilage" and pull that found set up on a different layout if any are found?" Or do you mean "find all records where status contains a word that the user enters into a different field and bring them up on a different layout?"

          • 2. Re: Scripts to hide fields in specific situation
            LoganSmart

            More detail. Ok, PhilModJunkwinkwink

            I use File Maker 13 Pro Advanced.

            May be I use wrong terminology, then I will use screenshots.

            Scripts:

            1) I have *.fmp12 (first post). Now there is 4 records there. Field «Photo» is Container. I want all existing and brand new records with empty fields to hide them. It’s marks too. For example, I press ’New Record’ (5th record) then, if «Hardware Type», «Purchase Date» and «Cost» are empty - they become hidden then I press ’New Record’ (to make 6th record), like in screenshot (http://i.piccy.info/i9/b25d034ac3525b6cf0c6cb6fb252fe09/1426926591/37507/885890/pic_2.jpg).

            Very important to be able unhide one or few (or all) of empty fields to type information to them when it’s needed (with help of button, for example). Kind of reverse function for definite record.

            2) There is a field «Status» (green) and it’s mark (red) (http://i.piccy.info/i9/56748cfc229ac9e1b4d32f05dcc905ea/1426925197/67892/885890/S.jpg). When field «Status» changing to «spoilage» this record become some kind of link to layout («Screen» for example). The aim is: when user call record (or records) with «spoilage» typed in field «Status» or any other field of this record, he goes (automatically) to layout «Screen».

            The reverse button also needed (it can be button on the layout «Screen», for example) changing Status to non-spoilage one and make some kind of unlocking it for editing.

            • 3. Re: Scripts to hide fields in specific situation
              philmodjunk

              Ok I looked at the first screen shot, but it doesn't explain: " I want all existing and brand new records with empty fields to hide them. It’s marks too."

              first there's only one record visible as you appear to be in form view. "hide them" means hide the fields or hide the records?

              My best guess is that you want to selectively hide and show fields. As I have previously posted, this can be done with Hide Object When, but it's not clear to me what user actions will cause a field to appear or disappear.

              2) is also a bit unclear, but a question with "spoilage" came up earlier. Is this the same question? It's not clear if you are finding records, modifying them, or both. You can enter find mode and specify "spoilage" to find records. Quick find can search all records and fields of your layout for "spoilage"--though such seems poor data entry design. Replace field contents can update a field with a new value over all records in a found set produced by such a find. And there are also ways to use relationships and search portals to pull up a list of records in a portal that match specified search text. Clicking a portal row--if you set them up as buttons, can bring up the selected record in the portal in a form view where you can view and edit the details.

              • 4. Re: Scripts to hide fields in specific situation
                LoganSmart

                1) Ok, let it be "selectively". For example, a separate button for every field. Can you write sample of the script Hide Object When for this?

                2) The same. The idea is: when user goes to record with "spoilage" in "Status" field he faces a message "this good is spoilage" (or going to layout "Screen" with this text as i posted previously). It can be also realised by unhiding prepared text, that become visible when editor of database type (or choose prepared status in popup menu) word spoilage in the field "Status".

                • 5. Re: Scripts to hide fields in specific situation
                  schamblee

                  The Hide Object uses a condition.  If the condition is true it is hidden if not it is show.

                  I think you want to display a message that states "This Good is spoilage" if the status is spoilage.
                  If this is correct then create a new calculation field.  In my example I will called the field SpoilageMessage .  Your Calculation for this new field will be If(mytable::status="spoilage";"This good is spoilage";"")   then you would insert this field onto your layout as a merge field, and you do that in layout mode, by selecting Insert, Merge field, then select the calculation field SpoilageMessage.
                   

                  • 6. Re: Scripts to hide fields in specific situation
                    philmodjunk

                    If you want to use a button to hide or show an object on your layout, you can do it this way:

                    #To show an object otherwise not visible:
                    Set Variable [$$ObjectFlag ; value: True ]
                    refresh Object ["ObjectNameofLayoutObjectHere"]

                    Then, in layout mode, select that object and use the Inspector's Name box to give it an object name that you will use in place of "ObjectNameofLayoutObjectHere" in the above example. and then Give it this Hide Object When expression:

                    Not $$ObjectFlag

                    • 7. Re: Scripts to hide fields in specific situation
                      LoganSmart

                      There is a problem. I must import from other *.xls file about 10 000 records. That's why first script must hide all empty fields in the records automatically, but for each record must be ability to fill the fields if it needed and when it needed. After import it can be realised not automatically, but by editor of database. But only after import.

                      • 8. Re: Scripts to hide fields in specific situation
                        philmodjunk

                        Sorry but you just aren't providing enough detail for us to answer your questions. Hiding fields has nothing to do with how an import works. It sounds more like you want to hide all newly imported records from the general user until an editor reviews and approves each record. That is quite possible to do, but I am still guessing as to what you have and what you really want to do.

                        • 9. Re: Scripts to hide fields in specific situation
                          LoganSmart

                          PhilModJunk, Stacy Chamblee thank you very much! I've done it!