2 Replies Latest reply on Oct 11, 2014 4:30 PM by mvreade

    Updating Related Records

    mvreade

      Whenever a record is modified, created or deleted, I need figure out which of the records has the most recent date. That one gets tagged as "Current" and the others get tagged as "History".

       

      I have a One_cn calculated number = 1, and a G_One_cn global number that = 1 too. These two fields form a relationship sorted by Date in descending order. And it's through that relation that I run the script. It first replaces all records with "History", then updates the related record to "Current".

       

      This works fine on modifying existing records and deleting records, but doesn't work on commit when I'm creating a new record. I'm thinking that perhpas the new record hasn't been indexed yet to be part of a relationship.

       

      Is that correct? If so, anyway around it? I tried to add the commit record script, but then I was getting into an infinite loop (as this runs on commit in the layout).

       

      Thanks,

      Michael Reade

        • 1. Re: Updating Related Records
          erolst

          mvreade wrote:

          which of the records has the most recent date.  That one gets tagged as "Current" and the others get tagged as "History".

          Are you're interested in the related record with the most recent change? That would be much easier to implement as an attribute of the parent record; since only one record can be Current, and all others are by definition History, you only need to capture that record's ID in the parent, and don't have to change/update any child records.

           

          mvreade wrote:

          I have a One_cn calculated number = 1, and a G_One_cn global number that = 1 too.

           

          Also see if using a relationship with the Cartesian operator (x) helps here – it does the same as your two fields, just without the need for an additional stored field.

          • 2. Re: Updating Related Records
            mvreade

            Not the record with the most recent change; the record with the latest Date. 

             

            I had initially used the X operator, but by doing it with a global field I can use the same script when I delete a record.