7 Replies Latest reply on Mar 29, 2012 9:30 AM by philmodjunk

    Create Custom Dialog If Two Conditions Are Met

    JoanneVermulm

      Title

      Create Custom Dialog If Two Conditions Are Met

      Post

      I am developing a check in/check out system for laptops.

      A record is created each time an item is checked out (in Table AssetStatus). However, if that particular item is already checked out and the barcode number is entered into the AssetBarcode# field, I would like a custom dialog to popup to indicate that item is already checked out.

      I am determining the status of the laptop based on whether that barcode number is found in any previous records in that table and if the CheckIn Date is blank (indicating it is still "out").

      I would like the barcode field to assess the barcode number once the field is exited.

      I currently have a Table called AssetStatus to a duplicate table of AssetStatus (called AssetStatusCheckBarcode) linked by an equal relationship of AssetBarcode#.

      Any help would be greaty appreciated.

      • 0. Re: Create Custom Dialog If Two Conditions Are Met
        philmodjunk

        Scan or enter the barcode into a global field: gBarCode, then use this script:

        Go to Layout [AssetStatus]
        Enter Find mode []
        Set field [AssetStatus::AssetBarcode#; YourTable::gBarCode]
        Set Field[AssetStatus::CheckIn Date ; "=" // finds for cases where field is empty]
        Set Error Capture [On]
        Perform Find[]
        If [Get (FoundCount ) // item is checked out]
           Go to layout [original layout]
           Show custom dialog ["Item is checked out"]
        Else
            Put steps here to check out the item here
        End If

        • 2. Re: Create Custom Dialog If Two Conditions Are Met
          JoanneVermulm

          Thank you so much for your quick reply ~  A couple of questions...

          1) To clarify - gBarCode field is a new field i need to create in the AssetStatus Table, correct?

          2) What is "FoundCount"?

          3) When a type in the barcode of a new, not-previously-existing barcode#, it returns with message "Item is already checked out"...

          If an existing item has already been checked back in (and we're trying to check it out again) it gives the "Item is aleady checked out" message.

          4) After clicking OK on the popup (when an item has actually already been checked out), I'd like it to highlight the AssetBarcode field again so the person can type in a new barcode. At this time, when I click the OK button, it goes back to the last record where the item was checked out.

          I am so appreciative of your help!

          • 3. Re: Create Custom Dialog If Two Conditions Are Met
            philmodjunk

            1) gBarCode is a field that should have global storage specified in field options. Unless you use it in a relationship (and you might, see 3 below), you can define it in any table in your database. It's often useful to put all such fields (IF not used in a relationship), in their own Globals table so that you can more easily keep track of them.

            2) Get ( FoundCount ) is a get function your can research in FileMaker Help. There are many useful get functions so it's worth the time to browse through them once in awhile to see what's there. When the "foundCount" parameter is specified for the get function, you get the number of records in your current found set as produced by performing the find in this script. This is the same number that can be seen near the "book" control in the status area at the top of your screen.

            3) Yes. More sepecifically if there is no record with this barcode number in the Asset Status table, you'll get that result. Unless you've set this up so that every record in the asset table automatically gets a related record in Asset Status, you may need to add an additional check for the existance of the record in the Asset table--creating a new Asset Status record if one is needed and displaying an error message if an Asset with that number does not exist.

            Of course, it may be that you only have an Asset Status table here. If so, then you just need to detect the fact that the entered/scanned number does not exist in Asset Status and then display the appropriate message.

            In either case, one way to check for the existance of an Asset (or Asset Status) record is to define a relationship between the table where gBarCode is defined and the AssetBarcode# field in Asset (or Asset Status). Then an if step like this:

            If [ IsEmpty ( Asset::AssetBarcode# ) ]

            Will tell you that no asset with that barcode number exists.

            If an existing item has already been checked back in (and we're trying to check it out again) it gives the "Item is aleady checked out" message.

            This should not happen. Better check the records in Asset Status to see if you might have an extra Asset Status record with the specified barcode number but an empty CheckInDate field. Also, make sure that gBarCode has global storage specified as this will keep the script from working also. You can inspect the records found by this script by temporarily disabling or removing the Go to Layout [original layout] and Show All Records step. This way, you are left on the Asset Status layout and can examine each record found by the script to see why it didn't work.

            4) You can use go to Field to put the cursor back into the gBarCode field. You can click the Select/Perform checkbox to select the current contents of the field.

            • 4. Re: Create Custom Dialog If Two Conditions Are Met
              JoanneVermulm

              I was trying to keep this as simple as possible, but I'm going to add another layer here.

              I also have a table called Assets which contains all the assets we have in inventory. Could I have it first check this table to verify this is an existing number, then check the AssetStatus table to see if it is checked out?

              I'm sorry to complicate things.... I was trying to use the KISS method....

              Any specific code you can provide is again TREMENDOUSLY appreciated. I worked with Access back in the day, but my little brain is having trouble bringing it all back to the surface.

               

              Smile

              • 5. Re: Create Custom Dialog If Two Conditions Are Met
                philmodjunk

                You did read my last post?

                Quoting from it:

                "one way to check for the existance of an Asset (or Asset Status) record is to define a relationship between the table where gBarCode is defined and the AssetBarcode# field in Asset (or Asset Status). Then an if step like this:

                If [ IsEmpty ( Asset::AssetBarcode# ) ]

                Will tell you that no asset with that barcode number exists."

                If you have this relationship:

                Asset Status::gBarCode = AssetsScanCheck::AssetBarcode#     

                AssetsScanCheck can be a separate occurrence of Assets. You click Assets in Manage | Database | Relationships and then click the duplicate button (two green plus signs) to created it. You can double click the new occurrence to open a dialog where you can rename it like I have. This does not duplicate the table, it just produces a new way to refer to it.

                Your script can then use:

                If [ Not IsEmpty ( AssetsScanCheck::AssetBarcode# ) ]

                # Put your current script steps here

                Else
                   Show Custom Dialog ["An asset with that code does not exist."]
                End IF

                • 6. Re: Create Custom Dialog If Two Conditions Are Met
                  JoanneVermulm

                  So I did read your last post.... thank you again, I'm just not very good at logical thinking.

                  I created a relationship between gBarCode in AssetStatus and Barcode# in Assets as you suggested above.

                  Could you kindly write the code in with the If [ isEmpty (Asset:AssetBarcode#) ] where I should insert it within the code I already have established alog with the other suggested if [Not isEmpty (AssetsScanCheck::AssetBarcode#) ]?

                  Line-for-line is basically what I'm asking. Again, I apologize for being so fundemental.

                  Here's what I have now...

                  Go to Layout [AssetStatus]
                  Enter Find mode []
                  Set field [AssetStatus::AssetBarcode#; AssetStatusCheck::gBarCode]
                  Set Field[AssetStatus::CheckIn Date ; "=" // finds for cases where field is empty]
                  Set Error Capture [On]
                  Perform Find[]
                  If [Get (FoundCount ) // item is checked out]
                     Go to layout [original layout]
                     Show custom dialog ["Item is checked out"]
                  Else
                      Put steps here to check out the item here ?????? Wasn't sure what I could put here...
                  End If

                  • 7. Re: Create Custom Dialog If Two Conditions Are Met
                    philmodjunk

                    Go to Layout [AssetStatus]
                    If [Not IsEmpty ( Assets 5::Barcode#) //Asset with this code exists ]
                      Enter Find mode []
                       Set field [AssetStatus::AssetBarcode#; AssetStatusCheck::gBarCode]
                       Set Field[AssetStatus::CheckIn Date ; "=" // finds for cases where field is empty]
                       Set Error Capture [On]
                       Perform Find[]
                       If [Get (FoundCount ) // item is checked out]
                         Go to layout [original layout]
                         Show custom dialog ["Item is checked out"]
                       Else
                        Put steps here to check out the item here ?????? Wasn't sure what I could put here...
                       End If
                    Else
                        show Custom dialog ["No asset with this barcode exists."]
                    End If

                    I can't tell you exactly what to put in place of the red text as that depends on the design of your database. Once you have scanned the barcode and determined that the asset is not checked out, you presumably need to make additional changes to show the asset as checked out. At the very least, you would assign a check in date. Presumably you also have either fields or a related record where you record who has borrowed the asset. However you have set that up will determine what steps your script will need to take to check out the asset.