cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Can anybody help to resolve to remove link between change notice and change task?

SOLVED
Highlighted
Granite

Can anybody help to resolve to remove link between change notice and change task?

This exception coming on wc11.1 only.

 

A persistence error occurred. System message follows:
Nested exception is: wt.associationRules.AssociationValidationException: Removing an association between "Change Notice - 00001" and "Change Task - 00001" violates the required role constraint of "Association Rule - PTC000007". The association is required for "Change Notice - 00001".

 

Please check sample code as below : 

// Get change Task here..
QueryResult changeActivityList = ChangeHelper2.service.getChangeActivities(changenotice);
while (changeActivityList.hasMoreElements()) {

//get ChangeTask obj
ChangeActivity2 changeActivity = (ChangeActivity2) changeActivityList.nextElement();

//get Affected obj
QueryResult qr2 = PersistenceHelper.manager.navigate(changeActivity,AffectedActivityData.ALL_ROLES, AffectedActivityData.class, false);
while (qr2.hasMoreElements()) {
AffectedActivityData affecteddata = (AffectedActivityData) qr2.nextElement();
ChangeHelper2.service.deleteAffectedActivityData(affecteddata);
System.out.println("deleted Affected Activity from Change task..!");
}

// get Resulting Obj.
QueryResult qr3 = PersistenceHelper.manager.navigate(changeActivity,ChangeRecord2.ALL_ROLES, ChangeRecord2.class, false);
while (qr3.hasMoreElements()) {
ChangeRecord2 changerecord = (ChangeRecord2) qr3.nextElement();
ChangeHelper2.service.deleteChangeRecord(changerecord);
System.out.println("deleted Resulting Data from Change task..!");
}
System.out.println("Change task name : "+changeActivity.getName());
System.out.println("Deleted change task started..!");
// delete change task.
ChangeHelper2.service.deleteChangeActivity(changeActivity);
System.out.println("Deleted change task success..!");
}

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted

Re: Can anybody help to resolve to remove link between change notice and change task?

HI Windchiller,

 

Please use this API :

 

hlafkir_1-1600859852923.png

 

http://support.ptc.com/cs/wncdoc/110/wcapi/wt/change2/ChangeService2.html#deleteIncludeIn2AndChangeT...

 

here an example :

 

ObjectIdentifier oid= ObjectIdentifier.newObjectIdentifier("wt.change2.WTChangeActivity2:396443");
wt.change2.WTChangeActivity2 ct = (wt.change2.WTChangeActivity2) PersistenceHelper.manager.refresh(oid);


IncludedIn2 changeLnk = null;

WTSet myCT= new WTHashSet();
myCT.add(ct);
WTCollection list = new WTArrayList(PersistenceHelper.navigate(ct, IncludedIn2.ROLE_AOBJECT_ROLE, IncludedIn2.class, false));
for (Object o : list) {
changeLnk = (IncludedIn2) ((ObjectReference) o).getObject();
System.out.println(changeLnk.getChangeOrder2());
}
ChangeHelper2.service.deleteIncludeIn2AndChangeTask(myCT, changeLnk.getChangeOrder2(),false);

 

 

 

Good luck

View solution in original post

2 REPLIES 2
Highlighted

Re: Can anybody help to resolve to remove link between change notice and change task?

HI Windchiller,

 

Please use this API :

 

hlafkir_1-1600859852923.png

 

http://support.ptc.com/cs/wncdoc/110/wcapi/wt/change2/ChangeService2.html#deleteIncludeIn2AndChangeT...

 

here an example :

 

ObjectIdentifier oid= ObjectIdentifier.newObjectIdentifier("wt.change2.WTChangeActivity2:396443");
wt.change2.WTChangeActivity2 ct = (wt.change2.WTChangeActivity2) PersistenceHelper.manager.refresh(oid);


IncludedIn2 changeLnk = null;

WTSet myCT= new WTHashSet();
myCT.add(ct);
WTCollection list = new WTArrayList(PersistenceHelper.navigate(ct, IncludedIn2.ROLE_AOBJECT_ROLE, IncludedIn2.class, false));
for (Object o : list) {
changeLnk = (IncludedIn2) ((ObjectReference) o).getObject();
System.out.println(changeLnk.getChangeOrder2());
}
ChangeHelper2.service.deleteIncludeIn2AndChangeTask(myCT, changeLnk.getChangeOrder2(),false);

 

 

 

Good luck

View solution in original post

Highlighted

Re: Can anybody help to resolve to remove link between change notice and change task?

@hlafkir Thank you.

Announcements