2 Replies Latest reply on Nov 21, 2012 8:36 AM by BryanN

    Script to check field data entered

    BryanN

      Title

      Script to check field data entered

      Post

           So I'm trying to add a feature in which a script(s) checks a field in my Work Order table when it is modified (it's a value list pop up) and if it's status is changed to Closed, it will verify that all the related Purchase Orders status' in another table are closed as well. Right now, it's not working and it's letting me close jobs that have open POs.  Trying to find where I am going wrong.  Here's what I have so far:

           Using the script trigger OnModify for the field, the first script runs:

           If [Work_Orders::WO_Status = "Closed"]

              Perform script ["Check_POStatus_for_WOClose"]

           Else

             Commit records

           End If

            

           The second script (Check_POStatus_for_WOClose) is like this:

           If [Purcahse_Orders::PO_Status = "Closed"]

              Commit records

           Else

             Show custom dialog (explaining the error)

             Revert record/request

           End If

        • 1. Re: Script to check field data entered
          philmodjunk

               The context of your post implies that there can be multiple PO's for a given WO. Your script does not find all such PO's and check all their status.

               I suggest either using a script that performs a find for all PO's related to this WO that do not have a status of "closed" or defining a new, additional relationship from WO to PO that matches only to PO's that are not closed. With either method, if even one related PO is not closed, it will be found.

          • 2. Re: Script to check field data entered
            BryanN

                 Nice call.  Made a 'query' type relationship between the two that ensures only Open POs will be matched.  After that, as long as the status field isn't empty, it will call out the error. (POs can only be open or closed, they are auto-entered with data on creation).