4 Replies Latest reply on Sep 24, 2014 10:32 AM by mbornhoe

    OnObjectSave Event Question

    mbornhoe

      Title

      OnObjectSave Event Question

      Post

      I have set an OnObjectSave trigger to a text field on a layout.  When I click in the field and modify it, the triggered script runs.  I also have a button on the layout that runs a script that will add some text to this field using set field and then go to the field.  When I press this button the text is added the field and has focus but when I press enter to save the change the triggered script does not run.  There is a passage in the documentation titled, "Changing object data without activating script triggers" but there is no mention of OnObjectSave behavior so I am asking if this is the expected behavior and if it is how can I get this script to run when the data in this field is changed via this button and the user commits the record.

        • 1. Re: OnObjectSave Event Question
          philmodjunk

          Set Field modifies data without interacting with the layout directly and thus does not trip script triggers. This is normally desirable behavior and the script that sets the field can also include a perform script step to perform the same script as the OnObjectSave trigger performs.

          If you want the script trigger to be tripped by your script, you can use one of the script steps that starts with "insert" to modify the contents of this field.

          • 2. Re: OnObjectSave Event Question
            mbornhoe

            Adding an insert script step to the button gives me the desired behavior.  Thanks much.

            On a similar note,  I also have a text field that is defined as a checkbox that has an OnObjectSave event.  Every time I check or uncheck an item in this field the script is triggered.  I expected it would only trigger after I committed the record by clicking outside the field or pressing enter.  Interestingly enough, a modified timestamp I defined only updates after I commit the record, not each time I check or uncheck an item.  To your knowledge is this the desired behavior?

            • 3. Re: OnObjectSave Event Question
              philmodjunk

              As far as I know, but I use OnObjectModify with check box and radio button formats in most cases so I haven't really had a need to use OnObjectSave with it. A "save" on a field and a commit records aren't exactly the same event so I'm not surprised to see what you describe.

              • 4. Re: OnObjectSave Event Question
                mbornhoe

                I am trying to create an edit history, so I am recording the contents of the field to another table when a user finishes making changes to it.  I don't want a record of each letter or word they change.  I just added a get ActiveFieldName to the triggered script to test if the field that is that is being modified still has focus,  if it does then I don't write the edit history record.  This seems to be working.

                Again, thanks for you input.