1 Reply Latest reply on Apr 20, 2015 1:31 PM by philmodjunk

    automatically creating a record based on a relationship as well as a checkbox field

    chf

      Title

      automatically creating a record based on a relationship as well as a checkbox field

      Post

      Hi there,

      I have three tables, one is an "Inventory" table, one is a "Removed Items" table, and the other is a "Item Use" table.  Each has its own layout.  Each item in the inventory has its on unique ID number, which is an auto enter serial number.  The "Item Use" table, is used to document when items are taken from the inventory and being used, so we have an accurate depiction of the actual items in our system. 

      The following relationships have already been set up:

      inventory::uniqueID = removeditems::uniqueID

                     This keeps track of an accurate number of units physically owned by the company

      inventory::uniqueID = itemuse::uniqueID

                     This keeps track of items that were used, but not actually removed from the company

      In the "item use" table, the user inputs the date, item unique id, and number of items used.  There is then another field where they enter whether the item was physically removed from the system.  It is a simple checkbox set with the values "yes" and "no".  What I want, is that if the unique ID number matches one that is in the inventory table (there are some cases that it may not be), AND the checkbox indicates "Yes" they were removed from the system, a new record is automatically created in the "removed items" table, that shows this information.

       

      Is this even possible?

        • 1. Re: automatically creating a record based on a relationship as well as a checkbox field
          philmodjunk

          What I want, is that if the unique ID number matches one that is in the inventory table (there are some cases that it may not be),

          That does not sound like a good thing.

          I'm not sure why you need the additional table to show removed items when you already have this info in your ItemUse table, but the following script would do what you request:

          IF [ Not IsEmpty ( FilterValues ( ItemUse::CheckBoxField ; "Yes" ) ) and Not Isempty ( Inventory::UniqueID )  //"Yes" was selected ]
              set Variable [ $ID ; value: ItemUse::UniqueID ]
              Set Variable [ $Qty ; value: Itemuse::Qty ]
              Go to Layout [ "removedItems" (removedItems) ]
              New Record/Request
              Set Field [RemovedItems::UniqueID ; $ID ]
              Set Field [ RemovedItems::Qty ; $Qty ]
              Go to Layout [original layout ]
          End If

          This script could be performed by the OnObjectModify trigger on the check box field.