Open vvv850 opened 2 years ago
I am not 100% sure on how the syncro integration works. You might need to do a get-huduassets and have a look at what data is being returned then check the script to see how the matching is being done and if it is actually finding a device.
This is what i get:
Parent asset
id : 173 company_id : 5 asset_layout_id : 3 slug : xxx-4eeeb1b5bb9d name : xxx primary_serial : primary_mail : primary_model : MS-7D13 primary_manufacturer : Micro-Star International Co., Ltd. company_name : Testing Company object_type : Asset asset_type : Computer assets archived : False url : xxx created_at : 2021-12-06T22:51:42.450Z updated_at : 2021-12-06T22:51:42.501Z fields : {} cards : {@{id=292; integrator_id=1; integrator_name=syncro; link=xxx-4eeeb1b5bb9d; primary_field=; data=; sync_type=asset; sync_id=6008240; sync_identifier=}}
Logged asset
id : 181 company_id : 5 asset_layout_id : 7 slug : xxx-logbook-d45b9fc42d67 name : xxx - Logbook primary_serial : primary_mail : primary_model : primary_manufacturer : company_name : Testing Company object_type : Asset asset_type : Computer assets - logbook - autodoc archived : False url : xxx created_at : 2021-12-07T10:17:27.530Z updated_at : 2021-12-07T10:17:27.530Z fields : {@{id=87; value=xxx; label=Device Name; position=1}, @{id=85; value=173; label=Device; position=2}, @{id=89; value=<table>
If I manually select the parent asset from the logged asset's Device Field this is how both look:
Parent
cards : {@{id=292; integrator_id=1; integrator_name=syncro; link=http://xxx-4eeeb1b5bb9d; primary_field=; data=; sync_type=asset; sync_id=6008240; sync_identifier=}}
Logged
fields : {@{id=87; value=xxx; label=Device Name; position=1}, @{id=85; value=[{"id":173,"url":"/a/xxx-4eeeb1b5bb9d","name":"xxx"}]; label=Device; position=2}
So it seems that the parent is found and matched with the correct ID initially but I guess it's a syntax issue or compatibility with the newer field types? I'm guessing, I'm new with HUDU, just recently joined the trial.
I made some modifications to the script as follows: modified the field type for the Device under the new Asset Layout `label = 'Device'
field_type = 'AssetTag'`
And added a new variable to be able to populate the Device field:
$LinkValue = "[{""id"":$($ParentAsset.id),""url"":""/a/$($ParentAsset.slug)"",""name"":""$($ParentAsset.name)""}]"
and finally referenced in
'$AssetFields = @{ 'device_name' = $ComputerName 'events' = $eventshtml 'user_profiles' = $ProfilesHTML 'installed_updates' = $UpdatesHTML 'installed_software' = $SoftwareHTML 'device' = $LinkValue }
Being an amateur when it comes to scripting and using api's this is what I was able to come up with.
Now you have a link for the logged asset in the "Related Items" from the Parent Asset and a link for the Parent Asset under Device section in the Details for the logged asset. << I hope that this was the intended structure.
Thanks
I've been testing the script and it works, data is being populated in a new asset layout and new asset.
But I was under the impression that it links with the parent also after importing.
Details: Original assets are pull from Syncro Integration and put under a basic Computer Assets Layout Then after running the script, a new layout is created an populated with the logged asset. Viewing the newly created asset I can see that the Device field is blank, while the others are populated.
Any info about where I should look to fix it?
Thanks