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

We are happy to announce the new Windchill Customization board! Learn more.

Getting Affected Objects on a Variance

MikeIbosh
1-Newbie

Getting Affected Objects on a Variance

Hi all,

I’m working on a Windchill 10.1 M030 system. I'm working with the Variance (wt.change2.WTVariance) object (waivers and deviations) and trying to get the objects that are on the Affected Objects table. Does anyone have the transition code that will return a query result with these objects? Any help is much appreciated.

Mike

1 ACCEPTED SOLUTION

Accepted Solutions

OK, With a little help from David Graham with the queryresult, I have the answer to my question. Also, I'm setting the Resolution Date of the Variance workflow process (I thought I saw someone asking about this but can't find the post). The code is listed below.

/* Workflow code to change the state of the objects in the Affected Objects table of the Variation. */
wt.pom.Transaction trx = new wt.pom.Transaction();
trx.start();
wt.fc.QueryResult affected = wt.change2.ChangeHelper2.service.getChangeables((wt.change2.ChangeIssue) primaryBusinessObject);
while(affected.hasMoreElements()) {
wt.fc.WTObject obj = (wt.fc.WTObject)affected.nextElement();
java.lang.String type = wt.type.TypedUtilityServiceHelper.service.getExternalTypeIdentifier(obj);
if (type.equals("WCTYPE|wt.doc.WTDocument|com.YourDomain.WTDocumentSoftType")) {
wt.fc.Persistable persistable = (wt.fc.Persistable) obj;
if(persistable instanceof wt.lifecycle.LifeCycleManaged) {
wt.lifecycle.LifeCycleManaged lcManaged = (wt.lifecycle.LifeCycleManaged) persistable;
wt.lifecycle.LifeCycleHelper.service.setLifeCycleState(lcManaged, wt.lifecycle.State.toState("PRODUCTION"));
}
}
}
trx.commit();

/* Workflow code to set the Resolution Date of the Variance workflow process */
com.ptc.windchill.pdmlink.change.server.impl.WorkflowProcessHelper.setPRResolutionDate((wt.change2.ChangeIssue) primaryBusinessObject);

View solution in original post

1 REPLY 1

OK, With a little help from David Graham with the queryresult, I have the answer to my question. Also, I'm setting the Resolution Date of the Variance workflow process (I thought I saw someone asking about this but can't find the post). The code is listed below.

/* Workflow code to change the state of the objects in the Affected Objects table of the Variation. */
wt.pom.Transaction trx = new wt.pom.Transaction();
trx.start();
wt.fc.QueryResult affected = wt.change2.ChangeHelper2.service.getChangeables((wt.change2.ChangeIssue) primaryBusinessObject);
while(affected.hasMoreElements()) {
wt.fc.WTObject obj = (wt.fc.WTObject)affected.nextElement();
java.lang.String type = wt.type.TypedUtilityServiceHelper.service.getExternalTypeIdentifier(obj);
if (type.equals("WCTYPE|wt.doc.WTDocument|com.YourDomain.WTDocumentSoftType")) {
wt.fc.Persistable persistable = (wt.fc.Persistable) obj;
if(persistable instanceof wt.lifecycle.LifeCycleManaged) {
wt.lifecycle.LifeCycleManaged lcManaged = (wt.lifecycle.LifeCycleManaged) persistable;
wt.lifecycle.LifeCycleHelper.service.setLifeCycleState(lcManaged, wt.lifecycle.State.toState("PRODUCTION"));
}
}
}
trx.commit();

/* Workflow code to set the Resolution Date of the Variance workflow process */
com.ptc.windchill.pdmlink.change.server.impl.WorkflowProcessHelper.setPRResolutionDate((wt.change2.ChangeIssue) primaryBusinessObject);

Top Tags