8 Replies Latest reply on Jul 1, 2016 11:42 AM by siplus

    Record Flag

    EDP

      I have a contact database and the records data is used in several other tables via related fields. I would like to delete some of these records but not if the data is being utilized for records in other tables. Can a DO NOT DELETE flag be created that would highlight itself on the contact record if its _KP_ Customer_ Number existed in any other tables?

       

      Thanks for your help . Ed

        • 1. Re: Record Flag
          Mike_Mitchell

          Sure. Something like:

           

          Case (

               not IsEmpty (

                    relatedTable1::_KP_Customer_Number &

                    relatedTable2::_KP_Customer_Number &

                    relatedTable3::_KP_Customer_Number

                    ) ;

                    "DON'T DELETE ME!!!"

          )

           

          Naturally, you would probably want to exercise more control than this. Perhaps trap the deletion using the security setup or via a "delete" script (be sure to override the "delete record" command in the menu using Custom Menus if you choose this route).

           

          HTH

           

          Mike

          • 2. Re: Record Flag
            EDP

            Hello Mike,

             

            Thanks for the quick response. I am a novice at this and I tried your calculation 2 ways without success.

            First I created a text field named  (Do_Not Delete Flag) and created a conditional format using your Calc.

            Second attempt was to change the field to calculation field and I entered your Calc.

            The calculation was not rejected in either case.

            How is your calculation referencing the _KP_Customer_Number  in the client contact record?

             

            Case (

                 not IsEmpty (Receiving Data::_kf_Contacts_Customer_Number &

                 Shipment Request Data::_kf_Pickup_Contact_ID &

                     Shipment Request Data::_kf_Ship_to_Contact_ID

                      ) ;

                      "DON'T DELETE ME!!!"

             

            Thanks again!!

            • 3. Re: Record Flag
              Mike_Mitchell

              The calculation was an example based on the information you provided. I don't have access to your database, so I don't know what the structure looks like. Do you have a relationship to the other tables? The basic principle is you're looking to see if the primary key in the related table is empty or not. This tells you that a record exists "over there".

               

              So substitute the primary key of the related tables, in a calculation field, and it should work.

              • 4. Re: Record Flag
                EDP

                Hello Mike,

                 

                First, thanks again for your time.

                I do not understand what I should be substituting for the primary key.

                There is a relationship between the Customer table and the other tables.

                Based on there being only 2 tables.

                 

                Table 1  named (Customer_Contacts) -  with 2 fields named (KP_Customer_Contact_Number) and

                (Do_Not_Delete_Flag)

                 

                Table 2 named (Ship_Requests) - with 1 field named (KP_Customer_Contact_Number )

                 

                I am trying to get the (Do_Not_Delete_Flag) field in Table 1 to highlight red and display DO NOT DELETE if

                the (KP_Customer_Contact_Number) exists in a record in Table 2

                 

                Thanks again for your help.


                Ed

                • 5. Re: Record Flag
                  Mike_Mitchell

                  In Customer_Contacts, the Do_Not_Delete_Flag should be a calculation field equal to:

                   

                  Case (

                   

                       not IsEmpty ( Ship_Requests::KP_Customer_Contact_Number ) ; "DO NOT DELETE" ;

                       ""

                   

                  )

                  • 6. Re: Record Flag
                    EDP

                    Hello Mike,

                     

                    Your calculation works but only for 1 record and it happens to be record # 5 of 15,082.

                    Any thoughts?

                    • 7. Re: Record Flag
                      Mike_Mitchell

                      That doesn't give me much to go on. What "doesn't work"? What behavior are you seeing, and what are you expecting?

                      • 8. Re: Record Flag
                        siplus

                        - Disable record delete -> custom menus

                        - Put a delete button on the layout

                        - Hide it when not IsEmpty(List(yourFirstRelationship::pk) & List(yourSecondRelationship::pk)  & ....)