12 Replies Latest reply on Mar 18, 2012 11:30 AM by philmodjunk

    Delete Record based by Multiple relation.

    bablahemen

      Title

      Delete Record based by Multiple relation.

      Post

      Hi,

      How can i delete an record based on 3 different i.e

      1) Ref no = Quote no

          2) Pcode = Scode

             3) Pqty = Sqty

                     Then Delete Record.

       

      I have made an script but its not working any how, kindly help me resolving it.

       

       

      block_Delete.gif

        • 1. Re: Delete Record based by Multiple relation.
          philmodjunk

          Do you want to delete a record from the Block Line Items table or DO Stock?

          DOQ_NO, DO_Item_Code, and DO_Item_Qty

          are all fields defined in DO Stock, but you are on a layout to Block Line Items.

          Do these three fields all have global storage specified?

          If not, what is the relationship between DO Stock adn Block Line Items?

          (That relationship will control how the expressions in your If steps evaluate.)

          Once we get that figured out, you can combine the three IF steps into one with an expression that uses And to compare all three pairs of fields in one expression in order to produce a simpler script.

          • 2. Re: Delete Record based by Multiple relation.
            bablahemen
             Base upon all this three field i want to delete record in the block item table. And both block & do table are not in relation with each other.
            • 3. Re: Delete Record based by Multiple relation.
              philmodjunk

              Without a relationship between the tables you cannot compare the values in this fashion unless DOQ_NO, DO_Item_Code, and DO_Item_Qty have global storage specified.

              • 4. Re: Delete Record based by Multiple relation.
                bablahemen

                Hi,

                I did the relation but then also its not deleting it. i want that it should find all possible set of data in Block Database which are in DO Database.

                Also when its finding, how can we check whether the record point is shifting the another record of DO to check for Records in Block.

                 

                Regards.

                Hemen

                • 5. Re: Delete Record based by Multiple relation.
                  philmodjunk

                  The "record point" will not "shift" unless the script does so.

                  I don't know enough about your database deisgn to have a clear picture of what you have. Here's a script that takes the current values for DOQ_NO, DO_Item_Code, and DO_Item_Qty on the current record on a layout based on DO_Stock and deletes all records with values that match all three fields from Block_Line_Items:

                  Note that this script need not be required if you are deleting a record from DO_Stock and want all matching records from Block_Line_Items to automatically be deleted. That can be done by setting up a delete option in a relationship that matches records on all three pairs of fields.

                  #Script must start from layout based on DO_Stock
                  Set Variable [$QNo ; value DO_Stock:: DOQ_NO ]
                  Set Variable [$ItemCode ; value DO_Stock:: DO_Item_Code ]
                  Set Variable [$Qty ; value DO_Stock:: DO_Item_Qty ]
                  Go to layout [Block_Line_Items]
                  Enter find mode[] //clear the pause check box
                  Set Field [Block_Line_Items::Block Ref ; $QNO]
                  Set Field [Block_Line_Items::Stock Code ; $ItemCode]
                  Set Field [Block_Line_Items::Block Qty ; $Qty ]
                  Set Error Capture [on]
                  Perform Find []
                  If [ Get ( FoundCount ) > 0 ]
                      Delete All Records   //This says Delete All records but actually deletes all FOUND records
                  End IF

                  • 6. Re: Delete Record based by Multiple relation.
                    bablahemen

                    Thanks a lot Phil. i implimented the script and its working fine, also can u help me with how Importing of PDF can be done.

                    • 7. Re: Delete Record based by Multiple relation.
                      philmodjunk

                      I suggest a new thread and please spell out what you want to do with the PDF in more detail. Do you need attach this PDF to a specific record or group of records? Do you want to insert a physical copy of the PDF file or just the FilePath? Will this be on a network? If networked do you have both mac and windows systems as clients of the database?

                      • 8. Re: Delete Record based by Multiple relation.
                        bablahemen

                        Hi Phil,

                        I want to import the PDF for the perticular record and this is visible over the network. i have an existing solution of importing the Image file, but users say its outdated so they want to import pdf file. can u guide me with this?

                         

                        Regards

                        HEMEN.

                        • 9. Re: Delete Record based by Multiple relation.
                          bablahemen

                          Hi Phil, sorry to say but the delete script is not working. can u help me with this, tel me what information you want i will provide you.

                          • 10. Re: Delete Record based by Multiple relation.
                            philmodjunk

                            First you post that it's working fine and now you post that it is not working. Has anything changed in the design of your database or were you mistaken in your earlier post?

                            How is it not working? (What does happen when you run the script?)

                            A description of your database would help. What is the purpose of these two tables? Why do you need to delete these records?

                            Posting a screen shot of manage | database | relationships might be a good start.

                            • 11. Re: Delete Record based by Multiple relation.
                              bablahemen

                              1) No change in database.

                              2) i dont see any error while running the script.

                              3) The two table purpose is that,

                              1) Table 1 = Block Order

                              2) Table 2 = Delivery Order

                               

                              My main purpose of delete/omit/import( to any other table) from Block Order is that when the related records from the Delivery Order are created, it should match the condition and do the needful base on it.

                              • 12. Re: Delete Record based by Multiple relation.
                                philmodjunk

                                This is not enough information for me to make any suggestions.

                                Did the script work before?

                                What is happening now that tells you the script did not work?

                                Your main purpose does not really make sense to me. Why do you need to find and delete records in order to "match the condition and needful base"?

                                What do you mean by "needful base"?

                                Originally, you said " both block & do table are not in relation with each other." Yet from this last post it would seem that they either are related or should be. A relationship defined in Manage | Database | relationships might well eliminate the need for a script that performs a find for the records.