Jump to content
  • 0
888Washington

Trigger Only Enter Unique Values into fields within record

Question

I'm looking to  only insert unique values within a record on update with a trigger.  Right now I have two tables set up with a trigger on insert/update.  When a user updates a field within the Employee's table, it copies all of the information from the current record into the Employee History table.  However, my users want to be able to see what fields were modified within the Employee History table.  The trigger currently just copies all fields (and values in those fields - most are text) from the current Employee's table to the Employee History table.  The user then can compare the current record in the employee's table with the employee history records and manually scroll through to find what values in each field are different, but this takes quite a bit of time. 

I would like the trigger to look at all the current values in the fields it is going to copy, if the values have not been changed (or are equal to the current values in the Employee History table), then do not update/insert those fields in the employee history table; otherwise update only the fields that have been changed.   This would ideally show only updated field values for each history record, instead of duplicating all of the field values.

Thank you for any assistance!

Capture.PNG

Share this post


Link to post
Share on other sites

1 answer to this question

Recommended Posts

  • 0

Hey there, 

You can try something like what I built for my usage: 

image.thumb.png.8bbab87a431341eb7a1725db823378df.png 

In here, the trigger built in (aaa) table and on record update, fields updated are inserted into (aaaa) table. If Name was changed, Info field will be blank, and vice versa. ID is there to make sure records are connected, so kinda for relationships.

Feel free to copy-build such blocks for all of the fields that you have and would like to be ignored if they were not changed. 

Hope this helps! :)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×