AndrewPla / TOPdeskPS

PowerShell module to interact with the TOPdesk API
MIT License
30 stars 12 forks source link

New-TdIncident doesn't support optionalFields1 #106

Open goback136 opened 4 years ago

goback136 commented 4 years ago

Unlike Set-TdBranch New-TdIncident doesn't support the optional fields while the API does seem to support it.

https://developers.topdesk.com/documentation/index.html#api-Incident-CreateIncident For example "optionalFields1" : { "boolean1" : "true" }

goback136 commented 4 years ago

Hotfixed this 2 new parameters:

function New-TdIncident { .... [hashtable]$OptionalFields1, [hashtable]$OptionalFields2, ....

OptionalFields1 { $Body | Add-Member -MemberType NoteProperty -Name 'optionalFields1' -Value $OptionalFields1 } OptionalFields2 { $Body | Add-Member -MemberType NoteProperty -Name 'optionalFields2' -Value $OptionalFields2 }

boatbuys commented 3 years ago

Can you provide an example (and perhaps update the docs) of how to set a value in an optional field X -> drop down X for a new incident?

goback136 commented 2 years ago

Sure

Filling variable with optional fields

$Vrije_velden = @{} $Vrije_velden.add('text1',$x) $Vrije_velden.add('text2',$y) $Vrije_velden.add('number1',$a) $Vrije_velden.add('number2',$b) $Vrije_velden.add('boolean3','true')

preparing all incident parameters

$IncidentParams = @{ BriefDescription = $MeldingTitel CallerName= $MelderNaam CallerEmail = $MelderMail CallerMobileNumber = $MelderGSM Request= $MeldingBeschrijving
ExternalNumber = $SubmissionID CallerBranchId = (Get-TdBranch -name 'My branch').id EntryTypeId = (Get-TdEntryType -Name 'Website').id PriorityId = (Get-TdPriority -Name $Prioriteit ).id OperatorId = (Get-TdOperatorGroup -Name $Behandelaar).id OperatorGroupID = (Get-TdOperatorGroup -Name $Behandelaar).id optionalFields1 = $Vrije_velden }

calling the API

New-TdIncident @IncidentParams -verbose