AtlassianPS / JiraPS

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

Create Jira-Issue with multiple customfileds #388

Closed TimonsElsa closed 4 years ago

TimonsElsa commented 4 years ago

Hello,

im trying to create a jira issue with two custom fields. First I tried that, but it failed: Operation value must be a string Could not find valid 'id' or 'value' in the Parent Option object.

$phone = @{
       'customfield_12000' = @{ 
       value = '100000'
       }
}

$field = @{
    'customfield_11102' = @{
        id = 11700
    }
}

Get-JiraField -Field "customfield_11102"
New-JiraIssue -project "SERVICE" -IssueType Support -Summary Test -Priority 2 -Description "Test with PS" -Fields $field, $phone

Next i tried the example from "https://psjira.readthedocs.io/en/latest/custom_fields.html", but it failed with: Invoke-JiraMethod customfield_12000
Operation value must be a string

$fields = @{
    customfield_12000 = @{
        value = "100000"
    }
    customfield_11102 = @{
        id = '11700'
    }
}

New-JiraIssue -project "SERVICE" -IssueType bug -Summary Test -Priority 2 -Description "Test with PS" -Fields $fields`

Can anyone tell me the right way to create the issue correctly with multiple customfileds? Later i want to mix more customfileds with values and id's to create more accurate Tickets.

Thx for help guys!

lipkau commented 4 years ago

thank you for calling my attention to the readthedocs page. I deleted it, as it has been outdated for over 2 years. This is the correct documentation page: https://atlassianps.org/docs/JiraPS/

Your ticket does not describe what kind of field it is that you are trying to change. But based on the error you described

Operation value must be a string Could not find valid 'id' or 'value' in the Parent Option object.

I would assume that one of the two fields is a child of the other. If that is the case, this is the correct way to change the value of the field: https://atlassianps.org/docs/JiraPS/about/custom-fields.html#cascading-picker

if that is not the case, please describe what those two fields are. You can use

Get-JiraField customfield_12000 , customfield_11102
TimonsElsa commented 4 years ago

Hello @lipkau ,

thank you for the link to the documentation!

The fields i want to change are two different fields, which must be filled to create the Ticket. It is the Phone number of the User and the "Department".

i hope i can describe it correctly -> its like the issue here: https://github.com/AtlassianPS/JiraPS/issues/56

PS C:\WINDOWS\system32> Get-JiraField customfield_12000 , customfield_11102

ID          : customfield_12000
Searchable  : True
Schema      : @{type=string; custom=com.atlassian.jira.plugin.system.customfieldtypes:textfield; customId=12000}
Name        : Phone
Custom      : True
Navigable   : True
Orderable   : True
ClauseNames : {cf[12000], Phone}

ID          : customfield_11102
Searchable  : True
Schema      : @{type=option; custom=com.atlassian.jira.plugin.system.customfieldtypes:select; customId=11102}
Name        : Department
Custom      : True
Navigable   : True
Orderable   : True
ClauseNames : {cf[11102], Department}

Regards

lipkau commented 4 years ago

try this:

$fields = @{
    customfield_12000 = "100000"
    customfield_11102 = @{
        id = '11700'
    }
}

New-JiraIssue -project "SERVICE" -IssueType bug -Summary Test -Priority 2 -Description "Test with PS" -Fields $fields`
TimonsElsa commented 4 years ago

Wonderfully it works as desired. Sometimes you just do not see the mistake. Thank you for your patience and help