5 Replies Latest reply on Mar 25, 2011 10:14 AM by philmodjunk

    Trigger delete of identical field name

    FlorianWiegand

      Title

      Trigger delete of identical field name

      Post

      Hello everyone,

      i have a drop down menu which does a value list look up of a table "vms". Once the vm is selected, it writes it into the field "vm name". On object exit i would like to trigger that the field in "vms" which has the identical name as what i selected from my value list gets removed. How do i do that?

      Thank you

      Florian

        • 1. Re: Trigger delete of identical field name
          philmodjunk

          Permanently removed (Delete the record) or temporarily removed (keep record, but don't show value in value list)?

          • 2. Re: Trigger delete of identical field name
            FlorianWiegand

            Hello Phil,

            both will work for me. I have a scrip which opens a script that imports from a SQL database to the "vms" table. I then use a value list on that table to pick a dataset to be selected and reserved. But once the system is reserved it will not show up at the next time the sql data gets imported. Thats why i would like to simply clean the whole table or erase only this specific data set.

            Thank you

            • 3. Re: Trigger delete of identical field name
              philmodjunk

              Ok, this is called a dwindling value list. You can search under that text to find other examples. Here's the basic outline of how I'd set this up:

              Put a script trigger on the drop down (OnObjectExit for drop down lists, OnObjectModify for pop up menus) to run a script. The script finds the matching record in VMS and either deletes the record or changes the value in a "mark" field so that records of values that are selected have a value different from those unselected. If you delete the record, you are done. If you choose to mark the record, (let's you recover from errors where you accidentally selected the wrong value), you set up a relationship between your two tables so that the value list is a conditional value list that uses this "mark" field to exclude selected values from the value list.

              You can find the record with Go To Related Record if you've defined a relationship between the two tables or you can copy the selected value to a variable, freeze the window, go to a layout for vms and then perform a find for the selected value.

              If you don't know how to set up a conditional value list:

              Custom Value List? (Forum Tutorial)

              http://help.filemaker.com/app/answers/detail/a_id/5833/kw/conditional%20value%20list (Knowledgebase Article)

              • 4. Re: Trigger delete of identical field name
                FlorianWiegand

                Dear Phil,

                thank you very much for your suggestions. I do have a script trigger on the menu which initiated the sql import to the table "vms". However if i add in the next step to go to the related record it wont work, nothing happens at all. Not even an error. Where can i find this "delete related record" ?

                Thank you

                Florian

                • 5. Re: Trigger delete of identical field name
                  philmodjunk

                  I don't think this should be part of the same script if I am understanding what you want to do here.

                  I thought you where importing to load the VMS table with records that populate a value list.

                  Then you were selecting values from a drop down of these values to do a second operation: "pick a dataset to be selected and reserved".

                  The script trigger on the value list needs to do this operation. Go To Related Recods will do the job, but it must be performed from the correct layout and with the correct relationship defined in Manage | Database | Relationship. I'd do this before doing any subsequent interaction with the SQL data source as that may leave you on the wrong layout for GTRR to work.

                  The other choice is a scripted find:

                  #current layout must be layout that refers to "YourTable" in Show Records From of Layout Setup...
                  Set Variable [$VMvalue ; YourTable::DropDownField]
                  Go To layout [//specify VMS based layout]
                  Enter Find Mode[] //clear pause check box
                  Set Field [VmsTable::VMValueField ; $VMvalue]
                  Perform Find[]
                  Delete Record
                  Go To Layout [original layout]

                  But you still have to make sure this starts from the correct layout.