It's all about the answers!

Ask a question

How to set creator of a WI and Attachments in WI through Plain Old Java Client?


Harish Raj (1131519) | asked Aug 08 '12, 2:16 p.m.
edited Aug 09 '12, 2:29 a.m.
Is there a way/method by which we could change the 'Created By' attribute by Plain Old Java Client? I know how can do it by Bugzilla. We have created a tool to upload bulk Attachments for WIs as a part of HP QC to Jazz migration. Though we are able to perform this operation, the creator and created date of the attachment remaining unsuccessful.

so thought of keeping you updated about this to discuss this further.



Accepted answer


permanent link
Ralph Schoon (55.6k23642) | answered Aug 09 '12, 12:18 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
Hi Harish,

you can use the following built in methods on IWorkitem to set the creator/owner:

            IWorkItem workItem = workingCopy.getWorkItem();
            workItem.setCreator(contributor);
            workItem.setOwner(contributor);
           
Please see https://rsjazz.wordpress.com/2012/08/02/subscribing-to-a-work-item-using-the-java-api/ how to use

fTeamRepository.contributorManager().fetchContributorByUserId()

to get the user if you just have the ID.
Harish Raj selected this answer as the correct answer

Comments
Harish Raj commented Aug 09 '12, 2:25 a.m.

Thanks, Ralph. Any Idea how to set the creator of the attachment and creation date of the attachment in a WI through Java API?

2 other answers



permanent link
Ralph Schoon (55.6k23642) | answered Aug 09 '12, 2:50 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
Hi Harish,

I looked into the API and could not find a setter for the creator or the the creation date. It might be impossible to do. I am not sure but I think I remember that I have seen a similar issue with the ClearQuest Synchronizer.

permanent link
Carlos Maciel (3112) | answered Mar 31 '14, 5:50 p.m.
 Hi Harish, Ralph. 

This answer might be too late, but here it is for anyone else doing any dev with the java plain API:

The work item methods setCreator() and setCreationDate() will fail if the attribute is readonly at attribute, not editor, level (directly on the Configuration Data > Work Items > Types and Attributes).

They do not throw errors or exceptions so far as I've tested but once an admin removes that readonly flag (unchecks the box) then you can set creator and creation date programmatically.

Comments
Ralph Schoon commented Apr 01 '14, 2:46 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

Thanks Carlos, I remember I did change the creator on creation, so that is probably why I did not notice. I also had administration rights.

Your answer


Register or to post your answer.