Scripting Question

How to Change Details in Assets with Scripting

02/16/2016 1269 views
This is the first question I have needed to ask as usually I find the answers I need from this site.  Asset management has always been an issue and I am trying to fix areas that have seems to cause the most problems.  Mainly that is keeping them organized and how to simplify the process.  Being in a school district, teachers can have multiple devices checked out to them in classrooms.  I have an asset type called rooms.  It has a few sub types but one is classrooms.  What I am hoping to do is any teacher that is assigned to a room with the subtype classroom, would automatically assign all the assets in the room to the user.  Devices move in and out of those rooms quite often and I would like to remove possibilities of errors by  having a script check the owner of the room and associate the devices in the room to the owner. It would only be for the subtype classroom as other locations would not work with that setup.  Does anyone have any recomendations on where to begin or best practices on keeping an efficient asset system for a school district?
0 Comments   [ + ] Show comments


All Answers

You can use ticket rules to update any part of the database, so that would be the place to start. You'll need a good knowledge of MySQL to make this work, but it should be possible. When the select statement runs in a ticket rule the KBox is expecting it to return at least an ID column, this column will be used to create a variable <TICKET_IDS> that can be used in the update statement of the rule. Using that knowledge you can craft select statements that will return assets that need to be assigned and an update statement that makes the changes.

Be very careful when making rules like this. It is easy to make a mistake in your update query that will cause problems in the database.

If you aren't already setup with MySQL Workbench or a similar tool for looking at the database then I highly recommend getting that setup. The asset tables are easy enough to understand once you have spent some time looking at them.
Answered 02/17/2016 by: chucksteel
Red Belt

This website uses cookies. By continuing to use this site and/or clicking the "Accept" button you are providing consent Quest Software and its affiliates do NOT sell the Personal Data you provide to us either when you register on our websites or when you do business with us. For more information about our Privacy Policy and our data protection efforts, please visit GDPR-HQ