9 Replies Latest reply on Dec 8, 2009 8:57 AM by philmodjunk

    Show Custom Dialog Question

    CraigFiore

      Title

      Show Custom Dialog Question

      Post

      Hello,

      I have created a script with "Show Custom Dialog" and I am using the Input fields to insert infromation.  However, the only way i can do this is by having the Input fields be used by Button#1. I would like to have button #2 do the input.

       

      Is there a way to control which button which button controls which field to be input? 

       

      Craig 

        • 1. Re: Show Custom Dialog Question
          ninja
            

          Howdy,

           

          If [ Get(LastMessageChoice) = 2 ]

           

          and name the buttons in the Custom Dialog pop-up.

           

          Or do I misunderstand?

          • 2. Re: Show Custom Dialog Question
            CraigFiore
              

            Hello Ninja,

            I think i have that or am i mission something. Do I have to actually put the name of the button somewhere?

             

            Button #1 is called "Auto Number" 

            Button #2 is called "Own"

            Button #3 is called "Cancel" 

             

            Here is what my script looks like.  

            Let me know if the image did not come through.

             

            Thanks 

            • 3. Re: Show Custom Dialog Question
              ninja
                

              Howdy Craig,

               

              I can't see the image of your script.  Either type out the pertinent parts, or all of it, or I've heard that Advanced can let you copy and paste the script as text (search the forum for "Posting Scripts").

               

              I'm on FMP8...keep that in mind as it may make a difference on where things are located:

              In Scriptmaker, on the Show Custom Dialog step there is a "Specify" button.  Click this and it lets you edit your button labels.  Use these to, well, edit your button labels. ;)

               

              You do not have to put your button label in the script functions...Get (LastMessageChoice) works on button number (1,2,3)

              • 4. Re: Show Custom Dialog Question
                CraigFiore
                  

                Thanks for your help Ninja,

                Looks like a found a way around it, but from what I see, only the #1 button will work the fields. I can not get Button #2 to work the field input.

                 

                Do you know much about Loops. I am having an issue with that now. 

                • 5. Re: Show Custom Dialog Question
                  ninja
                    

                  CraigFiore wrote:

                  I can not get Button #2 to work the field input.


                  Button #2 doesn't work a field input, it continues your script with a Get (LastMessageChoice) = 2.  The field input is a different item.

                  What is it you're trying to do, and how are you picturing it working...lets go from there.

                   

                  Loops...very easy, very effective when used well and very dangerous if used poorly.  Make backups regularly while building with them (make backups regularly no matter what).

                  Please describe what you're trying to do with loops...what is it you're trying to accomplish?

                  • 6. Re: Show Custom Dialog Question
                    CraigFiore
                      

                    The first part of your last entry, answered my question. But Im not worried because i did it another way.

                     

                    Loops!!

                    Here is a copy of my current script:

                     

                    Show All Record

                    Copy [Select;Workorder::cJobIDMaxplus1]

                    New Record

                    Show Custom Dialog["Serial Number Choice"………]

                       If[Get(LastMessageChoice=1]

                       Paste[Select;….]

                       Go to Field[…]

                       If[ Get(LastError)=401]

                    End If

                    Show Custom Dialog["Error"………]

                    End If

                    If[Get(LastMessageChoice=2]

                    Delete Record/Request

                    End If 

                     

                    Here is how it is suppose to work.

                    When the script is activated, it will create a new record, then give the user a choice to use the next serial number in line or create a custom number based on the job.

                    This issue I am having is:

                    If the custom number entered us used, the 2nd Show Custom Dialog kicks in and give a message to choose another number. Which is fine, but if the second number entered has also been used, the script just ends.

                    I think i need a loop in there somewhere. 

                     

                    I hope i explained this ok. 

                    • 7. Re: Show Custom Dialog Question
                      ninja
                        

                      Howdy Craig,

                       

                      Show All Records ##Not needed, but does not harm

                      Loop

                      Show Custom Dialog["Serial Number Choice"……{field = myfield}…]

                      ##Bailout clause

                      If[Get(LastMessageChoice=2]

                         SetField [ myfield ; "" ] ]## clear out the field before exiting

                         Exit Script

                      End If 

                      ## Check the number to verify it is unique

                      If[Get(LastMessageChoice=1]

                         Set Variable [$test ; Value: myfield ]

                         Enter Find Mode[]

                         SEtField [ Workorder::cJobIDMaxplus1 ; $test ]

                         Set ErrorCapture [on]

                         Perform Find

                      ## Make the record and add ID to it if unique

                         If [ Get (FoundCount) < 1 ]

                            New Record/Request

                            SEtField [ Workorder::cJobIDMaxplus1 ; $test ]

                            SetField [ myfield ; "" ]## clear out the field before exiting

                            Exit Script

                         EndIf

                      EndIf

                      SetField [ myfield ; "" ] ## clear out the field and let them try again

                      End Loop

                       

                      Note: "myfield" as shown above should be a new field that isn't used for anything else.  It will only serve the purpose of a placeholder in this script.  I would recommend that it be set to global storage.

                      Note: Copy&Paste use the computer's clipboard and involve risk...use Set Variable and SetField instead.

                       

                      Note: Workorder::cJobIDMaxplus1 shouldn't be a key field in a relationship if you're letting folks choose thier own.  Let them choose whatever they want, and show it to them wherever you want, but use an autoenter serial for your keyfield.  That way you can change your mind later about the job# without crashing your Dbase or breaking relationships.

                       

                      Is that what you were after?  Remember, many ways to skin a cat...there are other ways to do it, this is one.

                      • 8. Re: Show Custom Dialog Question
                        CraigFiore
                          

                        Thank you for your help. But, I just received the news, the higher ups here at the company don't like the idea of putting in numbers that way. So I wont be continuing with this script.

                         

                        But you were very helpful.

                         

                        • 9. Re: Show Custom Dialog Question
                          philmodjunk
                            

                          "...the higher ups here at the company don't like the idea of putting in numbers that way..."

                          If this is a security concern, be advised that there is a "password" option for your input fields that will echo the input with bullets instead of the actual numbers.

                           

                          If this is a layout issue (custom dialogs are extremely limited), You can also work up a dialog pop-up of your own using the New Window script step. Since this step opens a new Filemaker window that displays its contents in a Filmaker layout, you have all the options of any other Filemaker Layout to format fields, add scripted buttons etc and this, though a bit clunky in windows environments, can thus work in situations where a custom dialog just won't cut it.