Recommended Posts

But we have the Warranty Master plugin to help pull warranty information for devices. Unfortunately, Warranty Master does not sync with the computers table in the labtech database by default. We are connected to Manage and want warranty dates to sync so that we can automatically start ticketing based on Warranty expiration dates. We have found that the WarrantyEnd dates in the computers table is often random and totally unreliable. To solve this problem, I wrote a few database modifications to sync the dates.

Disclaimer: All code is provided for reference use only. You MUST customize it to your own use case.

Basically, the purpose of a trigger is to detect when a change is made to a table and to perform a certain action when it does.

In our case, we are detecting changes to the `plugin_warrantymaster_aux` table and updating the `WarrantyEnd` field in the appropriate rows in the computers table with the new values.

We are also updating the `extrafielddata` Value field where the row shares the same `ComputerID` and `ExtraFieldID`. This can get a little tricky as the `extrafielddata` table is a junction table for the many-to-many relationship between computers and `extrafield` tables. Be sure you understand what my code does before running it.