3 Replies Latest reply on Apr 14, 2016 8:46 AM by jthulin

    Script to delete related records from other db after import

    jthulin

      I would like to have a script whereby:

       

      1. Import records from Database A into Database B (relationship of records is established on import via a record id)

      2. Delete related record in Database A

       

      I tried the following (working in Database B):

      Import Records [ "Database A" ; Add ]

      Go to Related Record [ Show only related records ; From table: "Database A Table" ; External ; Using layout: "Database A layout" ; New window ]

      Delete Record/Request

       

      This script imports the record from Database A but then deletes the imported record in Database B rather than the related record in Database A. So I then before the delete step I added:

      Select Window [ Name: "Name of Window Specified in Go to Related Record step" ]

       

      But got precisely the same result. Suggestions?

       

      Using FMA 14 and FMS 14.

       

      Many thanks in advance.

        • 1. Re: Script to delete related records from other db after import
          erolst

          You cannot delete records in table A using a script in table B.

           

          Either create and call a script in table A to do the job, or (simpler) create a layout in table B that is based on the related table occurrence, and use that as the target layout for GtRR; then delete the found set.

          • 2. Re: Script to delete related records from other db after import
            dtcgnet

            I can see where you might want to:

            1. Import records from Database A into Database B (relationship of records is established on import via a record id)

            2. Delete related record in Database A

             

            If your script in Database B opens Database A, then returns to the window for Database B and Imports Records from Database A, whatever is in the found set in Database A will be imported into Database B. If you select a subset of A, then go to B and import from the open A, then the found set in A will remain as it was, and that found set will be imported into B, remaining as the found set when the import is complete. If your script then returned to the window for database A, and deleted all records, then you'd have a found set in A with 0 records, and any previously omitted records would remain in A. In B, the imported records would be in the foundset in B.

             

            By the way, in your script, there is a place where you say:

             

            Import Records [ "Database A" ; Add ]

            Go to Related Record [ Show only related records ; From table: "Database A Table" ; External ; Using layout: "Database A layout" ; New window ]

            Delete Record/Request

             

             

            The Delete Record/Request would only delete one record, and it would do it in whichever table the layout is based on.

             

            This is one of those...BE CAREFUL places.

            • 3. Re: Script to delete related records from other db after import
              jthulin

              Thanks for the responses. It's working just fine now using a layout based on the related table occurrences.