5 Replies Latest reply on Mar 19, 2012 1:45 PM by philmodjunk

    Identical Script Gives Error While 1st Script Doesn't

    VeronNovosad

      Title

      Identical Script Gives Error While 1st Script Doesn't

      Post

      Can anyone tell me why the following script provides me with the reports for the specified criteria,

       Enter Find Mode [  ]

      Set Field [ MSDS::Chemical; "" ]

      Set Field [ MSDS::Manufacturer; "" ]

      Show Custom Dialog [ Title:"Enter Search Parameter"; Message: "Enter the chemical or manufacturer below:"; Buttons:“OK” , “Cancel”; Input #1:MSDS::Chemical :"; Input #2:MSDS::Manufacturer, "Manufacturer" ]

      If [ Get ( LastMessageChoice) = 1 ]

      If [ IsEmpty ( MSDS::Chemical ) = 0 ]

      Go to Layout [ “MSDS Report by Chemical” (MSDS) ]

      End If

      If [ IsEmpty ( MSDS::Manufacturer ) = 0 ]

      Go to Layout [ “MSDS Report by Manufacturer” (MSDS) ]

      End If

      Perform Find [  ]

       Sort Records [ Specified Sort Order:MSDS::Chemical MSDS::Manufacturer [ Restore; No dialog ]

      End If

       And the following identical script provides me with the error shown below?

       Enter Find Mode [  ]

      Set Field [ Chemical Inventory::ChemicalInInventory; "" ]

      Set Field [ Chemical Inventory::InventoryOfFacility; "" ]

      Show Custom Dialog [ Title:"Enter Search Parameter"; Message: "Enter the chemical or facility below:"; Buttons:“OK”, “Cancel”; Input #1: Chemical Inventory::ChemicalInInventory Input #2:Chemical Inventory::InventoryOfFacility, "Facility" ]

       If [ Get ( LastMessageChoice) = 1 ]

      If [ IsEmpty ( Chemical Inventory::ChemicalInInventory) = 0 ]

      Go to Layout [ “Chemical Inventory by Specific Chemical Report” (Chemical Inventory) ]

      End If

      If [ IsEmpty ( Chemical Inventory::InventoryOfFacility ) = 0 ]

      Go to Layout [ “Chemical Inventory by Specific Facility Report” (Chemical Inventory) ]

      End If

      Perform Find [  ]

      Sort Records [ Specified Sort Order:Chemical Inventory::ChemicalInInventory Chemical Inventory::InventoryOfFacility [ Restore; No dialog ]

      End If

       Error Shown

      The provided find criteria is not valid. Enter a valid request before proceeding.

       

        • 1. Re: Identical Script Gives Error While 1st Script Doesn't
          philmodjunk

          Is a layout that specifies "Chemical Inventory" in Layout Setup | Show Records From the current layout when you perform the second script?

          • 2. Re: Identical Script Gives Error While 1st Script Doesn't
            VeronNovosad

            The MSDS script has two layouts setup, one for a chemical search report and the other for a manufacturer search report.

            The dialog asks you to either enter a chemical or manufacturer and then is directed to the appropriate layout.  This works.

            In the same sense, the dialog for the chemicals in inventory script asks for either a chemical or a facility where the chemical is located.

            I have also set this script to go to either a chemical search report or a facility search report. However, I keep getting an error saying the find criteria is not valid.

            The only difference between the two scripts is that the MSDS script is launched from the MSDS list view and the chemical inventory script is launched from the chemical list view.

            • 3. Re: Identical Script Gives Error While 1st Script Doesn't
              philmodjunk

              That's not the point.

              The layout that is current BEFORE the script starts up can make a difference in whether or not it correctly executes.

              In both scritps, these steps:

              Set Field [ MSDS::Chemical; "" ]
              Set Field [ MSDS::Manufacturer; "" ]
              Show Custom Dialog [ Title:"Enter Search Parameter"; Message: "Enter the chemical or manufacturer below:"; Buttons:“OK” , “Cancel”; Input #1:MSDS::Chemical :"; Input #2:MSDS::Manufacturer, "Manufacturer" ]

              Refer to fields in a table before the script ever specifies a specific layout. In the first script, the layout that is current when the script starts should refer to MSDS.

              In the second script, the layout that is current when the script starts up should refer to Chemical Inventory.

              • 4. Re: Identical Script Gives Error While 1st Script Doesn't
                VeronNovosad

                Thanks for the 2x4 to the back of the head!

                I did have the wrong current layout.

                Thanks again.

                • 5. Re: Identical Script Gives Error While 1st Script Doesn't
                  philmodjunk

                  Also, you can delete these script steps:

                  Set Field [ MSDS::Chemical; "" ]
                  Set Field [ MSDS::Manufacturer; "" ]

                  Entering find mode produces empty fields automatically unless they have global storage specified.

                  It also looks like you need to add some code that checks for when the cancel button is clicked so that this option returns you to browse mode, etcrather than leaving the user in find mode.

                  With such scripted finds, I usually specify different fields with global storage for the input fields, then enter find mode after the custom dialog box is dismissed with OK. The sript would enter find mode and use set field to copy the data from the global fields into the matching non global fields and then performs the find to pull up the appropriate set of found records.