Just as an update, here’s some of what I’m doing as a partial solution - would love to find out if it’s actually possible to return a UDGrid as an object from a function and then place it on a page successfully.
Function to return the data and properties/headers I care about:
function New-SNIncidentTable {
$uri = "https://somecompany.service-now.com/api/now/table/incident?sysparm_display_value=true&sysparm_limit=1000&sysparm_query=active%3Dtrue%5EstateNOT%20IN730%2C3%5Eassignment_group%3D361ec2626f14ba0039d3dd1cbb3ee406"
$OpenIncidents = New-SNResponse -URI $uri
#Process and store results
$IncidentData = @()
Foreach ($Incident in $OpenIncidents) {
$IncID = $Incident.Number
$IncLink = "https://nuvasive.service-now.com/task.do?sys_id=$IncID"
$IncImpact = $Incident.Impact
.
.
.
$IncidentInfo = @{ID = (New-UDLink -Text "$IncID" -Url $IncLink)}
$IncidentInfo["Short Description"] = $IncShortDescription
$IncidentInfo["Impact"] = $IncImpact
.
.
.
$IncidentInfo["Resolver"] = (New-UDButton -Text "Resolve" -OnClick {
Show-UDModal -Content {
New-UDInput -Title "Enter Resolution Reason" -Content {
New-UDInputField -Type textbox -Name "Reason" -Placeholder "Resolved"
} -Endpoint {
Show-UDToast -Message "Resolved"
}
}
})
$IncidentData += $IncidentInfo
}
$SNHeaders = @("ID","Short Description","Impact",.......,"Resolver")
$SNProperties = @("ID","Short Description","Impact",......,"Resolver")
$Results = @{"data" = $IncidentData; "headers" = $SNHeaders; "Properties" = $SNProperties}
Return $Results
}
Then I place this in the page where I want it to render:
New-UDCard -Endpoint {
$incidentData = New-SNIncidentTable
New-UDGrid -Title "SN Incidents" -Headers $incidentData.Headers -Properties $Incidentdata.Properties -Endpoint { $IncidentData.data | Out-UDGridData }
}
I’d LOVE to hear if ANYONE has found a way to have the above code be rendered as:
New-UDCard -Endpoint {
$myGridOutput = Return-CustomUDGridObject
$myGridOutput
}