Jazz Forum Welcome to the Jazz Community Forum Connect and collaborate with IBM Engineering experts and users

Validation errors for item: type = WorkItem - When adding Comments to a Work Item programatically.

Hi All,

I am getting the error message

com.ibm.team.repository.common.validation.PropertyConstraintException: Validation errors for item: type = WorkItem, itemId = [UUID _AIwpoLuhEeGplK6EoWL7QQ]
    Required property must not be null: internalComments.creationDate

When appending the Comments to an Work item from java API.

following is the Sourec I am using for appending the comment...

XMLString CmtMsg = XMLString.createFromPlainText(StrComment);
System.out.println("StrComment : " + StrComment);
IComments comments = sourceworkItem.getComments();
IComment comment = comments.createComment(getAuthenticatedContributor(), CmtMsg);
comments.append(comment);

Note : I am using a Server side plugin and I am adding a Comment to a WI which is currently getting saved. hence I am not using the Working copy concept.

Thanks..

Regards
Muthukumar.C


0 votes


Accepted answer

Permanent link
w.r.t the error that you are facing:

comment.setCreationDate();

You can assign a value to this date attribute.
Muthukumar C selected this answer as the correct answer

0 votes


6 other answers

Permanent link
Hi Muthukumar,
                              What does CmtMsg refer to? Any additional validation scripts (or) pre-conditions enabled?

I have 1 query, Instead of the loggedin contributor, if we want to add a handle to another user, which method should eb used? (Instead of GetAuthenticatedContributor())

Thanks.

0 votes


Permanent link
Hi Valli,

CmtMsg is nothing but a XMLString variable formed from a String variable.. Refer 1st line of my code. No additional validations are there related to this comment adding operation...

Regarding your query, the method is

IContributorService IConService = getService(IContributorService.class);
IContributorHandle user = IConService.fetchContributorByUserId("existinguserid");
AnyWorkItem.getSubscriptions().add(user);
System.out.println("UserID : Your UserID is added as subscriber");

Regards
Muthukumar.C

0 votes

Comments

I have given the example to add subscriber. Same will be applicable for Comments also


Permanent link
Hi Muthukumar,
                          Thanks. I am actually trying to create an approval item. Do you know how to add multiple approvers to an approval item programatically? My code is :

IContributorService IConService = getService(IContributorService.class);
             IContributorHandle user = IConService.fetchContributorByUserId("ccm_user");
            IApprovals approvals= sourceworkItem.getApprovals();
            IApprovalDescriptor descriptor= approvals.createDescriptor(WorkItemApprovals.APPROVAL_TYPE.getIdentifier(), "Lead Developer Approval");

                
                     IApproval approval= approvals.createApproval(descriptor, user);
                                             approvals.add(approval);

createApproval method allows only 1 contributor handle. How to add multiple approvers?

0 votes


Permanent link
I did that already. But unfortunately setCreationDate method is available only in Comment type and not in IComment.
So I did the following
((Comment)comment).setCreationDate(CurrentTimeStamp);

Thanks!!!

Will revert back to your query asap.

Regards
Muthu

0 votes

Comments

Hi Muthukmar,


Using 4.0.1 SDK, the setCreationDate() method gives me the following 'Discouraged Access' notice: "The method setCreationDate(Timestamp) from the type Comment is not accesible due to restriction on required library.

I've tried to override the notice but it doesn't appear to be working at all. Are you aware of any solution on this? or have you not encountered this error?

Thanks in advance,
Regards
Carlos M

hi Carlos,


I am also using SDK 4.0.1 and the line 
((Comment)comment).setCreationDate(TimeStamptoday); is working fine without any warnings.
Please check the Plugin Development --> Target Platforms once again.

Regards
Muthukumar 


Permanent link
I have another query relating to approvals:

Is it possible to make the approval presentation read-only? - as i want to update it only through Java API. Users should not be able to update it.

Thanks.

0 votes


Permanent link
Hi Muthukumar,
                           I tried a scenario for dependent enumerations involving a muti-select list:
Source: Enumeration
Target: medium string (multi-select list referring an enumeration)

Created a value-set between the 2 enumerations.

How to associate the value-set? Since string type does not have value-set enabled. Please advise

0 votes

Your answer

Register or log in to post your answer.

Dashboards and work items are no longer publicly available, so some links may be invalid. We now provide similar information through other means. Learn more here.

Search context
Follow this question

By Email: 

Once you sign in you will be able to subscribe for any updates here.

By RSS:

Answers
Answers and Comments
Question details

Question asked: Jul 10 '12, 7:07 a.m.

Question was seen: 8,608 times

Last updated: Aug 20 '13, 12:57 a.m.

Related questions
Confirmation Cancel Confirm