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

Unable to add comment during transition #248

Closed
ghostsquad opened this issue Dec 16, 2019 · 5 comments
Closed

Unable to add comment during transition #248

ghostsquad opened this issue Dec 16, 2019 · 5 comments
Labels

Comments

@ghostsquad
Copy link
Contributor

On behalf of @hdshah-dev

Hello Andy,
I am using go-jira client version 1.11.1. I am trying to see an option to change the transition of an issue with a comment (as part of the update). I do see DoTransitionWithPayload() method to allow a payload TransitionPayload (struct). However I dont see a way to set the comment in TransitionPayload struct or there is one to be used. Can you please confirm if this feature is yet to be implemented or if otherwise can you provide an example to do?
Thanks

@ghostsquad
Copy link
Contributor Author

According to this:
https://docs.atlassian.com/software/jira/docs/api/REST/6.2.5/#d2e1171

The fields that can be set on transtion, in either the fields parameter or the update parameter can be determined using the /rest/api/2/issue/{issueIdOrKey}/transitions?expand=transitions.fields resource. If a field is not configured to appear on the transition screen, then it will not be in the transition metadata, and a field validation error will occur if it is submitted.

This leaves me to believe that we probably shouldn't be used TransitionFields here:

type TransitionPayloadFields struct {

We should use IssueFields, as this would provide the greatest flexibility.

Howevever, This is a backwards incompatible change.

There's good news though!

func (s *IssueService) DoTransitionWithPayload(ticketID, payload interface{}) (*Response, error) {

payload here is an interface{} can you pass an arbitrary struct to it, which means you can make your own TransitionPayload with the right tags to be serialized properly.

Finally some more bad news:

Your mileage may very. I found an open Atlassian issue about this exact thing, and it appears to not be well supported.

https://jira.atlassian.com/browse/JSDSERVER-5034

@hdshah-dev
Copy link

hdshah-dev commented Dec 17, 2019

Hello,
Thank you for prompt reply on this and detailed info. I tried with my custom structure as below

payload := CreateTransitionPayload{
		Transition: TransitionPayload{
			ID: transitionID,
		},
		Update: TransitionPayloadFields{
			Comment: []Comment{{Add: AddComment{Body: "Fixed...again"}}},
		},
	}

However the Update field gets changed to Fields as somewhere down the json encoder code path as below

{
  "transition": {
    "id": "101"
  },
  "fields": {
    "Comment": [
      {
        "Add": {
          "Body": "Bug has been fixed."
        }
      }
    ]
  }
}

Using cURL command I was able to transition the state with a comment that needs to be filled in the popup screen by having the payload below

{
	"transition": {
    		"id": "101"
	},
	 "update": {
        "comment": [
            {
                "add": {
                    "body": "Bug has been fixed."
                }
            }
        ]
    }
}

Any advice if there is a way to not have Update field change to Fields or any other work around?
Thanks

@ghostsquad
Copy link
Contributor Author

Can you provide the struct definition you are using?

@hdshah-dev
Copy link

hdshah-dev commented Dec 17, 2019

Nevermind, I was using the wrong tag for the struct. After changing it as below I was able to DoTransitionWithPayload() with a comment to add...Hallelujah!
Thanks!!!

type TransitionPayloadFields struct {
	Comment []Comment `json:"comment" structs:"comment"`
}

@ghostsquad
Copy link
Contributor Author

ghostsquad commented Dec 17, 2019

Woo!

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

No branches or pull requests

2 participants