I have a function that fetches data, and places it in an autocomplete, but the value parameter of New-UDAutocompleteOption doesnt seem to accept json data.
Bump. Anyone have any idea what this could be? Updated to 5.0.9 and no difference. (And noticed I wrote one of the code blocks wrong above… $_.Computername should of course be $_.Status
Thank you so much for the suggestion, but I am already doing this (not putting the parameters in a hashtable, but string interpolation, "$()").
I also tried putting the result in a variable but the result is exactly the same. This doesnt work, but adding anything to the $value string that breaks the json format makes it work.
This may seem irrelevant, but can you try bypassing the pipeline and directly passing the InputObject? I’m wondering if it’s having an issue with the evaluation.
Another thing to try, though it won’t work in the structure you’re anticipating, is to transform your prefilled JSON string into a traditional pscustomobject/hashtable to see if it may be an issue with the evaluation on ConvertFrom-Json… this is an interesting one. Let me know if either of those have any effect; I’m going to test this on an app in my environment in the meantime to see if I can’t recreate.
Well, converting your $EventData to JSON works for the UDToast - but for whatever reason, something with the -OnChange trigger is causing this. You could also access the Value with $EventData.Value, predictably.
Bypassing the pipeline, ConvertTo-Json -Compress -InputObject $_, does nothing. Same error.
Also tried the ConvertTo-JsonEX from the Universal module, but no difference.
Using tha original hashtable works, but like mentioned, the value isn’t what I need in the end. Show-UDToast Is really just a part of an entire script, so I would prefer to have the JSON string.
It is only an issue with New-UDAutocomplete though. Using New-UDSelect works just as expected.
so the expectation is that the -Value parameter is able to handle those objects cast as strings - the issue right now is that it is casting as a pscustomobject even though you are converting it to json? if so, then i’d agree with putting in a bug report. the easy workaround is to leave the value as the pscustomobject in the -Value parameter and convert to a string when you’re about to use it. are you able to get it working that way? see this post for the syntax
Yes, the workaround works, but the handling does, to me, look like a bug.
The -value parameter shouldn’t just be able to handle strings, it is expecting a string input.
My issue, and why I believe it is a bug, is because somehow it treats the objects differently depending on the content of the string…
I will make it work with custom objects (or csv’s which also works fine) for now. Thank you for all your help, it is much appreciated.