Not sure if I just need a second set of eyes or if it’s an actual problem. I’m using schema method of New-UDForm and can’t seem to get the dynamic schema dependencies method to work.
The doc for it is located here: Dynamic Schema Dependencies
Here’s what I have:
$emSchema = @{
title ="New Employee Form"
type = "object"
properties = @{
givenname = @{
title = "First Name"
type = "string"
}
surname = @{
title = "Last Name"
type = "string"
}
title = @{
title = "Job Title"
type = "string"
}
department = @{
title = "Department"
type = "string"
}
manager = @{
title = "Manager"
type = "string"
}
modeluser = @{
type = "string"
title = "Model User?"
enum = @("no", "yes")
default = "no"
}
}
dependencies = @{
modeluser = @{
oneOf = @(
@{
properties = @{
modeluser = @{
enum = "no"
}
}
},
@{
properties = @{
modeluser = @{
enum = "yes"
}
modelafter = @{
type = "string"
title = "Model After"
}
}
required = @('modelafter')
}
)
}
}
}
It’s just a simple form gathering some user info. What should happen, is that when you set the modeluser dropdown to yes, the modelafter textbox should appear.
It took a moment to get the formatting of the oneOf block correct, but I was able to test it with this blurb and it does change the properties of the text box based on the option you choose.
$testSchema = @{
title ="Test Form"
type = "object"
oneOf = @(
@{
properties = @{
txttestone = @{
title = "Test Textbox 1"
type = "string"
}
}
},
@{
properties = @{
txttesttwo = @{
title = "Test Textbox 1"
type = "string"
}
}
}
)
}
So the possibilities are:
- my formatting is still off
- the method isn’t support
- I’m just doing it wrong
- I’m crazy for even doing it this(<—probably the right choice)
For now i’m just going to scrap that part and make the field not required as this was probably just the better way to do it in the first place, but an additional set of eyes or info would be appreciated for my sanity’s sake.
Product: PowerShell Universal
Version: 3.2.2