I wanted to use the criteria for the Location + Department, as those are the names for the cost centers and I don't have any other way to "know" the cost center, except those.
I've tried those principles in the link provided, but it keeps skipping the rows when I try it.
I've used the "inventory" view to see the table affected when there's a Cost Center ownership and that's what I've tried.
So far this is what I have tried, getting the rows "skipped for association 'Cost Center'. Null values found in one or more key lookup columns":
Resource Type = Computer
Target = SQL Query
Query =
select vAsset._ResourceGuid, vasset.[Serial Number], vAssetCostCenterOwner._CCGuid, vAssetCostCenterOwner.[Cost Center], vAssetCostCenterOwner.[_ccId], vAssetCostCenterOwner.[Ownership Percentage]
, vDepartment_Location_CostCenter.Location, vDepartment_Location_CostCenter.Department, Inv_Cost_Center_Ownership.[_ResourceGuid],Inv_Cost_Center_Ownership.[Owner], Inv_Cost_Center_Ownership.[Ownership Percentage],
CC = case
when [Location] = [Department] THEN [Location]
When [location] <> [Department] then CONCAT(SUBSTRING([Location],1,12),[Department] )
end
from vasset
left join vAssetCostCenterOwner
on vAsset._ResourceGuid = vAssetCostCenterOwner._AssetGuid
left join vDepartment_Location_CostCenter
on vAssetCostCenterOwner._CCGuid = vDepartment_Location_CostCenter.CostCenterGuid
left join Inv_Cost_Center_Ownership
on vAssetCostCenterOwner.[_AssetGuid] = Inv_Cost_Center_Ownership.[_ResourceGuid]
where vAsset.[Asset Type] = 'Computer' and vAsset.Status = 'Active'
Now, I'm not sure what lookup keys it's using and in theory, it shouldn't be an update, because it's a new registry in the table.
I'm doing a new query now, but not sure how it'll turn out. Will post it as soon as I test it.