Get-UDElement issue?

Ok, I’ve been trying to figure this out for a week now.
I’m trying to hide elements based on the result of a dropdown. At different times it works, but mostly it doesn’t.

In this example, the error seems to come from trying to hide the “fetch” button.

The debug log has this in it:
07:50:14 [Warn] PowerShellExecutionService Error executing endpoint eGetADAcctDisposition. You cannot call a method on a null-valued expression.
at , : line 66
07:50:14 [Debug] ComponentController ConvertToActionResult() {“Error”:{“message”:“You cannot call a method on a null-valued expression.”,“location”:null,“type”:“error”,“id”:null,“refreshInterval”:0,“autoRefresh”:false,“hasCallback”:false}}

This is the code that gets called:
# Hide the element…
$attributes = $null
$TheUDElement = Get-UDElement -Id ebtnFetch
$attributes = $TheUDElement.Attributes
if ((!(IsNull($attributes))) -and ($attributes.ContainsKey(“style”))){ $attributes.Remove(“style”) }
$attributes.Add(“style”, @{display = “none”})
Set-UDElement -Id “ebtnFetch” -Attributes $attributes
$TheUDElement = $null

It seems that Get-UDelement doesn’t return the attributes, so its null (pardon my IsNull function, thats me testing stuff).

Am I not using Get-UDElement correctly? I’ve tried it with no-quotes, single quotes, double quotes, directly, indirectly.
I’m going to try putting in a loop to try 5 times grabbing the attributes. Wanted to put this out there though to see if anyone else came across it.

In this particular case, its crashing on a button. But I’ve seen it crash at other places too. (I reset text boxes and other dropdowns too)

I’m running this in UD 2.9 on IIS.


Hello @eefisherv dude, I hate it when a plan doesn’t go to plan…so thankfully I write some readme documentation every now and then :slight_smile:

This shows you how to easily hide a component on the page :grin: I got everything in the readme that you should need, boost my downloads by downloading the component and follow through with the example readme, you should then be able to apply the same to your dashbaord…I hope this helps…Let me know :+1:

Holy powershell-programming Batman! That was so much easier. Thank you!

How do you figure out what attributes are available? I was trying different ways to show them, but couldn’t figure it out. Granted, only played with it for like 15 minutes then got called into another meeting.

I did download your component… that will be useful down the line as my dashboard evolves.

Thanks again!

1 Like

Awesome work @eefisherv and glad I could shine some light onto the situation. To find out what attributes are available you can use get-udelement I use firefox as my preferred browser and I downloaded this cool REACT plugin, so if I press F12 I can find the component via the ID parameter name I give it, it then shows me the props and state, so I can see what is available to me with the given component. I got quite a few components on the marketplace that all do various little things, so do recommend you look at them as may give you a new way to display your data to impress your colleagues :grin:
I’ve chucked quite a lot on github so I may have something on there that can help you out. Anyways glad you completed the task :+1:

Oh, that is so cool. Thanks again.

1 Like