3 Replies Latest reply on Jul 19, 2012 1:01 PM by philmodjunk

    Updating Auto-entered fields

    VeronicaDaigle

      Title

      Updating Auto-entered fields

      Post

      I have a field which needs to be indexed, so I have it as an auto-enter calculation based on a related field in another table. I have seen references in other posts about setting a script trigger on the related field to force the calculated field to update, what would such a script look like? Would it be a script that would have to go through every single record and end up taking too long to run to be worth using it? Not sure where to start on this one.

        • 1. Re: Updating Auto-entered fields
          philmodjunk

          You could start by describing your relationship, the fields and the auto-enter calculation.

          The script could be as simple as a single set field step performed by an OnObjectSave trigger, but the details will depend on your database design.

          • 2. Re: Updating Auto-entered fields
            VeronicaDaigle

            I've got a client table and a project table. Each project has a client, assigned by the user selecting the client from a dropdown box that displays the list of client names, but enters in the client's serial number (which is an auto-entered index field). Because I want to display the client name and not just the serial number I have a second field that looks up the client name throught the relationship between the client serial number in the client table and the serial number assigned to that project. The client name field is an auto-enter text calculation, as when I set it to a calculation field other features I have set up to create lists of combined client/project names don't work. If someone changes a client name, I would  like it to change the name on all of the projects that have that client. It would not likely be used often, but it would save me from having to go through and find other ways of making those other lists work properly.

            • 3. Re: Updating Auto-entered fields
              philmodjunk

              Client::ClientID = Project::ClientID

              is how I interpret the relationship and given the one to many relationship, updates could be a bit time consuming if there are a large number of projects for a given client.

              #Script should be performed from a client layout

              If [ Not IsEmpty ( Projects::ClientID ) ]
                 Freeze Window
                 Go To Related Record [Show only related records; From table: Project; Using layout: "Project" (Project)]
                 Replace Field Contents [no dialog; Project::ClientName; Client::ClientName ]
                 Go to Layout [<Original layout>]
              End If