Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get-JiraIssueEditMetadata has no -Project parameter. Get-JiraIssueEditMetadata does #478

Open
hkelley opened this issue May 30, 2023 · 0 comments

Comments

@hkelley
Copy link

hkelley commented May 30, 2023

Context

I use the Get-JiraIssueCreateMetadata cmdlet today to get a list of fields for the issue type and then I use that schema to convert customfield names to friendly names. This works well except for fields that are not in the create screens.

Description

I tried to use the Get-JiraIssueEditMetadata cmdlet to fetch the schema but it doesn't support the -Project, meaning I would have to fetch once per issue.

#
##  Currently use "Create" but would prefer to use "Edit"
#
$fieldschema = Get-JiraIssueCreateMetadata -Project $JiraProjectKey -IssueType 'Task'
#
##  Get a map of custom fields for translation/rename
#
$customFields = $fieldschema | ?{$_.Id -like "customfield_*"}
$personFields = $fieldschema | ?{$_.Schema.Type -eq "user"}

$issues = Get-JiraIssue -Query "project = '$JiraProjectKey' AND created >= -$($LookbackDays)d"

foreach($issue in $issues)
{
    # Fix up custom fields
    foreach($cf in $customFields)
    {
        if($issueField = $issue.psobject.Properties[$cf.Id])
        {
            $issue | Add-Member -NotePropertyName $cf.Name -NotePropertyValue $issueField.Value
            $issue.PSObject.Properties.Remove($cf.Id)            
        }
        else
        {  # stub out the field with a null for consistent CSV exporting
            $issue | Add-Member -NotePropertyName $cf.Name -NotePropertyValue $null
        }
    }

    # Promote the display name for user fields
    foreach($pf in $personfields)
    {
        if($f = $issue.PSobject.Properties[$($pf.Name)])
        {
            $f.Value = $f.Value.DisplayName
        }
    }

    # for all others, de-reference anything that has a "value" field
    foreach($f in $issue.PSObject.Properties)
    {
        if($f.Value.Value -ne $null)
        {
            $f.Value = $f.Value.Value
        }
    }

    Write-Output $issue
}

Could you add the -Project to Get-JiraIssueEditMetadata?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant