Rob Gething
-
Posts
37 -
Joined
-
Last visited
Content Type
Profiles
Forums
Enhancement Requests
Posts posted by Rob Gething
-
-
If I do:
ConvertFrom-Json -InputObject $taskAnswers, I get:
ConvertFrom-Json : Cannot bind argument to parameter 'InputObject' because it is null.
If I do:
$taskAnswers | ConvertFrom-Json
$answers = $taskAnswers | ConvertFrom-Json
$answers[0].key
$answers[0].value
$answers[0].displayValue
I get:Cannot index into a null array.
It's as if $taskAnswers has not data to pull back, but I can see it in inspect element:
taskAnswers: [{key: "OtherCorrectName", value: "Pipeline", displayValue: "Pipeline"},…]0: {key: "OtherCorrectName", value: "Pipeline", displayValue: "Pipeline"}
displayValue: "Pipeline"
key: "OtherCorrectName"
value: "Pipeline"
-
I am using the following code to get taskAnswers:
# Define output stream type
[OutputType([object])]# Define runbook input params
Param
(
# API Params
#[Parameter (Mandatory= $true)]
[string] $taskId}
# Add XMLMC params
Add-HB-Param "taskId" $taskId $false
# Invoke XMLMC call, output returned as PSObject
$xmlmcOutput = Invoke-HB-XMLMC "task" "taskGetInfo"
$exceptionName = ""
$exceptionSummary = ""
# Read output status
if($xmlmcOutput.status -eq "ok") {
if($xmlmcOutput.params.title -and $xmlmcOutput.params.title -ne ""){
$title = $xmlmcOutput.params.title
$requestWarnings = $xmlmcOutput.params.warnings
}
if($xmlmcOutput.params.options -and $xmlmcOutput.params.options -ne ""){
$options = $xmlmcOutput.params.options
$requestWarnings = $xmlmcOutput.params.warnings
}
if($xmlmcOutput.params.createdOn -and $xmlmcOutput.params.createdOn -ne ""){
$createdOn = $xmlmcOutput.params.createdOn
$requestWarnings = $xmlmcOutput.params.warnings
}
if($xmlmcOutput.params.createdBy -and $xmlmcOutput.params.createdBy -ne ""){
$createdBy = $xmlmcOutput.params.createdBy
$requestWarnings = $xmlmcOutput.params.warnings
}
if($xmlmcOutput.params.owner -and $xmlmcOutput.params.owner -ne ""){
$owner = $xmlmcOutput.params.owner
$requestWarnings = $xmlmcOutput.params.warnings
}
if($xmlmcOutput.params.outcomes -and $xmlmcOutput.params.outcomes -ne ""){
$outcomes = $xmlmcOutput.params.outcomes
$requestWarnings = $xmlmcOutput.params.warnings
}
if($xmlmcOutput.params.taskAnswers -and $xmlmcOutput.params.taskAnswers -ne ""){
$taskAnswers = $xmlmcOutput.params.taskAnswers
$requestWarnings = $xmlmcOutput.params.warnings
}
}
# Build resultObject to write to output
$resultObject = New-Object PSObject -Property @{
Status = $xmlmcOutput.status
Error = $xmlmcOutput.error
ExceptionName = $exceptionName
ExceptionSummary = $exceptionSummary
title = $title
options = $options
createdOn = $createdOn
createdBy = $createdBy
owner = $owner
outcomes = $outcomes
taskAnswers = $taskAnswers
}if($resultObject.Status -ne "ok" -or $exceptionName -ne ""){
Write-Error $resultObject
} else {
Write-Output $resultObject
}I can see that taskAnswers is an array, but I am struggling to return:
taskAnswers: [{key: "OtherCorrectName", value: "Pipeline", displayValue: "Pipeline"},…]0: {key: "OtherCorrectName", value: "Pipeline", displayValue: "Pipeline"}
I've tried a PSCustomObject with with a ForEach-Object to loop through the array, but this doesn't return any results.
Having run $taskAnswers | Get-Member, taskAnswers is Boolean so with only return true or false.
-
I guess that the error is related to:
Looks like the issue is not isolated to us / me / my code and this is a wider issue for Hornbill to look at. I do not have a full azure admin account and neither should one be needed.
-
Actually, you might be onto something there @SamS, my chat bot Azure function is set to anonymous so that might be why?
-
Since there’s just the one parameter for the second script, PowerShell will intelligently match the output of one script to the input of the next, when piped.
‘.\GetRunID.ps1’ -ReportID xxx | ‘.\DownloadReport.ps1’ returns:
@{delivery=; ExceptionName=; files=;
Error=Failed to retrieve report info for Id: 45234; reportRun=; Status=fail; ExceptionSummary=}
If I run the scripts individually I get this from GetRunID:
Status : ok
Error :
ExceptionName :
runId : 51542
ExceptionSummary :
.\reportRunGetStatus.ps1 -runId 51542 has actually successfully downloaded the file but that’s because I ran GetRunID first, got the reportID and then ran .\reportRunGetStatus.ps1 -runId 51542.
I can’t get 51542 to parse to the other script through a pipe and download the file.
-
Hi @SamS,
That basically suggests:
PathToMyScript\MyScript.ps1 -loc ValueOfLoc
Which is similar to:
. "./script1.ps1" -runId $runId
As I said in my original post, this does not have the desired effect.
-
I have two separate scripts:
# Define output stream type [OutputType([object])] # Define runbook input params Param ( # API Params #[Parameter (Mandatory= $true)] [string] $reportId = "842", [string] $outputFormat, [string] $runtimeParameter, [string] $comment, [string] $publish ) # Add XMLMC params Add-HB-Param "reportId" $reportId $false Add-HB-Param "outputFormat" $outputFormat $false Add-HB-Param "runtimeParameter" $runtimeParameter $false Add-HB-Param "comment" $comment $false Add-HB-Param "publish" $publish $false # Invoke XMLMC call, output returned as PSObject $xmlmcOutput = Invoke-HB-XMLMC "reporting" "reportRun" $exceptionName = "" $exceptionSummary = "" # Read output status if($xmlmcOutput.status -eq "ok") { if($xmlmcOutput.params.runId -and $xmlmcOutput.params.runId -ne ""){ $runId = $xmlmcOutput.params.runId } if($xmlmcOutput.params.exceptionName -and $xmlmcOutput.params.exceptionName -ne ""){ $exceptionName = $xmlmcOutput.params.exceptionName $exceptionSummary = $xmlmcOutput.params.exceptionDescription } } # Build resultObject to write to output $resultObject = New-Object PSObject -Property @{ Status = $xmlmcOutput.status Error = $xmlmcOutput.error ExceptionName = $exceptionName ExceptionSummary = $exceptionSummary runId = $runId } if($resultObject.Status -ne "ok" -or $exceptionName -ne ""){ Write-Error $resultObject } else { Write-Output $runId }
This generates a run ID for a report which downloads successfully if I manually enter the run ID into:
# Define output stream type [OutputType([object])] # Define runbook input params Param ( # API Params #[Parameter (Mandatory= $true)] [string] $runId = "45234" ) # Add XMLMC params Add-HB-Param "runId" $runId $false # Invoke XMLMC call, output returned as PSObject $xmlmcOutput = Invoke-HB-XMLMC "reporting" "reportRunGetStatus" $exceptionName = "" $exceptionSummary = "" # Read output status if($xmlmcOutput.status -eq "ok") { if($xmlmcOutput.params.reportRun -and $xmlmcOutput.params.reportRun -ne ""){ $reportRun = $xmlmcOutput.params.reportRun } if($xmlmcOutput.params.files -and $xmlmcOutput.params.files -ne ""){ $files = $xmlmcOutput.params.files } if($xmlmcOutput.params.delivery -and $xmlmcOutput.params.delivery -ne ""){ $delivery = $xmlmcOutput.params.delivery } if($xmlmcOutput.params.exceptionName -and $xmlmcOutput.params.exceptionName -ne ""){ $exceptionName = $xmlmcOutput.params.exceptionName $exceptionSummary = $xmlmcOutput.params.exceptionDescription } } # Build resultObject to write to output $resultObject = New-Object PSObject -Property @{ Status = $xmlmcOutput.status Error = $xmlmcOutput.error ExceptionName = $exceptionName ExceptionSummary = $exceptionSummary reportRun = $reportRun files = $files delivery = $delivery } if($resultObject.Status -ne "ok" -or $exceptionName -ne ""){ Write-Error $resultObject } else { $reportFileLink = $files | Select -ExpandProperty name $reportID = "123" $HornbillKey = "xxxxxxx" [string] $url = "https://mdh-p01-api.hornbill.com/iposervicedesk/dav/" + "reports/" + $reportID + "/" + $reportFileLink $headers = @{} if ($HornbillKey -ne $null) { $headers["Authorization"] = "ESP-APIKEY $HornbillKey" } try { $result = Invoke-WebRequest -Uri $url -Method GET -OutFile "./$reportFileLink" -Headers $headers } Catch { Write-Error $_.Exception.Message } }
What I want to do is parse the run ID that is output from the first piece of code so that the report downloads without having to manually specify the run ID to the second piece of code.
. "./script1.ps1" - runId $runId
Doesn't have the desired effect.
-
I have a teams bot that is an Azure function written in PowerShell.
I have the following function:
function Update-TakeRequest {
[CmdletBinding()]
param(
[string]$ID,
[string]$Key,
[string]$OwnerID,
[string]$OwnerName,
[string]$TeamID,
[string]$TeamName,
[string]$RequestRef
)
$Request = Get-RequestDetails $ID $Key $RequestRef
$MessageBody = ""
if($null -eq $Request.Params.primaryEntityData) {
$MessageBody += "Request $($RequestRef) not found."
} else {
$RD = $Request.Params.primaryEntityData.record
if ($RD.h_fk_team_id -ne $TeamID) {
$MessageBody += "Request $($RequestRef) isn't owned by $($TeamName), so can't be taken by a user in this Team."
} else {
Set-HB-Instance -Instance $ID -Key $Key
Add-HB-Param "inReference" $RequestRef
Add-HB-Param "inAssignToId" $OwnerID
Add-HB-Param "inAssignToGroupId" $TeamID
$Timeline = @{
"updateText" = "''Assigned by $($OwnerName) via Microsoft Teams''"
"source" = "teams"
"extra" = @{
"h_ownername" = $OwnerName
"h_fk_team_id" = $TeamID
"h_group_name" = $TeamName
}
"visibility" = "trustedGuest"
}
$TimelineJSON = $Timeline | ConvertTo-JSON
Add-HB-Param "updateTimelineInputs" $TimelineJSON
$APICall = Invoke-HB-XMLMC "apps/com.hornbill.servicemanager/Requests" "assign"
if ($APICall.Status -eq "ok") {
if ($null -ne $APICall.Params.assignError -and $APICall.Params.assignError -ne "") {
$MessageBody = "An error occurred when attempting to assign the request."
} else {
$MessageBody = "$($RequestRef) has been assigned to you in $($TeamName)"
}
} else{
$MessageBody = "An error occurred when attempting to assign the request."
}
}
}
$bodyObj = @{
"type" = "message"
"text" = $MessageBody
}
return $bodyObj
}run.ps1:
if ($Request.Body.text -like '*update request*') {
$StringArray = $Request.Body.text -split "update request",2
$ContentString = $StringArray[$StringArray.Count - 1].TrimStart()
$ContentArray = $ContentString -split " ",2
$bodyObj = Update-Request $InstanceName $InstanceKey $User.displayName $ContentArray[0] $ContentArray[1] $TeamDetails.Params.id $TeamDetails.Params.name
$body = $bodyObj | ConvertTo-Json -Depth 4
}If a call is assigned to a colleague in my team and I invoke @Hornbill take request IN0012345 for example, I expect that call to be taken from them and assigned to me. What happens instead is the the call gets taken from the owner and assigned back into the main queue for my team, rather than being directly assigned to me.
How do I take from one owner and assign to another?
-
Hi @SamS,
I can confirm that the account does exist and is not disabled.
I have a Teams bot that uses the same keysafe key and that's functioning. Surely if the keysafe key or the account that granted the authorisation were the issue, my bot would be affected too?
-
I get the above error when using the Hornbill Service Manager BPM >> Microsoft / Teams / PostToChannel method, yet I have a Teams license.
I am currently using an incoming webhook as an alternative, but I have concerns that this isn't the most secure method.
Convert each csv item to a string and add them to a Hornbill simple list
in Integration Connectors, API & Webhooks
Posted
The following code adds a stringValue to a list:
This:
Iterates through a column in a csv file and returns 2734 items, but only "Total: 2734" gets added to the list.
How do I convert each csv item to an individual stringValue and add all 2734 items to a Hornbill simple list?