13 Replies Latest reply on Aug 19, 2009 4:14 PM by philmodjunk

    how would i script this...

    Sketter

      Title

      how would i script this...

      Post

      I created a radio button with a Yes/No value list.

       

      I want to be able to when Yes is selected, the Persons name is added to a value list if not already in that value list.  If selected no, removes from the list if not already removed.

        • 1. Re: how would i script this...
          philmodjunk
            

          Define a calculation field:

           

          If ( Radiobuttonfield = "yes" ; Namefield ; "" )

           

          Set up your value list to display values, specifying this new calculation field as the source of values.

           

          If you click "yes" on the radio button field, it will be included in the list. If you do not click "yes", the name field of the current record will not supply a value to the list.

          • 2. Re: how would i script this...
            Sketter
              

            i think i'm missing something.

             

            the Dropdown shows "yes" and not the name.

            • 3. Re: how would i script this...
              philmodjunk
                

              Sketter wrote:

              i think i'm missing something.

               

              the Dropdown shows "yes" and not the name.


               

              Sounds like the IF calculation is returning the contents of the wrong field. It should refer to the field that stores your values, not the formatted radio button field.

               

              If you can't figure it out, post your calculation to the thread along with the names of the fields you are using.


              • 4. Re: how would i script this...
                Sketter
                  

                So I got somewhere, but not sure if I did this right.

                 

                This is what I have.

                 

                In calculation, in the C_Leader field I have this.

                If ( C_Leader = "yes" ;Name_Full ; "" )

                 

                These are my fields

                "C_Leader" = Radio Button

                "C_under" = Pop up box.

                "Name_Full" = Full name field

                 

                 

                Value List 

                List is being specified by C_Leader

                 

                So I do get a list now, but the Radio buttons blank out. I don't know if this is a bug within filemaker.  The Full name is added, and shows on the pop up, but the Radio button clear out, as if it was null.

                • 5. Re: how would i script this...
                  philmodjunk
                     Your calculation and radio button fields must be separate fields. Do that and it'll work.
                  • 6. Re: how would i script this...
                    Sketter
                      

                    Works great thank you!

                     

                    A few formatting questions.

                     

                     I want to add not only the name, but also another field name.  However that field name is a populated field.  My calculation looks like this.

                     

                    If ( C_Leader = "yes" ;Name_Full  & HotelIDfk; "" )

                     

                    So what ends up happening is i get a Name, and then a number, how do i get it to display the Name and not the number?

                    • 7. Re: how would i script this...
                      philmodjunk
                        

                      "...how do i get it to display the Name and not the number?"

                      I must be missing something in your question. HotelIDfk would appear to be a number field. If you don't want the number, don't include that field in your expression. Since that takes us full circle back to the original expression, I think there's a key fact missing in your posted question.

                       

                      Can you give an example of what you want to have happen here?

                      • 8. Re: how would i script this...
                        Sketter
                          

                        Sorry I didn't explain that well.

                         

                        HotelIDfk is a pop up specified value list of HotelID, with a second field specifying Hotel_Name. (HotelID and Hotel_Name are in a different table.

                         

                        Hope this makes sense.

                        • 9. Re: how would i script this...
                          philmodjunk
                            

                          That adds another piece of data, but the full picture is still incomplete.

                           

                          Is Full_Name a person's name?


                          What do you want to see in your value list?

                          • 10. Re: how would i script this...
                            Sketter
                              

                            So I would want to see  "Full Name, Hotel"  Full Name is some ones full name yes.

                             

                            The list will get quite big, so I need be able to differentiate by Hotel, so that is why i want that part of the list.

                            • 11. Re: how would i script this...
                              philmodjunk
                                

                              In your value list, do you want the hotel name in a second column or the same column as "full name"?

                               

                              In either case, you need to store the contents of Hotel Name in an indexed text field that's part of the same table as your Full Name field. I'm guessing you already have a relationship that looks something like: MainTable::HotelIDfk = HotelTable::HotelIDpk

                               

                              Using this relationship, you can define a new text field, HotelName, in MainTable and set either a lookup or calculated auto-enter option to copy the Hotel name from the matching related record. You can't just refer to the related table's Hotel Name field in your calculation because that forces your calculation to be unstored and you can't use an unstored calculation as a data source for your value list.

                               

                              Both Full Name and Hotel Name in one column:

                               

                              Modify your calculation to read Full Name & ", " & HotelName where we originally just had Full Name in the If function.

                               

                              Full Name and Hotel Name in two columns:

                              Make a 2nd calculated field: If (RadioButtonField = "Yes" ; HotelName; "" )

                              In your value list setup, just specify this second calculation field as your second column of values.

                               

                              Sometimes as the full requirements of a solution become evident, other options become more appropriate. You can also get the same results by using a relationship that includes your radio button as a key field. You might also want to investigate Conditional Value Lists. You can set up your value list so that once you select a hotel, your value list would only list full names from the same hotel. That might prune your value list down to a much shorter list of values.

                              • 12. Re: how would i script this...
                                Sketter
                                  

                                Some of what you said was interesting, especially the "Conditional Value Lists".

                                 

                                Everything works great, but I noticed one thing.  If a person was set to yes as a leader, and a group of people had that person selected in the pop up box. Once that leader was removed, the other people who had that leader marked still had the leader selected.  

                                 

                                Is there a way so if that person falls back to No, that everyone else that had that leader selected becomes reset to nothing, or better yet, (for find sorting) auto select them to a defined value? So in other words, If C_leader becomes no, everyone that had that leader selected in the value list gets reset to a null value, or ideally a defined value/name.

                                 

                                Is all this doable, and if so how?

                                 

                                (you have been a great help so far man thank you!)

                                • 13. Re: how would i script this...
                                  philmodjunk
                                    

                                  I think you'd need to script that.

                                   

                                  If you're using FMP 10, you might set up a script that is triggered when you modify the Radio button field.

                                   

                                  Since you know the value of the affected field where you need to do an update, you should be able to script a find operation that locates these records so that your script can update the field.