AtlassianPS / JiraPS

PowerShell module to interact with Atlassian JIRA
https://AtlassianPS.org/module/JiraPS
MIT License
325 stars 131 forks source link

Add documentation for JiraSD Organization #434

Open agowa opened 3 years ago

agowa commented 3 years ago

Context

Please add documentation on how to set the JiraSD Orgaanization field. Apparently it uses a different syntax than other customfields...

https://atlassianps.org/docs/JiraPS/about/custom-fields.html#custom-fields

Description

The JiraSD Organisation gets returned as (Get-JiraIssue)

"customfield_11302": [
  {
    "id": "27",
    "name": "LoremIpsum Corp",
    "_links": "@{self=https://$SERVER/rest/servicedeskapi/organization/27}"
  }
]

Get-JiraField "customfield_11302":

Schema      : @{type=array; items=sd-customerorganization; custom=com.atlassian.servicedesk:sd-customer-organizations;
              customId=11302}
Custom      : True
Searchable  : True
ClauseNames : {cf[11302], Organizations}
ID          : customfield_11302
Orderable   : True
Navigable   : True
Name        : Organizations

According to the documentation it would be set as: Set-JiraIssue -Issue $ticket.Key -Fields @{ Organizations = @( @{ id = 27 } ) }

But that fails with:

Invoke-JiraMethod: E:\Users\%username%\Documents\PowerShell\Modules\JiraPS\2.14.6\JiraPS.psm1:5505
Line |
5505 |                      Invoke-JiraMethod @parameter
     |                      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     |  customfield_11302 ----------------- Operation value must be a number at array index 0

Oddly (Get-JiraField "customfield_11302").AllowedValues doesn't return anything.

After digging a bit in the Atlassian documentation and issues I found: https://jira.atlassian.com/browse/JSDSERVER-4353 Which would result in: Set-JiraIssue -Issue $ticket.Key -Fields @{ Organizations = @(27) }

And that works.