dwalby Posted October 19, 2018 Posted October 19, 2018 Hi all, I'm looking to incorporate an Asset Disposal process into Hornbill BPM. My thoughts were to get an analyst to raise a Service Request, then link the assets requiring disposal to the Service Request so we have a record of what's been disposed of and when. Is it possible to automatically update the; State, Location, Disposal Reason, etc. as part of the BPM? Otherwise if we're disposing of a large number of assets in one go, it would take quite a while to manually update each assets fields. Unless there's another way? Thanks in advance
ArmandoDM Posted October 19, 2018 Posted October 19, 2018 He @dwalby this is not currently possible , but I will mention the problem to the relevant people to see if there is any change in the backlog to cater for this. Regards Armando
samwoo Posted October 19, 2018 Posted October 19, 2018 +1 for interacting with Assets via the BPM, particular for this sort of task. My work around was to use the API via PowerShell which reads through a CSV file for Asset Disposal. Not ideal but it works and better than going through 200 assets one-by-one.
dwalby Posted October 19, 2018 Author Posted October 19, 2018 2 minutes ago, samwoo said: +1 for interacting with Assets via the BPM, particular for this sort of task. My work around was to use the API via PowerShell which reads through a CSV file for Asset Disposal. Not ideal but it works and better than going through 200 assets one-by-one. @samwoo Powershell sounds like a good interim approach, are you able to provide any info on how you achieved this?
samwoo Posted October 19, 2018 Posted October 19, 2018 @dwalby Getting Powershell Version You need to be on Powershell Version 3.0 or higher for this to work. To check do the following: Open Powershell (ISE or not) Run the command $psversiontable Identify the Powershell Version Getting the xmlmcmodule for PowerShell Firstly you will need to download Hornbill's PowerShell module from here:https://github.com/hornbill/powershellHornbillAPIModule The xmlmcModule.psm1 file will need to be stored in a Powershell Module location on a Server / Local machine. It is usually C:\Windows\system32\WindowsPowershell\v1.0\Module but you can use any of the folders visible when you run this command in PowerShell: $env:PSModulePath -split ";" Basic Script Import-module xmlmcmodule #------------------------------------------------------------------------------------------------ # Import from CSV file # The Asset Name column should be called - "Name" - or it can be changed in the script below #------------------------------------------------------------------------------------------------ $pathToCSV = "[PATH TO CSV FILE].csv" $disposalAssets = Import-Csv -path $pathToCSV #------------------------------------------------------------------------------------------------ # (Optional) if your Asset Tags has a prefix in Hornbill but no prefix on your spreadsheet, you # can define the prefix here. Otherwise leave blank. #------------------------------------------------------------------------------------------------ $assetPrefix = "" #------------------------------------------------------------------------------------------------ # Loop through each asset in the CSV file #------------------------------------------------------------------------------------------------ foreach($asset in $disposalAssets) { #------------------------------------------------------------------------------------------------ # Get the Asset Name from the name column in the CSV and append the prefix (if any) to the front #------------------------------------------------------------------------------------------------ $assetName = "$assetPrefix$($asset.name)" #------------------------------------------------------------------------------------------------ # Define the Hornbill connection details #------------------------------------------------------------------------------------------------ # Same as in your live.hornbill URL $hbInstance = "[INSTANCE NAME]" # Instance Zone $hbZone = "eur" # API key for a user with access to amend assets $hbAPIKey = "[API KEY]" Set-Instance -Instance $hbInstance -Key $hbAPIKey -Zone $hbZone #------------------------------------------------------------------------------------------------ # Build the API call to return the machines where the asset number matches in Hornbill #------------------------------------------------------------------------------------------------ Add-Param "application" "com.hornbill.servicemanager" Add-Param "entity" "Asset" Open-Element "searchFilter" Add-Param "column" "h_name" Add-Param "value" $assetName Close-Element "searchFilter" #------------------------------------------------------------------------------------------------ # Invoke XMLMC call, output returned as PSObject #------------------------------------------------------------------------------------------------ $hornbillAssetOutput = Invoke-XMLMC "data" "entityBrowseRecords2" #------------------------------------------------------------------------------------------------ # Convert the results of the API results into a workable format #------------------------------------------------------------------------------------------------ $hornbillAsset = $hornbillAssetOutput.Params.rowData.row #------------------------------------------------------------------------------------------------ # Get ID of the Hornbill Asset #------------------------------------------------------------------------------------------------ $h_id = $hornbillAsset.h_pk_asset_id #------------------------------------------------------------------------------------------------ # Update the Assets accordingly to DISPOSED #------------------------------------------------------------------------------------------------ Add-Param "application" "com.hornbill.servicemanager" Add-Param "entity" "Asset" Open-Element "primaryEntityData" Open-Element "record" # Update the Asset matching the ID Add-Param "h_pk_asset_id" $h_id.Trim() # Set the Operational State to Retired (2) Add-Param "h_operational_state" 2 # Blank out the Site field Add-Param "h_site" " " # Remove the name of the company from the Asset Add-Param "h_company_name" " " # Remove any user assosciated with the Asset Add-Param "h_used_by" " " Add-Param "h_used_by_name" " " # Remove any Owner assosciated with the Asset Add-Param "h_owned_by" " " Add-Param "h_owned_by_name" " " # Remove the Location Details Add-Param "h_location" " " # Set the Disposal date Add-Param "h_actual_retired_date" $disposal_date_txt.text # If the Notes variable is populated... if($notes) { # Add the notes to the Asset's notes field Add-Param "h_notes" $notes } # Set the Asset State to Archived (2) Add-Param "h_record_state" 2 # Set the Substate to Disposed (14) Add-Param "h_substate_name" "Disposed" Add-Param "h_substate_id" "14" Close-Element "record" Close-Element "primaryEntityData" #------------------------------------------------------------------------------------------------ # Invoke XMLMC call, output returned as PSObject #------------------------------------------------------------------------------------------------ $xmlmcAssetUpdate = Invoke-XMLMC "data" "entityUpdateRecord" } Firsly double check the fields you want updated and the values they should hold. Secondly, do a test run on a few lines in a CSV file just to make sure it works (and so you know what's been updated) That is essentially what it is. I haven't included any debug information that will show data to the screen whilst it's being run. Thanks, Samuel 1
dwalby Posted December 10, 2018 Author Posted December 10, 2018 @samwoo I'm just picking up on this as we've recently disposed of a number of assets. Possible stupid question... Where should the disposal csv be saved/located in order for the PowerShell script to pick it up?
dwalby Posted December 14, 2018 Author Posted December 14, 2018 @samwoo - Now that I've actually taken the time to properly study the script I've worked it out - going to give it a try shortly. Thanks!
samwoo Posted December 14, 2018 Posted December 14, 2018 Hi @dwalby, Apologies I did not get back to you sooner. I am glad you managed to find out. It's advisable to test this script using a small number of assets first which I am assuming you have already thought of just to make sure that it does what is expected. I hope it goes well. Thanks, Samuel
samwoo Posted December 14, 2018 Posted December 14, 2018 On 10/19/2018 at 1:54 PM, ArmandoDM said: He @dwalby this is not currently possible , but I will mention the problem to the relevant people to see if there is any change in the backlog to cater for this. Regards Armando Have there been any movement to this conversation @ArmandoDM? I can imagine linking all the assets to be disposed of against a ticket, the at the right part stage, the bpm then loops through all these assets and updates according to the information we specify via the progressive capture. I can also envisage tasks being created individually for each assigned assets too, appearing in the request for the user to action on one-by-one. I hope something like this will be possible. Thanks, Samuel
ArmandoDM Posted December 19, 2018 Posted December 19, 2018 Hi @samwoo apologies for my late response. We are discussing about introducing a new bpm operation to update the assets linked to a request. The details are not finalized yet, but I will keep you updated once they are and I'll add you as a member of the CH. Regards Armando 1
ArmandoDM Posted December 20, 2018 Posted December 20, 2018 Hello @dwalby @samwoo we have scheduled a change to update the asset linked to a request via a BPM operation. You have a been added as an interested connection to it. Regards Armando 1 1
dwalby Posted December 20, 2018 Author Posted December 20, 2018 On 12/14/2018 at 3:56 PM, samwoo said: Hi @dwalby, Apologies I did not get back to you sooner. I am glad you managed to find out. It's advisable to test this script using a small number of assets first which I am assuming you have already thought of just to make sure that it does what is expected. I hope it goes well. Thanks, Samuel Hi @samwoo - I've made some amendments to the script and copy/pasted into a PowerShell window running as admin (after setting Set-ExecutionPolicy -Scope Process -ExecutionPolicy Bypass) and it appears to go through each line but doesn't appear to actually do anything Hornbill side or report any errors. Any ideas?
samwoo Posted December 21, 2018 Posted December 21, 2018 On 12/20/2018 at 12:03 PM, dwalby said: Hi @samwoo - I've made some amendments to the script and copy/pasted into a PowerShell window running as admin (after setting Set-ExecutionPolicy -Scope Process -ExecutionPolicy Bypass) and it appears to go through each line but doesn't appear to actually do anything Hornbill side or report any errors. Any ideas? Hmm without seeing what your configuration and CSV files look like its quite difficult to think about what the issue could be. But see if this helps... underneath $assetName add the following... Write-host $assetName so it will look like this #------------------------------------------------------------------------------------------------ # Get the Asset Name from the name column in the CSV and append the prefix (if any) to the front #------------------------------------------------------------------------------------------------ $assetName = "$assetPrefix$($asset.name)" write-host $assetName Run the script. If you are seeing the names of all the Assets appear in the Powershell Console from the CSV file then you know that this part works and there is something else going on further down the script. If you don't see the names of the assets, then you need to ensure that the Asset Tag column header is called name by amending the CSV file. Also check the headers should appear in the first row of the CSV file, and start in the first column. I think you can also return the results of the following variable... to show if it failed or not. $xmlmcAssetUpdate But I am not at my PC at the moment so am unable to check. I hope this helps to start with. Samuel
samwoo Posted December 21, 2018 Posted December 21, 2018 On 12/20/2018 at 11:50 AM, ArmandoDM said: Hello @dwalby @samwoo we have scheduled a change to update the asset linked to a request via a BPM operation. You have a been added as an interested connection to it. Regards Armando Thanks @ArmandoDM, We are very excited to see these changes - so we can move away from using the Powershell Script and do everything from within the ticket. Samuel
dwalby Posted January 3, 2019 Author Posted January 3, 2019 On 12/21/2018 at 4:01 PM, samwoo said: Hmm without seeing what your configuration and CSV files look like its quite difficult to think about what the issue could be. But see if this helps... underneath $assetName add the following... Write-host $assetName so it will look like this #------------------------------------------------------------------------------------------------ # Get the Asset Name from the name column in the CSV and append the prefix (if any) to the front #------------------------------------------------------------------------------------------------ $assetName = "$assetPrefix$($asset.name)" write-host $assetName Run the script. If you are seeing the names of all the Assets appear in the Powershell Console from the CSV file then you know that this part works and there is something else going on further down the script. If you don't see the names of the assets, then you need to ensure that the Asset Tag column header is called name by amending the CSV file. Also check the headers should appear in the first row of the CSV file, and start in the first column. I think you can also return the results of the following variable... to show if it failed or not. $xmlmcAssetUpdate But I am not at my PC at the moment so am unable to check. I hope this helps to start with. Samuel Thanks @samwoo - Looks like the error reporting is working. By the looks of it, it's now failing because it can't find the disposal_date_txt.text file, can't seem to get that to work, so in the meantime I manually entered the date into the script, but it's reporting that the below Invalid date/time format provided: [2018-12-10 12:00:00] for column h_actual_retired_date As per the Wiki https://wiki.hornbill.com/index.php/Understanding_the_Asset_Structure it's appears to be in the correct format however Date Time – must be in the format: YYYY-MM-DD HH:MM:SS e.g. 2015-07-15 00:00:00
samwoo Posted January 3, 2019 Posted January 3, 2019 9 minutes ago, dwalby said: Thanks @samwoo - Looks like the error reporting is working. By the looks of it, it's now failing because it can't find the disposal_date_txt.text file, can't seem to get that to work, so in the meantime I manually entered the date into the script, but it's reporting that the below Invalid date/time format provided: [2018-12-10 12:00:00] for column h_actual_retired_date As per the Wiki https://wiki.hornbill.com/index.php/Understanding_the_Asset_Structure it's appears to be in the correct format however Date Time – must be in the format: YYYY-MM-DD HH:MM:SS e.g. 2015-07-15 00:00:00 Hi @dwalby, I'm glad you got a bit further than before. As for the date, try it 2 different ways... 1. $date = get-date("2015-07-15 00:00:00") 2. $date = (get-date("2015-07-15 00:00:00")).toString("yyyy-MM-dd hh:mm:ss") Set this somewhere near the top of your script. Then use $date in the following Param and see which work (hopefully) works # Set the Disposal date Add-Param "h_actual_retired_date" $date Fingers crossed! Samuel
dwalby Posted January 3, 2019 Author Posted January 3, 2019 @samwoo strangely I continued to get invalid date format errors with both of those date commands. For the meantime I've excluded the disposal date from the script just so I can get them updated.
samwoo Posted January 3, 2019 Posted January 3, 2019 Hi @dwalby, I think it's best we wait for someone from Hornbill to advise us on the input format for the API. Strangely I used a Datepicker in my version of the script when generates a GUI... but it was so buggy and slow I stripped all of that out to send you the code (which I will rebuild using XAML GUI eventually) but for some reason that Datepicker allowed the date to be used in the API call but i'm not sure what format it comes out in. @TrevorKillick or @Victor perhaps to offer any advice for us Powershell users using the API? Thanks, Samuel
Giuseppe Iannacone Posted January 13, 2019 Posted January 13, 2019 On 12/20/2018 at 12:50 PM, ArmandoDM said: Hello @dwalby @samwoo we have scheduled a change to update the asset linked to a request via a BPM operation. You have a been added as an interested connection to it. Regards Armando @ArmandoDM can you please add me too to the interested person +1
Steven Boardman Posted December 2, 2020 Posted December 2, 2020 @dwalby @samwoo @Giuseppe Iannacone Just an update to let you know we have added a number of new business process operations which will allow for the automatic adding of and updating to assets associated to requests, these include: * Options to add all assets linked to a customer to a request * Option to add specific asset classes / types of assets linked to customer to a request * Existing PC options to add any assets to a request is retained * Options to update all assets linked to a request * Options to update selective assets based on class and types * Options to update generic and class specific attributes of assets linked to requests These options will be available in the coming weeks (once testing etc is complete) 1
Giuseppe Iannacone Posted December 3, 2020 Posted December 3, 2020 @Steven Boardman very interesting! thanks for following up
James Ainsworth Posted January 18, 2021 Posted January 18, 2021 As of the Service Manager build 2126 we have added a number of new Hornbill Automations in the BPM for Assets. For a full list of automations, please see the documentation Hope this helps, Regards, James 1
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now