UDElement Question

Hello Everyone!

I was wondering if it is possible to have multiple elements with the same name if they are on different pages.

Thank you,

I believe it is only the -Id parameter which has to be unique…so you give them all the same name as long as they all got different -Id

I probably should have been saying Id, meant that instead of Name.

I am setting by -Id, so if that has to be unique, i can’t use the same button for a different page…

Bummer.

Dude just give it a different -id like -id button1 id button2 etc…I believe I am correct in saying it has to be unique as I had design elements when using the grid layout, as I was copying and pasting that code, and found my layout stopped working, as I was using the same ID tag as I copied and pasted the layout grid design…so to get around this I just added a number to the ID to make it unique…Also pretty sure it has to have a unique ID for each element as when calling sync-udelement it needs the ID to sync with…I mean HTML seems more @BoSen29 avenue…but you could create a new-udelement -tag ‘div’ with an id then nest all buttons in there then when you sync the ID of the div it will refresh the buttons in it too I believe…anyways hope this gives some insight.
You can sync multiple IDs at the same time

Sorry re-read original post…my issue was because I was using TABBED pages so it was in essance all on the same page…I guess it’s good practise to have a unique ID, hence the guid is automatically created for them, so they are unique…

1 Like

Hi guise,
@Jacob-Evans and @psDevUK
The ID is used for all references of the object in UD.
If you have duplicate ID’s you might experience weird issues.

Do as @psDevUK reccomends, with a twist:
Make a “container” for your buttons:

new-udelement -id “syncable” -tag “span” -endpoint {
#all your buttons here (without a specified ID)!
}

When you need to refresh said buttons, just refresh the parent’s ID (which should be unique).

1 Like

I did mean this but with a div tag…but was being a tad lazy and typed it instead of coding this…Thanks @BoSen29 for clarifying the ID situation…top man! :slight_smile:

1 Like

All of my buttons are attached to AD Objects in a Cache, Ex:

$AllUsers = $AllAccounts |  Select-Object LockedOut, PasswordExpired, Description, Office, SamAccountName, Name, Department, Title, accountexpirationdate, Enabled, UserPrincipalName, St, @{Name = "Details"; Expression = { New-UDButton -Text "Show Details" -OnClick (...)}

And there are 13 of those buttons added this way.

Moving them is far more complicated then just copy/paste as i am pulling data from the AD Object into the buttons.

I have a few buttons that i am trying to get to work on more then one page, they call:

Set-UDElement -Id "adWorkingArea" -Content {...}

the ID varies depending on where the button is used. Just as life goes on and projects grow, we found ourselves wanting to have some of those buttons work on different pages.