Dynamic Text for label

This forum can be browsed by the general public. Posting is limited to current SAPIEN license holders with active maintenance and does not offer a response time guarantee.
Forum rules
DO NOT POST LICENSE NUMBERS, ACTIVATION KEYS OR ANY OTHER LICENSING INFORMATION IN THIS FORUM.
Only the original author and our tech personnel can reply to a topic that is created in this forum. If you find a topic that relates to an issue you are having, please create a new topic and reference the other in your post.

Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
This topic is 11 years and 9 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
StupidSexyFlanders
Posts: 107
Last visit: Thu Apr 29, 2021 8:47 am

Dynamic Text for label

Post by StupidSexyFlanders »

I need a label that will reflect the current working domain when the form loads (using PSS3.0.4). Here's what I have so far (just showing relevant sections):$OnLoadFormEvent={#TODO: Initialize Form Controls here $getDomain = Get-ChildItem env:USERDOMAIN [string]$D = $getDomain.Value} $DomainName.Font = "Microsoft Sans Serif, 9pt, style=Bold" $DomainName.ForeColor = 'Black' $DomainName.Location = '125, 9' $DomainName.Name = "DomainName" $DomainName.Size = '225, 16' $DomainName.Text = $DIf I replace $Domain.Text = $D with $Domain.Text = "My Domain Name", the label shows that string as its label. But the $D value is not showing at all. When I run this is a PS CLI the value of $D is returned as the proper string.I also tried defining the variables outside the OnFormLoadEvent region and got the same result.
Mike
User avatar
davidc
Posts: 5913
Last visit: Mon Jul 08, 2019 8:55 am
Been upvoted: 2 times

Dynamic Text for label

Post by davidc »

It could be that the getDemain variable is null. Try this instead: $env:UserDomain David
David
SAPIEN Technologies, Inc.
StupidSexyFlanders
Posts: 107
Last visit: Thu Apr 29, 2021 8:47 am

Dynamic Text for label

Post by StupidSexyFlanders »

Ah, that was the key. I replaced all this:$getDomain = Get-ChildItem env:USERDOMAIN[string]$D = $getDomain.Value$DomainName.Text = $DWith just this: $DomainName.Text = $env:UserDomainThanks!
Mike
This topic is 11 years and 9 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.