Closed danxpar closed 5 years ago
Okay I solved it another way, I just did a GetAll, and then searched for the Asset Tag through the returned data. Here is my snippet...
//define variables and load tempAllAssetArray with all snipeit Records
var thisDeviceTag = "12345"
var tempAllAssetArray = snipe.AssetManager.GetAll();
Asset foundDevice = null;
//loop through them all looking for the match to the AssetTag
foreach(var tempAsset in tempAllAssetArray.Rows)
{
if (tempAsset.AssetTag == thisDeviceTag)
{
// convert long to int
int i = (int)tempAsset.Id;
//load the found device to the variable
foundDevice = snipe.AssetManager.Get(i);
// only one Asset Tag per asset so we can continue and not break the for loop
}
}
// clear the memory
tempAllAssetArray = null;
Please excuse my code, i'm sure there are many other ways to skin a bird with a glass house... Kind regards and thanks again, Dan
Hello,
It's been a long time since I've gone through the code on this. Looking at it I don't think it's possible as it stands. However, you could extend AssertSearchFilter to include the asset tag field. I'm pretty sure that will work.
Thanks for the reply, It's working for now with my mish-mash, I don't have many devices to manage, but will definitely look into it.
I've got a pull request for a GetByAssetTag(string)
method in #18.
Awesome, I'll test it out.
Hi Barry, Really appreciate you putting this together, thanks for all your work.
I can successfully get an object using the Get object with Name. but I was wondering if it is possible to Get and object with AssetTag?
I may be doing something wrong.
Sorry if you no longer are doing much with this, but I thought I'd just ask.
Kind Regards,
Dan.