12 Replies Latest reply on Nov 22, 2013 9:23 AM by philmodjunk

    field = field

    ryandunne_1

      Title

      field = field

      Post

           hey guys im trying to write a script where

           if text in field = text in related table field

           if its true i want it to do one thing and if its false do another

           but it doesnt seem to work if i do the obvious

           if[field=relatedfield]

                      go to layout2

                      else

                       run script again

            

           but i doesnt seem to work if the field is the same but it does if its empty

            

        • 1. Re: field = field
          philmodjunk

               "run script again" might be the problem as we have no way of seeing those details from your post.

               Also, we don't know the nature of your relationship and this could also be an issue.

               The syntax of your If step should be:

               If [LayoutTableOccurrence::Field = RelatedTableOccurrence::Field ]

               But that relationship could match the current record in the Layout's found set to multiple records in the related table. This expression, however, will only access the data in the first such related record.

               You may want to post the relative portion of your script.

               To post a script to the forum:

                 
          1.           You can upload a screen shot of your script by using the Upload an Image controls located just below Post A Answer.
          2.      
          3.           You can print a script to a PDF, open the PDF and then select and copy the script as text from the opened PDF to your clipboard for pasting here. (with this approach, you can get multiple script steps on the same line, please edit the pasted text by inserting some returns to separate those steps.)
          4.      
          5.           If You have FileMaker Advanced, you can generate a database design report and copy the script as text from there.
          6.      
          7.           If you paste a text form of the script, you can use the Script Pretty box in the Known Bugs List database to paste a version that is single spaced and indented for a more professional and easier to read format.
          • 2. Re: field = field
            philmodjunk

                 PS If you have FileMaker Advanced, I suggest opening the script debugger and dataviewer, then stepping through your script step by step while watching values change in the data viewer. This may pinpoint the issue very quickly for you.

            • 3. Re: field = field
              ryandunne_1

                   tada

              • 4. Re: field = field
                ryandunne_1

                     and nothing is in the table login

                      

                     and int he table login password i have

                     admin              admin

                     dan                   dan

                     ryan                  ryan

                      

                     in the data viewer its showing the field login password::password as empty

                • 5. Re: field = field
                  philmodjunk

                       Given that FileMaker has a built in security system for accounts and passwords, I don't see why you need to set up your own system but...

                       

                            in the data viewer its showing the field login password::password as empty

                       That would indicate that there is no related record that matches the current record of login. I would make sure than none of these 4 match fields are of type number and that the values in the fields of login password don't have any extra invisible characters (Such as a space or tab character)  that are keeping the records from matching as expected.

                  • 6. Re: field = field
                    ryandunne_1

                         ok there is no hidden characters and ive even tried to copy and paste it over to see if that does it but it still wont and it also doesnt explain why when i enter nothing at all it works

                    • 7. Re: field = field
                      philmodjunk

                           If there is nothing in the two fields in log in, then you get <nothing> = <nothing>

                           and this is a true statement. Thus your script will function as you are reporting.

                           Are there any records in the Log In table? If not, try creating one new record in LogIn and test your script again.

                      • 8. Re: field = field
                        ryandunne_1

                             there are apparently 2 records in the first table

                             see what im getting from my understanding is

                              

                             <nothing>=admin,dan or justin works and goes to next layout

                             <admin>=admin,dan or justin repeats and shows the dialogue

                              

                             its seems as though its working in completely the opposite way

                        • 9. Re: field = field
                          philmodjunk

                               You've indicated this:

                               

                                    in the data viewer its showing the field login password::password as empty

                               Thus, when you leave the Login::Password field empty, the expression in the IF step evaluates as: <empty> = <empty> and this will be true so the steps inside the IF block are executed.

                               Have you checked to be sure that all four match fields are of type text?

                               And are the fields on your LogIn layout truly from LogIn and not another table or table occurrence?

                               Are they formatted as edit boxes or are you selecting a value in either field from a value list?

                               Note: a quick test you can use while puzzling this one out is to place the Password field from LogIn Password on your LogIn layout. Then, without running the script, try entering different values into the user name and password fields already on the layout. If you can't get the right value to appear in the added field, you know that there's a relationship issue keeping this from working.

                               Hmmm, just noticed something in your script. Apologies for not noticing it sooner. Try this simple test: Enter your credentials on the layout, click a blank area of the layout and then continue the login script. If that works, then you just need to add a commit records step immediately after the pause step in your script.

                          • 10. Re: field = field
                            ryandunne_1

                                 ok ive not got it working with the admin dan and justin but it still lets it go through with nothing aswell and i also dont know what i did to get it half working

                            • 11. Re: field = field
                              philmodjunk

                                   Add an additional test to your IF:

                                   If [ Not IsEmpty ( Login Password::Password ) and Login::Password = Login Password::Password ]

                              • 12. Re: field = field
                                philmodjunk

                                     Can you explain why you are going to the trouble of setting this up instead of using Manage | Security to set up accounts and passwords?