Linking Multiple Assets to an Incident
The current version of Help Desk (as of this writing) allows you to select a single asset, and set it as the 'managed object' for that incident. This comes in handy for reporting and automation rules, not to mention the ability to quickly navigate to the resource manager, or carbon copy to a device via the icons next to the selected asset. In my workplace however, our day to day workflow requires that for a given incident, multiple assets need to be associated.
To that end, I created a mechanism that allows the linking of multiple assets to an incident with a bare minimum of customization to the help desk product.
Tested Using:
Altiris HelpDesk Solution 6.0.308
Altiris Asset Management Solution 6.5.1126
Altiris CMDB 6.5.1126
I would preface this by stating that this solution requires a solid understanding of the resourceassociation table within Altiris. Not a complicated thing, but you can certainly cause a lot of problems if you mess it up.
In order to minimize the amount of customization, and reduce the overall complexity, our approach leverages the resourceassociation table in Altiris to store the link data. Using the same (and existing) architecture used to associate (link) all other resources to one another, the actual customization to help desk is limited to one line of code inserted in a single help desk template.
* To undo the customization then, you just delete one line of code, and a single resourceassociation type, and boom! ...you're right back where you started.
Our approach for linking multiple assets requires three components:
- A Resource Association between an incident and an asset
- A hyperlink within help desk worker view that passes the guid of the current incident to a custom web page.
- An in-house built web page that displays associated assets, and can make new or delete existing associations.
The first is a piece of cake. In the configuration tab of the Altiris console, expand the resource settings, and then the resource associations container. In the user defined folder of your choice (I put ours under asset association types/user defined), create a new resource association by right clicking the parent folder, and selecting new->editable association type:
Name the new association, and select the 'from' and 'to' resource types as 'asset' and 'incident' respectively. Set the cardinality (the number of allowed/required associations per resource) as appropriate, choose the resource pickers you want to use, and save your new association type.
The order in which you do the second and third steps is up to you, but for the web site to function it needs a starting point. That is, it needs to know with what incident to contextualize its queries. So then, what is needed (the only real customization required by this approach), is the creation of a hyperlink within the helpdesk worker view that when clicked, passes in the identifier of the incident from which it was clicked to a web page. To create the link, we need to create a custom version of the subworkitemeditgeneral.ascx file located in the templates folder (usually C:\Program Files\Altiris\Helpdesk\AeXHD\templates). Editing this template will make changes to the appearance of the body of an incident in edit mode only. Changing the appearance in any other mode would require that you edit its respective template file.
If you have done any customization to help desk, I don't need to tell you this part, but DON'T edit this file directly. Create a folder called 'custom' in your Altiris aexhd folder (usually C:\Program Files\Altiris\Helpdesk\AeXHD\), and a sub folder within it called 'templates' like so: C:\Program Files\Altiris\Helpdesk\ AeXHD\custom\templates. Make a copy of subworkitemeditgeneral.ascx, put it in your \custom\templates folder, and rename it to customsubworkitemeditgeneral.ascx. You may also need to make a copy of other files and put them in this folder as well (like TemplateEngine.inc) to get this working. Certainly, I have more files in my folder than I need to do just this customization, but then this is not the only customization we have. My custom folder looks like this:
You will notice that I have prepended 'custom' to all of the .ascx files. Certainly, there are more in-depth/better explanations on how to set up custom help desk templates to be used, but in the interest of reduced digression we will keep them out of scope here. However, one key step I will touch on is the creation/modification of a custom.config file which tells help desk to start using your custom templates instead of the originals. See the product release notes (altiris kb 18269) for more info. My custom.config file is located in C:\Program Files\Altiris\Helpdesk\AeXHD\worker, and looks like this:
<?xml version="1.0" encoding="utf-8" ?>
<custom.configuration>
<files path="~/custom/templates/">
<file id="WorkItemEdit" file="customWorkItemEdit.ascx"/>
<file id="WorkItemView" file="customWorkItemView.ascx"/>
<file id="subWorkItemEditGeneral" file="customsubWorkItemEditGeneral.ascx"/>
<file id="subWorkItemEditAsset" file="customsubWorkItemEditAsset.ascx"/>
<file id="subWorkItemEditAttach" file="customsubWorkItemEditAttach.ascx"/>
<file id="subWorkItemEditBulletin" file="CustomsubWorkItemEditBulletin.ascx"/>
<file id="subWorkItemContact" file="customsubWorkItemEditContact.ascx"/>
<file id="subWorkItemEditEmail" file="customsubWorkItemEditEmail.ascx"/>
<file id="subWorkItemEditFindAsset" file="customsubWorkItemEditFindAsset.ascx"/>
<file id="subWorkItemEditFindContact" file="customsubWorkItemEditFindContact.ascx"/>
<file id="subWorkItemEditLink" file="customsubWorkItemEditLink.ascx"/>
</files>
</custom.configuration>
So then, open the C:\Program Files\Altiris\Helpdesk\AeXHD\ custom\templates\customsubWorkItemEditGeneral.ascx file, and search for a place to insert the link. I have opted to have the link appear as an icon next to the others to the right of the existing 'Asset:' field:
It can be tricky to find a place to put your link, but to put it where I did, search for the text string 'ibSelectAsset' (you will find only one instance). Skip to the end of the line, and press enter to insert a new one.
Enter the following line of text (include the URL to your web page):
<aw:HyperLink id="mylink" ImageUrl="icnLink" runat="server" target="_blank" NavigateURL='<%# "http://URL TO MY WEB PAGE" + datastore("WorkItem").current("_resourceguid") %>' Enabled='True' />
Save, and close the file. The way this is set up, the URL you insert will be appended with a string containing the resource guid of the incident. This gives your web page the context it needs to run its queries, so structure your web page/URL so that the guid at the end becomes a parameter for your page. The id="mylink" portion is arbitrary, but the value needs to be unique from any other id on the page. The ImageUrl="icnLink" tells it to use the icon you see in the image above, but you can point it to whatever icon you like.
If this is your first customization, you may need to perform an IIS reset (once you have created/modified custom.config) to make help desk start using the templates in your custom folder.
Finally, step three. The web page is really all up to you, but the basic concept is that when the page loads, it takes the guid passed in from help desk, and queries the Altiris database to find all the assets associated to the incident from which the link was clicked. From there, it is easy to add the 'add' and 'remove' functionality by writing the insert and delete queries and binding them to triggers/forms on your web page. Mine looks like this:
In my page, I have also added the ability to assign (link or associate) the asset with the primary contact in the incident. Additionally, as in the case above, when an asset request generated the incident, it affords me a way to query for the cost center (expense account) that was used during the request and so too to be able to associate the asset to that cost center for billing. You could just as easily perform these (and any other) additional functions via an automation rule or smart task utilizing an AEXQUERY once the asset(s) has/have been associated to the incident. The barcode field is a hyperlink to the resource manager for that asset. As of this writing, I have not yet added links to carbon copy and/or RTSM but it is entirely possible.
As I mentioned earlier, the resource association(s) store the link data. For each asset that is linked to an incident, a row is added to the resourceassociation table containing the unique identifier of the resource association type, the unique identifier of the asset, the unique identifier of the incident, and a time stamp. The insert statement looks like this:
INSERT INTO resourceassociation VALUES(<RESOURCE ASSOCIATION GUID>, <ASSET GUID>, <INCIDENT GUID>, getdate())
Bear in mind that the asset and incident guids may need to be reversed depending on whether you put asset or incident in the 'from type' field when you created your resource association. The above is correct if you created yours the same as mine.
- Login or register to post comments
- 4080 reads
- Printer-friendly version



















Perfect timing.
We were just considering doing this exact thing for our helpdesk as we're replacing a legacy system. I'm thinking I'm going add this to our project.
Thanks!
Insert Bonus
While you should avoid making direct inserts into the altiris database whenever possible, sometimes there's just no way around it. However when you must, it is always best to use the library of stored procedures that get 'installed' along with the various altiris products whenever you can. Instead of the above insert statement for creating a resource association, try using the spAddAssociation function like this:
spAddAssociation(<resourceassociationtypeguid>, <parent guid>, <child guid>)
need more help
Hi chaotech, I need to do this for our helpdesk console. Could you pls provide more information on how to do the new web page?
Thanks.
mchau
resourceassocation table in altiris
Hi Chaotech, I did the changes. What I did is creating some new .ascx files. Now, I'm stuck on how to save the new records.
What I did is in the customworkitemedit.ascx, i added the following code:
1. 'this is for getting the current resouceassociationtypeguid in the resourceassociation table.
assetSql ="Select * from ResourceAssociation where ParentResourceGuid = '" + rguid + "' and ChildResourceGuid = '" + mobjectid + "'"
pTypeGuid = assettemp.Tables(0).Rows(0).Item("ResouceAssociationTypeGuid")
but it complaint about that resourceassociation is not a valid object. I guess it's becuase I'm doing it from
the helpdesk module. I can't query the table which is under Altiris. Could you pls let me know how can I get aroud this? Also i try to call the spaddassociation stored procedure but got the same error message. Pls help.
mchau
Possible help...
Not sure of the hows and why's, but I think you could take this:
And add this:
Adding "USE ALTIRIS" will specify the database to run the query against.
John Golembiewski
Midwest Practice Principal
ITS Partners
Jgo@itsdelivers
spaddassociation stroed procedure
Hi John, thanks for your reply. I'll try your sugesstion now. The reason why I need to do a select against the Altirs at this point is to find out the resourceassociationtypeguid for this incident. Then I need to pass this resouceassociationtypeguid to spaddasociation stored procedure. This stored procedure requires 3 params - resouceassocationtypeguid, parentresourceguid and childresourceguid. Pls let me know if I can find out this resouceassocationtypeguid in another way. All I need to do is to insert new records in the resourceassociation table.
Also, can you pls also let me know how can I use this spaddassociation stored procedure in this help desk module?
Thanks for your help.
Maggie
Prime Workflow Candidate
I think with what you are looking to do makes you a prime workflow candidate. In workflow this process becomes much less intense... I think if you continue down this path you risk possibly being in a situation where you would not be supported. :(
I'll go back to the lab on this though.
John Golembiewski
Midwest Practice Principal
ITS Partners
Jgo@itsdelivers
workflow
Can you provide me more info about this workflow? Can you pls let me know how should I begin with?
Thanks.
Maggie
Altiris Create Association Component
jgo,
This is a perfect application for workflow. Unfortuantely, you would still need to be able to answer the same questions mchau is asking in regards to the query. Since the out of the box 'create resource association' component in workflow only allows you to make default/standard association types - not custom ones (and only between default/standard resource types as well), you would have to use the SQL script builder to create an intergration library to accomplish the same thing. I have put in a feature request to make this component more flexible...
resourceassociationtypeguid is static
mchau,
perhaps I am misunderstanding you, but you don't need to query for the resourceassociationtypeguid. Once you have created/identified the resource association you are going to use, simply right click on it from within the configuration tab in the console, and select properties. The guid listed there will always be one of the three guids you use in your query - whether you are trying to list linked assets, or making a new insert, the only guids that will change are that of the asset and of the incident. Just hard code the association type guid into all of your search and insert queries. Using the modification I made to the customsubWorkItemEditGeneral.ascx page, the guid of the incident will be passed to your custom web page in the URL. The only one you need then to make a new link/association is the asset guid which should be supplied by a simple query when the user enters a new asset to be linked. The insert then can be made using the spaddassociation stored procedure like this:
Altiris.dbo.spAddAssociation(resourceassociationtypeguid, asset guid, incident guid)
or you should also be able to use the syntax that jgo suggested like this:
use altiris spAddAssociation(resourceassociationtypeguid, asset guid, incident guid)
As I said, for the resourceassociationtypeguid, you just need to hard code the guid of the resource association type you are using since it will never change. The asset guid should be supplied by the user - or more accurately, the user will supply an identifier like barcode, serial, or name (however you want your users to search for assets), and you will need to use that identifier to query for the asset's guid. Finally, pull the incident guid out of the URL (that was passed in by customsubWorkItemEditGeneral.ascx).
If it would be helpful to you, feel free to send me what you have in your custom web page, and I'd be happy to give you some feedback.
resourceassociationtypeguid
Hey chaotech, thanks for your reply. Can you also tell me is the resourceassociationtypeguid for New Ticket page and Edit a ticket page also static as well? if it is, could you pls provide that to me? The reason why I need this is becuase I want to show the Asset in the Asset drop down box(on the New ticket Page and Edit ticket page. e.g. click on New ticket: Assets: ) in the multiple asset page as well.
The reason why I want to do this are:
1. users can see all the assets for this ticket in one place.(not one in the New Ticket or Edit Ticket page, and the other in the multiple Asset page)
2. if the user enter nothing in the Assets: drop down box, but enter assets in the multiple assets page and save the ticket. Then after the user click on the save and view button, the view page will show Asset: [none selected]. But actually this ticket has multiple assets.
Thanks.
Maggie
Managed Object and Custom type are static
To answer your first question, yes. As a matter of fact, all resourceassociationtype guids are static. You also made reference to the managed object. The managed object is the default resourceassociaton between an asset and an incident. There is a 1 to 1 relationship between the two which is why I had to find a way to link multiple assets using a custom resourceassociationtype. Where a ticket shows 'Asset: [none selected]', it means that no managed object is set for that ticket. Using my method of linking multiple assets will not set the managed object. It sounds like you are looking for a way to use the custom association you are using to link multiple assets and the managed object association interchangeably - or at least to display them in the same place. I can't say that this would be impossible, but it's something I haven't tried and it would certainly have some complications. While we haven't done it yet, we too would like to display all of the linked assets on the edit and view pages. For the time being, people have to click on the link to open the custom 'linked assets' page that I built in order to see the assets that are linked. My idea for showing the custom linked assets in the edit and view pages would require that the database schema be extended, and a new field added to the edit and view templates to display the new database field.
asset_resource_guid is not unique
HI chaotech/jgo, pls correct me if i was wrong. I assume that the chilresourceguid in the resourceassociation table is correspond to the asset_resource_guid in the asset_view table.
In the customization, the user will search the asset by using computer name. then it search the asset_resource_guid in the asset_view table and save this asset_resource_guid in the resourceassociation table. When I retrieve the records for this ticket, I use the following sql to retrive record:
"Select a.* from asset_view a, altiris.dbo.resourceassociation r where r.resourceassociationtypeguid='4cd53ada-c487-4e38-90a6-61aa0613c008' and r.parentresourceguid = '" + _resourceguid + "' and a.asset_resource_guid = r.childresourceguid"
Now I found thhat the asset_resource_guid is not uniqe in the asset_view table. For example, if I create assets(using Assets -> New Assets) under computer catagory, all these assets will have the same asset_resource_guid, pls let me know how can I resolve this problem.
Thanks.
Maggie
Query against the Altiris Database
mchau,
I think it would simplify things for you if you just queried the altiris database rather than bringing the asset_view into the equation. Assuming that:
1. your custom web page is receiving the guid of the incident in the URL.
2. the user has provided a machine name they would like to link to the ticket and clicked submit.
3. '4cd53ada-c487-4e38-90a6-61aa0613c008' is the guid for the resourceassociationtype that you created for linking assets to incidents.
You can create the link by using the following query/insert statement:
(you can use whatever variable scheme you want, but i'm using strictly SQL for this example)
declare @assetguid uniqueidentifier
set @assetguid = (select guid from altiris.dbo.item where altiris.dbo.item.name = [machine name passed in by user])
insert into altiris.dbo.resourceassociation values('4cd53ada-c487-4e38-90a6-61aa0613c008', @assetguid, [incident guid passed into URL], getdate())
or, if you are trying to list all assets linked to a ticket:
select
altiris.dbo.item.name
... (whatever other fields you want)
...
from altiris.dbo.item
where altiris.dbo.item.guid in(select altiris.dbo.resourceassociation.parentresourceguid from altiris.dbo.resourceassociation r where r.resourceassociationtypeguid = '4cd53ada-c487-4e38-90a6-61aa0613c008' and r.childresourceguid = [incident guid passed in by URL])
item table
Hi chaotech, thanks for the suggestion. In our item table, we've over 25,000 records, if I put that in a dropdown combo box, it's not easy to select a product and I'm not sure can I break it down into different types. I've few questions:
1. if I use item instead of asset_view, it seems that I can't select the new asset which create manaually.
2. in your select statement
quote
select
altiris.dbo.item.name
... (whatever other fields you want)
...
from altiris.dbo.item
where altiris.dbo.item.guid in(select altiris.dbo.resourceassociation.parentresourceguid from altiris.dbo.resourceassociation r where r.resourceassociationtypeguid = '4cd53ada-c487-4e38-90a6-61aa0613c008' and r.childresourceguid = [incident guid passed in by URL])
end quote
In the item table doesn't have asset's detail information, for example: serial number, asset_manufacturer and asset version. How can I get all these information if I use the sql you mentioned above.
3. if I don't use item table. I think instead of using asset_view, I should use managed_object table instead. I can create a another simple table to hold the information for the _resourceid, asset_id(becuase it seems the asset_id is unique and the asset type lookup id in this table, then it will solve the duplicate asset guid issue. do you think this will work?
Thanks.
Maggie
Thanks.
Hi chaotech & jgo, thanks for all your help, I've finished the customization.
Maggie