It's all about the answers!

Ask a question

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


Muthukumar C (32712833) | asked Jul 10 '12, 7:07 a.m.
retagged Jul 25 '12, 9:04 p.m. by Millard Ellingsworth (2.5k12431)
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


Accepted answer


permanent link
VK L (8177155159) | answered Jul 11 '12, 3:27 a.m.
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

6 other answers



permanent link
VK L (8177155159) | answered Oct 12 '12, 2:12 a.m.
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

permanent link
VK L (8177155159) | answered Jul 11 '12, 5:34 a.m.
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.

permanent link
Muthukumar C (32712833) | answered Jul 11 '12, 3:31 a.m.
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

Comments
Carlos Maciel commented Aug 19 '13, 1:23 p.m.

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


Muthukumar C commented Aug 20 '13, 12:57 a.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
VK L (8177155159) | answered Jul 11 '12, 3:13 a.m.
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?

permanent link
Muthukumar C (32712833) | answered Jul 11 '12, 2:56 a.m.
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

Comments
Muthukumar C commented Jul 11 '12, 2:58 a.m. | edited Jul 11 '12, 2:58 a.m.

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


permanent link
VK L (8177155159) | answered Jul 11 '12, 2:45 a.m.
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.

Your answer


Register or 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.