Skip to main content
6-Contributor
March 24, 2025
Question

Business Rule or Customization to check that a drawing is more recent than the model.

  • March 24, 2025
  • 4 replies
  • 981 views

Version: Windchill 12.1

 

Use Case: Windchill Publishing is currently set to publish drawings using the As-Stored configuration. This ensures that a REV A drawing is never re-published using a REV B model, for example. But sometimes users check-in a model after the last time they check-in the drawing. Then the drawing publishes "incorrectly". Uses don't notice this because their workspace always has "latest" versions of the model and drawing.


Description:

Has anyone developed a customization or business rule to check that during a promotion request / change notice, that the drawing is more recent than the associated drawing models of that drawing.  I would be open to other suggestions on how to prevent publishing the wrong drawing other than changing the publishing configuration to "Latest".  If there was an option to check for "Latest Iteration" of the model, that might work, but I do not want a solution that creates the potential for a Revision mismatch.

 

Years ago, I seem to remember a warning when the "model is more recent than the drawing" but I think it was just in Pro/Engineer (yeah, that long ago.)

4 replies

18-Opal
March 24, 2025

@MM_10260548 

Would an acceptable solution be to set the config to “Latest” but only publish if the drawing’s rev and the drawing’s model’s rev match?

 

If yes, this is doable.

 

 

6-Contributor
March 25, 2025

The goal is to get the "correct" version of the drawing to publish...  I don't want to not publish.

The simplest solution is to make sure that the drawing is always checked in after any changes to the model.  So, I think that is what needs to be enforced before the objects are Promoted / ECN is approved.  The "As-Stored" version of a drawing should be a good piece of information for other use cases besides publishing.  So, with that assumption, I believe I am looking for a rule check during a workflow, not at publishing.

18-Opal
March 25, 2025

Ok, so the solution is to ensure drawings on promotion request or ECN resulting object are ALWAYS later than their drawing models prior to workflow promote/approve task.

Why not simple write Java code to validate this condition and run the code in the workflow before the promote/approve task?

If the validation doesn’t pass mustard workflow sends task to user explaining the problem and the solution.

 

I’d also run the same code in the promote/approve task’s transition or at least right after the task just in to make sure everything is still valid at the moment of approval.

20-Turquoise
March 25, 2025

Felcos' Object Validator will probably do this checking along with a myriad of other checks:

https://www.felcosolutions.com/objectvalidator

Community Manager
April 27, 2025

Hi @MM_10260548,

 

I wanted to see if you got the help you needed.

If so, please mark the appropriate reply as the Accepted Solution. It will help other members who may have the same question.
Of course, if you have more to share on your issue, please pursue the conversation. 

 

Thanks,
Anurag 

15-Moonstone
October 9, 2025

I had the exact same problem, I made some workflow code to check the drawing and the referenced models, you will need a workflow variable "errorMsg" which you also put in the error activity to display the error message to the assignee, hopefully its some use to you:

wt.maturity.PromotionNotice pn = (wt.maturity.PromotionNotice) primaryBusinessObject;

// Refresh promotion targets
com.ptc.windchill.enterprise.maturity.PromotionNoticeWorkflowHelper.refresh(pn);

// Get the promotion targets 
wt.fc.QueryResult qr = wt.maturity.MaturityHelper.service.getPromotionTargets(pn, false);

boolean allOK = true;
StringBuilder errorMessages = new StringBuilder();


while (qr.hasMoreElements()) {
 wt.maturity.PromotionTarget pt = (wt.maturity.PromotionTarget) qr.nextElement();
 String oid = pt.getPromotable().toString();
 ObjectIdentifier oid1 = ObjectIdentifier.newObjectIdentifier(oid);
 wt.fc.WTObject obj = (wt.fc.WTObject) wt.fc.PersistenceHelper.manager.refresh(oid1);

 // Only check drawings
 if (obj.getDisplayType().getLocalizedMessage(java.util.Locale.ENGLISH).contains("Drawing")) {
 wt.epm.EPMDocument epm = (wt.epm.EPMDocument) obj;

 int DRAWING_MODEL_DEP_TYPE = 4;
 wt.epm.workspaces.EPMAsStoredConfigSpec as_stored_config = wt.epm.workspaces.EPMAsStoredConfigSpec.newEPMAsStoredConfigSpec(epm);

 wt.query.QuerySpec ref_filter_qs = new wt.query.QuerySpec();
 Class qc = wt.epm.structure.EPMReferenceLink.class;
 int idx = ref_filter_qs.addClassList(qc, true);
 ref_filter_qs.appendWhere(new wt.query.SearchCondition(qc, wt.epm.structure.EPMReferenceLink.REQUIRED, wt.query.SearchCondition.IS_TRUE), new int[]{idx});
 ref_filter_qs.appendAnd();
 ref_filter_qs.appendWhere(new wt.query.SearchCondition(qc, wt.epm.structure.EPMReferenceLink.DEP_TYPE, wt.query.SearchCondition.EQUAL, DRAWING_MODEL_DEP_TYPE), new int[]{idx});

 wt.fc.QueryResult qr2 = wt.epm.structure.EPMStructureHelper.service.navigateReferencesToIteration(epm, ref_filter_qs, true, as_stored_config);

 while (qr2.hasMoreElements()) {
 wt.epm.EPMDocument ref = (wt.epm.EPMDocument) qr2.nextElement();
 String refS = ref.toString();

 // Get latest iteration of referenced model
 wt.epm.EPMDocConfigSpec epmConfigSpec = wt.epm.EPMDocConfigSpec.newEPMDocConfigSpec();
 epmConfigSpec.setLatestActive();
 epmConfigSpec.setWorkingIncluded(false);
 wt.fc.QueryResult resultLatestEPM = wt.vc.config.ConfigHelper.service.filteredIterationsOf(ref.getMaster(), epmConfigSpec);

 if (resultLatestEPM.hasMoreElements()) {
 wt.epm.EPMDocument latestRef = (wt.epm.EPMDocument) resultLatestEPM.nextElement();
 String latestRefS = latestRef.toString();

 // Check if the referenced model is not the latest
 if (!refS.equals(latestRefS)) {
					allOK = false;
					errorMessages.append("<p>").append(epm.getCADName()).append("</p>");
 }
 }
 }
 }
}


// Set result based on findings
if (allOK) {
 result = "Approve";
} else {
 result = "Rework";
	errorMsg = errorMessages.toString();
}