Error when calling functions

Recently I’ve been having this issue when my page loads and click one of the buttons right after is done, I get unable to find errors. It happens with my custom functions within the script and objects. If I refresh the page, then issue goes away.

Any ideas as to what could be causing thins and how to prevent?

Product: PowerShell Universal
Version: 2.2.0

Any suggestion is greatly appreciated!

How are you importing these functions? Are they in modules?

They are at the top of the page script

Hmm weird. Ok. You could try to put them in a PSM1 file and then add that PSM1 path to the modules for the environment used by your dashboard. This would cause the module to load before anything else.

Kool beans! I will that a try.

What is the proper way of using custom functions within PSU environment?

What you are doing should work but I’d recommend modules in the environment since you can easily use them through out PSU that way.

Awesome! Thank so much for the advice and info :slight_smile:

Now that I’m paying more attention, where in PSU can I add the PSM1 and how to make sure is being loaded when Dashboard start?

OK, I was able to load the PSM1 file but am having issues accessing an enum from within PSU but have no issues if I run it in ISE

using module C:\ProgramData\UniversalAutomation\Repository\Scripts\PSUCustomFunctions.psm1

PSUCustomFunctions.psm1 file

enum SecurityGroups {
    WebDeployerSecGroup
    TestGroup
}

class FileUploadInfo
{
    [string]$LocalPath
    [string]$RemotePath
    [array]$FileNames
}

function New-CenterContent {
    param($Content)

    New-UDElement -tag div -Attributes @{ style = @{ position = 'absolute'; top = '50%'; Left = '50%'; transform = 'translate(-50%, -50%)'; } } -Content $Content
}