Missed Team ’24? Catch up on announcements here.

×
Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

not able to update project object and issue key

David Lemon April 28, 2013
map = new HashMap<String, String>();
        map.put("Stalwarts - ST","ST");
        map.put("Pacers - PA","PA");
        map.put("Hunters - HU", "HU");
Newproject = ComponentAccessor.getProjectManager().getProjectObjByKey(map.get(customValue));
         MutableIssue someMutable = (MutableIssue) event.getIssue;
         someMutable.setProjectObject(Newproject);
         someMutable.setProjectId(Newproject.getId());
         Long id = ComponentAccessor.getProjectManager().getNextId(Newproject);
         someMutable.setKey(Newproject.getKey() + "-" + id);
someMutable.setIssueTypeId(event.getIssue().getIssueTypeObject().getId());
         someMutable.setDescription("something is working");
         try{
             newIssue = ComponentAccessor.getIssueManager().updateIssue(getThisUser(),someMutable, EventDispatchOption.ISSUE_UPDATED,true);
}catch(Exception e){e.printStackTrace()}

well igore the map concept that is auto selected on a custom field selection.. and thats returning right values. just consider that map is returning the Project key according to the custome field value

here:

new project is created.

then mutable issue is created

few setters are called

But only description is getting updated in the issue and nothing else.

i wanted to change the projectObject and issue Key.

please give any idea for my attempt

2 answers

1 accepted

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

3 votes
Answer accepted
Bhushan Nagaraj
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
April 28, 2013

Hi Sohil,

Use the IssueService and check your updateValidationResult

https://developer.atlassian.com/display/JIRADEV/Performing+Issue+Operations

David Lemon April 28, 2013

i have tried that too before. not working

and with my method i am able to update everything other than projectObject,projectId and issue key..

please suggest some bug in my method.

Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
April 28, 2013

Bhushan is correct here - you can't just set the project and key, you need to go through the whole "move issue to new project" process.

That will also force validation on your process and if it's "not working", you'll be told why in the logs.

Also, you've mentioned project and issue key - the other thing that will fail is status...

David Lemon April 29, 2013

hello @Bhushan & @Nic

Newproject = ComponentAccessor.getProjectManager().getProjectObjByKey(map.get(customValue));
        try{
        IssueService.IssueResult issueResult= ComponentAccessor.getIssueService().getIssue(getThisUser(),getEvent().getIssue().getKey());
        MutableIssue mutableIssue = (MutableIssue) event.getIssue();
        mutableIssue.setProjectId(Newproject.getId());
        Long id = ComponentAccessor.getProjectManager().getNextId(Newproject);
        mutableIssue.setKey(Newproject+"-"+id);
        mutableIssue.setSummary("mutableIssue.setSummary some SUEMM "+mutableIssue.getKey());
        IssueInputParameters issueInputParameters = ComponentAccessor.getIssueService().newIssueInputParameters();
        issueInputParameters.setProjectId(Newproject.getId());
        issueInputParameters.setComment("issueInputParameters.setComment new comment");
        issueInputParameters.setIssueTypeId(getEvent().getIssue().getIssueTypeObject().getId());
        //issueInputParameters.setSummary("This is a summary");
          issueInputParameters.setDescription("describing in issueInputParameters.setDescription");
            IssueService.UpdateValidationResult updateValidationResult = ComponentAccessor.getIssueService().validateUpdate(getThisUser(),getEvent().getIssue().getId(),issueInputParameters);
        ComponentAccessor.getIssueService().update(getThisUser(),updateValidationResult,EventDispatchOption.DO_NOT_DISPATCH,false);
}catch(Exception e){e.printStackTrace();}

IssueService is working well and faster but it is not providing me the IssueKey update setter.

I think its the my way i was doing before may work (code in the question). MutableIssue has a IssueKey setter.

Can you tell me even if the MutableIssue object has the setter for issue key and project object and project id as well, still its not reflecting the db and the ui. well I have checked the updated value programatacally of issue key it is showing me the updated value.

Like bryan.bai@wdc.com likes this
Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
April 29, 2013

I'm not sure you've understood what we've said. You're still trying to "update" an issue. This does not work because you really need to "move" the issue.

David Lemon April 29, 2013

M sorry @Nic.
My requirenment is to move an issue programatically, on a custom field selection. Is there any solution for that.

or it can only be done by the UI "move issue to new project" ?

2 votes
Bhushan Nagaraj
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
April 28, 2013
David Lemon May 26, 2013

Hello @Bhushan please look at this question related to the same question above.

https://answers.atlassian.com/questions/173760/update-function-not-working

TAGS
AUG Leaders

Atlassian Community Events