5 Replies Latest reply on Apr 5, 2013 1:41 PM by philmodjunk

    Flagging a parent record

    EP

      Title

      Flagging a parent record

      Post

           Is there a way to flag a parent record? Let me explain.  I have a one to many relationship (Client---<Orders).  If ANY of the Orders records contain a certain value in a field, I want the Client record calc field (Clients::cFlagged) to display "Complete."  Not the best example but you get the idea.  If I simply set Clients::cFlagged= If (Orders::Status = "Complete" ; Complete") I believe the parent record will only reference the last related record; I want it to reference ALL related records.

           Thanks

        • 1. Re: Flagging a parent record
          philmodjunk

               Actually, it will only refer to the First related record.

               There are several ways to make your calcualtion field work, but why not move the status field from Orders to Client? You can still put the field on your orders layout, but now any effort to change this field will change it to the same value for all related orders records.

               If you insist on your calculation field you can use one of these two approaches:

               1) in the relationship for Client to Oders, specify a sort order that sorts the related records to make any orders record with status="complete" either the first or last related record. With it sorted to be the first related record, your If function will work for you. If you make it the Last related record, you can often use the Last function to check for a record with a complete status.

               2) Use this calculation: Not IsEmpty ( Filtervalues ( List ( Orders::Status ) ; "Complete" ) ) to detect that at least one related record has this status.

          • 2. Re: Flagging a parent record
            EP
                 

            but why not move the status field from Orders to Client?

            Yea, I am actually trying to trak the day a project was completed.  So when a user inputs a work record for a project, I want to have a checkbox where they can mark it as complete from the related work record.  This would allow managers to see what day the project was completed on and what work occurred that day.  The calc field would mark the project as "complete."

            Is there a best practices for this situation that I am not aware of?

            Thanks

            • 3. Re: Flagging a parent record
              philmodjunk

                   I still see no reason why the field would not be defined in the parent record.

              • 4. Re: Flagging a parent record
                EP
                     

                2) Use this calculation: Not IsEmpty ( Filtervalues ( List ( Orders::Status ) ; "Complete" ) ) to detect that at least one related record has this status.

                Can this calc be used to detect the first related record with a field that is not empty and return data from another field in that record to the parent record?  I'm having trouble getting it to work. Calc field in the parent table looks like this: not IsEmpty ( FilterValues ( List ( ( orders::Units ) ) ; orders::Date ) ) 

                     The related table is sorted by ascendng date via relationship sorting

                • 5. Re: Flagging a parent record
                  philmodjunk

                       It checks for the presence of any related record, first, middle last, that has that value.

                       But your expression doesn't seem set up correclty. I see:

                       FilterValues ( List ( ( orders::Units ) ) ; orders::Date )

                       Orders::Date refers to the date in the first related record. List ( Orders::Units) produces a return separated list of all values found in the Units field of all related records. Don't see how a date from the first related record would ever match to any value in a Units field.

                       And I STILL see no reason to use this approach when you can modify a field in the parent record instead.