8 Replies Latest reply on Apr 21, 2011 12:55 PM by Terri

    Dialog box leads to a dialog box

    Terri

      Title

      Dialog box leads to a dialog box

      Post

      I have a dialog box that comes up and asks why I changed a record and the user is asked to add a one-line comment explaining why they made the change. Sometimes this comment is not needed (if they are just updating a spelling error or something, that is not business critical and does not need to be updated). How can I have one dialog box come up that says "Do you want to record a comment" Answer Yes/No - if it is no, it does nothing. If it is Yes - it goes to my current dialog box.

        • 1. Re: Dialog box leads to a dialog box
          philmodjunk

          Show Custom Dialog ["Do you want to record a comment"] //specify Yes for button 1 and No for button 2
          If [Get ( LastMessageChoice ) = 1 // Yes was clicked]
             Show Custom Dialog ["Please enter a comment"]
          End IF

          Since you have three buttons you can use with your custom dialog, you could do all this with one custom dialog where you have both the input field for the comment and the two buttons.

          • 2. Re: Dialog box leads to a dialog box
            Terri

            This works in terms of one dialog box opening up, if the answer is yes than another dialog box opens. If it is no, then it does nothing - sort of. To catch others up who may view this, my dialog box asks if I want to record a comment as to why I made the change, then if a comment is entered, it records that comment in another table that I view through a portal, so I can see all the change comments for that record.

            Phil, when they select no, they don't want to record a comment, it still creates a new record in my change log (it is a blank record because no comment was left). I suspect it does this because I'm still telling the script to automatically enter the userid and the date/time. Is there a way to bypass that? I don't want a bunch of blank records. Is there any way to tell the script of the answer is no then it doesn't even go to the change log at all?

            • 3. Re: Dialog box leads to a dialog box
              philmodjunk

              You just have to expand the If Else Endif block to enclode the script steps appropriate to each response:

              Show Custom Dialog ["Do you want to record a comment"] //specify Yes for button 1 and No for button 2
              If [Get ( LastMessageChoice ) = 1 // Yes was clicked]
                 //put steps to create the new record here
                 Show Custom Dialog ["Please enter a comment"]
              End IF

              If you want to, you can do this all with just one dialog box:

              Define a global field for the comment and use it for your custom dialog's input field:

              Show Custom Dialog ["Enter a comment or click no"] //specify Yes for button 1 and No for button 2
              If [Get ( LastMessageChoice ) = 1 // Yes was clicked]
                 //Create new record steps go here
                 Set Field [Yourtable::commentfield ; Yourtable::GlobalInputfield ]
              End IF

              • 4. Re: Dialog box leads to a dialog box
                Terri

                I think it is best that I give all my script steps and then you can help me understand how this works. My main question is "create new record steps go here" - what is that? It doesn't make sense to me that the create new record steps are before the next dialog box. I'm trying to understand your first suggestion before I move on to the global field option (baby steps). So please explain further:

                Show Custom Dialog ["Record Change"; "Do you want to record a comment?"]
                If [Get (LastMessageChoice) = 1]
                  Show Custom Dialog ["Change Log"; "What did you change?"; Catalogs::gChangeNote]
                End If
                Set Variable [$I; Value:Catalogs::Media Code]
                Freeze Window
                Go to layout ["ChangeLog" (ChangeLog)]
                New Record/Request
                Set Field [ChangeLog::MediaCode; $ID]
                Set Field [ChangeLog::ChangeNote; Catalogs::gChangeNote]
                Set Field [Catalogs::gChangeNote; ""]
                Go to Layout ["Master Global SS11 Schedule" ( Catalog)]
                • 5. Re: Dialog box leads to a dialog box
                  philmodjunk

                  If you create the new record first, you can use the comment field of the newly created record for your input field. If you do not create the record first, you'd need to use a different field to temporarily hold the comment text until you create the new record and then copy the text into it--which is exactly how you've done it in your script. If you don't want a new record to be created in the change log table if the user clicks no, do it this way:

                  Show Custom Dialog ["Record Change"; "Do you want to record a comment?"]
                  If [Get (LastMessageChoice) = 1]
                         Show Custom Dialog ["Change Log"; "What did you change?"; Catalogs::gChangeNote]
                         Set Variable [$I; Value:Catalogs::Media Code]
                         Freeze Window
                         Go to layout ["ChangeLog" (ChangeLog)]
                         New Record/Request
                         Set Field [ChangeLog::MediaCode; $ID]
                         Set Field [ChangeLog::ChangeNote; Catalogs::gChangeNote]
                         Set Field [Catalogs::gChangeNote; ""]
                         Go to Layout ["Master Global SS11 Schedule" ( Catalog)]
                  End If

                  • 6. Re: Dialog box leads to a dialog box
                    Terri

                    Great, thanks! I thought that is what I did but for some reason I was getting an error message. This worked perfectly.

                    • 7. Re: Dialog box leads to a dialog box
                      philmodjunk

                      We discussed this ChangeLog concept before didn't we?

                      That earlier thread sparked an idea for setting up my own Audit Trail system with global variables, script triggers, etc. to log all changed values and enable the user to "roll back" or undo these changes step by step all the way back to the original blank record.

                      The idea looks promising and fairly easy to implement. It can even be used track multiple edits on multiple layouts for more than one table in the database, with all changes logged to the same changelog table. Still working out a few details such as support for edits to portal records, but the idea shows much promise.

                      For those interested, stay tuned, I'll post a download link in a new thread once I'm satisfied with how it works in all particulars.

                      • 8. Re: Dialog box leads to a dialog box
                        Terri

                        Yes, you have walked me through this entire process and made is so simple!! Your idea sounds great. I'll wait for updated posting!