8 Replies Latest reply on Mar 5, 2015 12:16 AM by davehob

    Updating via OnRecordCommit

    davehob

      I have a field that needs updating whenever relevant data changes.  It's a field called "searchableData", which is used primarily for eSQL queries and resultant portal filtering.  I don't want it to be a calc field, because it includes related data and will therefore incur performance issues, so it's a plain text field.

       

      Is it safe to do the updating in a triggered OnRecordCommit script?  I'm aware that this a layout-based trigger, so that the updating of the searchableData field relies on the data being updated (only) via the layout.  But if I watch out for any other ways to update the data (via other scripts etc.) and do a "manual" update of the field separately in these situations, is this a sound approach?  Or is there a better way?

       

      Thanks,

       

      Dave.

        • 1. Re: Updating via OnRecordCommit
          DanielShanahan

          I'd like to have an OnRecordExit for this purpose.  I've tried something similar and found there are too many ways to commit the record.  I ended up putting a button on the layout for the user to click when s/he was done entering data for that record.

           

          Is your layout a user layout or a backend layout?  I think that may make a difference.

          • 2. Re: Updating via OnRecordCommit
            davehob

            Thanks for your input Daniel.  It is a user layout, and is the only place where the user can amend the data.  But are you saying that, even though I'm confident of that, there may be other commits that I'm not aware of? 

             

            I agree that OnRecordExit would be good.

            • 3. Re: Updating via OnRecordCommit
              wimdecorte

              The user may be committing the record many times without really knowing it (clicking in the background,...) so your logic may be running more times than strictly necessary if the source field does not change but some other field does.

               

              Instead of OnExit you may want to look into OnSave.  Which only runs if the field changes, instead of every time you exit the field (whether you changed the field or not)

              • 4. Re: Updating via OnRecordCommit
                DanielShanahan

                wimdecorte wrote:

                 

                Instead of OnExit you may want to look into OnSave.  Which only runs if the field changes, instead of every time you exit the field (whether you changed the field or not)

                Yes, but OnSave is at the object level, not the record level.

                • 5. Re: Updating via OnRecordCommit
                  davehob

                  Thanks Wim - as Daniel said, I'm really after a record-level trigger, but I take your point, and maybe I should use OnObjectSave on each of the fields which are included in the search data - that may be safer I guess.

                  • 6. Re: Updating via OnRecordCommit
                    mark_scott

                    Hi Dave,

                     

                    I like Daniels' OnExit and Wim's OnSave, each for the reasons given, but returning for one last moment to OnCommit, there are a couple ways to suppress extraneous commits when the user clicks in the background:  (1) Build the logic into the OnCommit script itself to not commit (result=False) on those extraneous clicks; and (2) place an empty Web Viewer object into the layout's background to "catch" those clicks.  (The latter method predates script triggers and has always worked well.)

                     

                    Neither of these is necessarily better than Wim's or Daniel's suggestions, but just additional techniques to consider when weighing the pros and cons.  All things considered, I'd probably end up going with Wim's as the least likely to trigger evaluation when not needed.

                     

                    Mark

                    • 7. Re: Updating via OnRecordCommit
                      user19752

                      If you drag&drop a text to a filed (from another application, without entering the field), only "onObjectModify" tigger fires and record is commited.

                       

                      Tested on FM13v4/Windows7

                      • 8. Re: Updating via OnRecordCommit
                        davehob

                        Thanks Mark, I'll experiment with those.