AtlassianPS / JiraPS

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

Invoke-JiraIssueTransition for Cascading Select Child Options #468

Closed joe-heaton closed 5 months ago

joe-heaton commented 1 year ago

Cannot Transition due to Child option, using only the parent works fine but does require the child.

I have used value & id now, also have used as many different variations i can think of incl.

I must be missing something, but i am unsure how to add a single-string constructor/factory method as per error message given.

Following instructions HERE: https://atlassianps.org/docs/JiraPS/about/custom-fields.html#cascading-picker

$transitionparams = @{
    customfield_13590 = @{

    id = 14976

    child = @{

    id = 14989

    } 
    }

    'customfield_10227' = $resolution
  }

Get-JiraIssue -Issue $jiraticket | Invoke-JiraIssueTransition -Transition 341 -Fields $transitionparams -Verbose

This is the error recieved:

`VERBOSE: [Resolve-ErrorWebResponse] Retrieved body of HTTP response for more information about the error ($responseBody)
Invoke-JiraMethod : 
customfield_13590                                                                                                                                                                                                                                                              
-----------------                                                                                                                                                                                                                                                              
Can not instantiate value of type [simple type, class com.atlassian.jira.issue.fields.rest.json.beans.CustomFieldOptionJsonBean] from JSON String; no single-String constructor/factory method (through reference chain: com.atlassian.jira.issue.fields.rest.json.beans.Cus...
At C:\Program Files\WindowsPowerShell\Modules\JiraPS\2.12.5\JiraPS.psm1:3138 char:9
+         Invoke-JiraMethod @parameter
+         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidResult: (:) [Invoke-JiraMethod], RuntimeException
    + FullyQualifiedErrorId : InvalidResponse.Status400,Invoke-JiraMethod`
joe-heaton commented 1 year ago

Further information from the Verbose as im still struggling, i can post debug too if that is useful but unsure where im going wrong. Seen a similar issue where the Headers was an Empty String? if this helps?


VERBOSE: [Invoke-JiraMethod] Post https://URL/rest/api/latest/issue/365436/transitions?maxResults=25
VERBOSE: [Invoke-JiraMethod] Failed to get an answer from the server
VERBOSE: [Test-ServerResponse] Checking response headers for authentication errors
VERBOSE: [Invoke-JiraMethod] Status code: BadRequest
VERBOSE: [Resolve-ErrorWebResponse] Function started
VERBOSE: [Resolve-ErrorWebResponse] Retrieved body of HTTP response for more information about the error 
($responseBody)
joe-heaton commented 1 year ago

Still issues with this,

Current Error message is :

customfield_13590 ----------------- Can not instantiate value of type [simple type, class com.atlassian.jira.issue.fields.rest.json.beans.CustomFieldOptionJsonBean] from JSON String; no single-String
constructor/factory method
joe-heaton commented 1 year ago

Further information is i seem to be able to get .child.value and it give me what i want.

Name                           Value
----                           -----
child                          {[value, User - Advice Given]}
value                          Site Support
joe-heaton commented 1 year ago

get-jirafield "customfield_13590" - Output

Navigable   : True
Orderable   : True
ID          : customfield_13590
Searchable  : True
Custom      : True
ClauseNames : {cf[13590], Closure Code, Closure Code[Select List (cascading)]}
Name        : Closure Code
Schema      : @{type=option-with-child; custom=com.atlassian.jira.plugin.system.customfieldtypes:cascadingselect; customId=13590}
joe-heaton commented 1 year ago

Further digging, the Validators for this transition is a "Build-Your-Own (Scripted)

!! issue.customfield_13590.child.value must return true
Rogueit commented 1 year ago

So are you trying to transition both Issue-14976 & Issue-14989?

joe-heaton commented 1 year ago

@Rogueit so these are the customfields inside of the issue I'm trying to transition.

These are required to successfully transition the issue, both for customfield_13590 and one ID is the parent and the other the child.

Rogueit commented 1 year ago

So one thing I see that is different from the way i'm doing it is your ids are in single quotes. And maybe double quote resolution.

$transitionparams = @{
    customfield_13590   = @{

        id    = '14976'

        child = @{

            id = '14989'

        } 
    }

    'customfield_10227' = $resolution
}