4 Replies Latest reply on Jul 21, 2009 9:21 AM by craig5005

    Odd Scripting Problem

    craig5005

      Title

      Odd Scripting Problem

      Post

      Hi

       

      I am having a small problem that I can't seem to find the answer to.  I am basically using the same principles/scripts as the Lending Library template that comes with FM pro adv 9 (and maybe others).  I am trying to set it up so we can deploy people out into the field, just as you would sign out a book in the Lending Library... have a deploy out date/time and deploy in date/time.  I have everything set up the same as the Lending Library and all the steps but one seem to work.  When I deploy a person to the field, the script creates a new record in "Member Deployment History" table and gets the current date and time.  That works fine... when they return, it adds the in date/time to that record.  The problem arises when they deploy again.  What happens is a new record is created with the out date/time, but when they come back in from the field, the in date/time is updated on the previous record, not the new/current one.  I will provide the scripting steps below (but keep in mind i am typing them from one window to the next, so there could be small errors.. ie. missing quotes)  The upper half is run when the person is not deployed, and the bottom half is when they come back.  I would like both possibilities to run from the same button, thats why I have to the two events running in the same script.

       

      If [members::Deployed="Not Deployed"]

          if members::deployable="yes"]

              set field [members::deployed;"DEPLOYED"]

              set field [members::gcontact ID; members::contact ID]

              Go to layout ["member deploy history" (member deploy history)]

              New record/request

              Set field [member deploy history::contact ID; members::gcontact ID]

              Set field [member deploy history::deploy out date; get(currentdate)]

              set field [member deploy history:: deploy out time; get (currenttime)]

              commit record/request

              go to layout [original layout]

         else

             show custom dialogue ["deployment"; "team member has not been medically cleared for deployment yet."

         end if

       

      else

           go to related record [from table: "member deploy history"; using layout: "member deploy history" (member deploy history)]

           set field [member deploy history::deploy in date; get(currentdate)]

           set field [member deploy history::deploy in time; get (currenttime)]

           set field [member deploy history:: flag deployed out; ""]

           go to layout [original layout]

          set field [members:: deployed; "Not deployed"

      end if