New-UDApp -Title 'SyncVMwareVMtoSharePoint' -Pages @(
    New-UDPage -Name "Home" -Content {
        New-UDForm -Content {
            New-UDTypography -Text 'Enter a VMware VM name below and click the Submit button'
            New-UDRow -Columns {
                New-UDColumn -SmallSize 6 -LargeSize 6 -Content {
                    New-UDTextbox -Id 'VMName'
                }
            }          
        } -OnValidate {
           $FormContent = $EventData

    if ($FormContent.VMName -eq $null -or $FormContent.VMName -eq '') {
        New-UDFormValidationResult -ValidationError "VMName is required"
    } else {
        New-UDFormValidationResult -Valid
    }
        } -OnSubmit {
            Show-UDToast -Message ($EventData.VMName + " sync in progress.") -Duration 5000
            
            Invoke-PSUScript -Script 'Sync-ITDVMwareVMMetadataToSharePoint_script.ps1' -VMName $EventData.VMName -Wait | Out-Null

            Show-UDToast -Message ($EventData.VMName + " sync finished.") -Duration 10000
        } -OnProcessing {
            New-UDTypography -Text ("Syncing " + $EventData.VMName + " ...")
            New-UDProgress
        }
    }
)