UDForm Schema - Re-order properties

When using Schema forms, how does one set the order of the properties?

There’s a uiSchema object and a ui:order property, but I’m not quite sure how exactly to use it.

const uiSchema = {
  "ui:order": ["bar", "foo"]
};

Specifying property order

I may be off, but poking around, it looks like it may not be possible. Looks like it will need to have the uiSchema object passed and from what I can see, that may not be configured. So I may be out of luck.

But now I’m running into a weird issue, when using the required property, the form throws errors even if all of the fields have data.

Also it looks like the documentation needs to be updated for the EventData variables.

$EventData.PropertyName doesn’t work, at least not for me. I’m having to use $EventData.formData.PropertyName to get the data.

1 Like

I know this is an old one, but I’m new to UD and this is making Schema based forms all but worthless to me. If I’m asking for First / Last Names plus some info and the First / Last are multiple values apart on the form it’s a bad use experience. Hoping someone has a workaround.

funny how things crop up. I was just about to raise an issue with this.

the problem is the hashtable, they don’t maintain order (its a powershell thing). but you can make it an ordered dictionary using [ordered]@{}
… but PSU doesnt like this at all.

$schema= @{
title = “Test”
type = “object”
properties =[ordered] @{
hostname = @{
title = “Hostname”
type = “string”
}
ipaddress= @{
title = “IP Address”
type = “string”
format = “ipv4”
}
description = @{
title = “Server Description”
type = “string”
}
}
}

generates this error

Unsupported field schema for field root_0: Unknown field type undefined.

{
“key”: “hostname”,
“value”: {
“type”: “string”,
“title”: “Hostname”
}
}

1 Like

I’m running into this as well, @adam how can we use the ‘order’ property as explained here uiSchema | react-jsonschema-form

Use a PSCustomObject to do it without the UI schema.

        $schema= @{
            title = “Test”
            type = “object”
            properties = [PSCustomObject]@{
            hostname = @{
            title = “Hostname”
            type = “string”
            }
            ipaddress= @{
            title = “IP Address”
            type = “string”
            format = “ipv4”
            }
            description = @{
            title = “Server Description”
            type = “string”
            }
            }
        }

        New-UDForm -Schema $schema -OnSubmit {

        }

If you want to use the UISchema to do it, use this.

        $schema= @{
            title = “Test”
            type = “object”
            properties = [PSCustomObject]@{
            hostname = @{
            title = “Hostname”
            type = “string”
            }
            ipaddress= @{
            title = “IP Address”
            type = “string”
            format = “ipv4”
            }
            description = @{
            title = “Server Description”
            type = “string”
            }
            }
        }

        $uiSchema = @{
            "ui:order" = @("ipaddress", "hostname", "description")
        }

        New-UDForm -Schema $schema -UiSchema $uiSchema -OnSubmit {

        }

Thanks! Not so difficult after all…