Community Tip - Have a PTC product question you need answered fast? Chances are someone has asked it before. Learn about the community search. X
Hello,
I have an attribute called 'sapnumber' that I use in both wtpart and cadpart.
When a user creates a part and publishes it, they initiate an ECN and start the process of publication. I would like to update my sapnumber within the ECN process using an expression.
The expression will be: sapnumber = (part number + -AA). However, I am constantly receiving an error with this expression.
The expression I got the error from is attached.
Can you help me?
what error ypu get ?
hello fadel,
I can't actually get to an error. expression skips without executing its function.
hi , you may enable below loggers , to see what the WF is doing :
log4j.logger.wt.workflow.definer=DEBUG
log4j.logger.WF_EXEC_EXPR=DEBUG
log4j.logger.wt.workflow=DEBUG
log4j.logger.wt.workflow.engine=DEBUG
Actually, my goal is to write the WTPart number updated while in ECN to an attribute along with the version number.
or in short, being able to update any attribute of wtpart while in ecn.
Do you have sample code that can achieve this?
Hi,
Just thinking out aloud... Can you try updating that attribute manually?
In ECNs, the resulting objects are editable by normal user and hence if you can update it manually, then surely the issue is in the WF itself.
Cheers
Hari
Hi,
the data here is critical information and should not be left to the user's discretion.
That's why we're actually trying to make it automatic.
Thanks.
Hi,
I meant for trouble shooting sake, can you try updating it manually? So that we are clear that we are working on something that is actually feasible by code.
There is some thing wrong with the WF. Enable the logs as mentioned by Fadel.
Cheers
Hari
Hi, @Hari_Vara @Fadel
I prepared the code and it works.
I take the first digit of the version number with the epm number and write it to an attribute.
(Description lines are in Turkish.)
wt.change2.WTChangeActivity2 changeActivity = (wt.change2.WTChangeActivity2) primaryBusinessObject;
wt.fc.QueryResult qr = wt.change2.ChangeHelper2.service.getChangeablesAfter(changeActivity);
if (qr != null) {
while (qr.hasMoreElements()) {
java.lang.Object obj = qr.nextElement();
if (obj instanceof wt.epm.EPMDocument) {
wt.epm.EPMDocument epmDocument = (wt.epm.EPMDocument) obj;
// CAD numarasını al
String cadNumber = epmDocument.getNumber();
System.out.println("CAD Number: " + cadNumber);
// Versiyon kimliğini al
String version = wt.vc.VersionControlHelper.getVersionIdentifier(epmDocument).getValue();
System.out.println("Version Identifier: " + version);
// Versiyonun ana kısmını (örneğin, 'A', 'B' gibi) al
String majorVersion = version.substring(0, 1);
System.out.println("Major Version: " + majorVersion);
// Yeni sapnumber oluştur
String newSapnumber = cadNumber + "-" + majorVersion;
System.out.println("New SAP Number: " + newSapnumber);
// EPMDocument'i checkout yap
epmDocument = (wt.epm.EPMDocument) wt.vc.wip.WorkInProgressHelper.service.checkout(epmDocument, wt.vc.wip.WorkInProgressHelper.service.getCheckoutFolder(), "").getWorkingCopy();
System.out.println("EPM Document checked out.");
// sapnumber attribute'unu güncelle
com.ptc.core.lwc.server.PersistableAdapter adapter = new com.ptc.core.lwc.server.PersistableAdapter(epmDocument, null, java.util.Locale.US, new com.ptc.core.meta.common.UpdateOperationIdentifier());
adapter.load("sapnumber");
adapter.set("sapnumber", newSapnumber);
adapter.apply();
System.out.println("SAP Number updated.");
// Değişiklikleri kaydet ve check-in yap
wt.fc.PersistenceHelper.manager.modify(epmDocument);
wt.vc.wip.WorkInProgressHelper.service.checkin((wt.vc.wip.Workable) epmDocument, "sapnumber updated with CAD number and major version in workflow");
System.out.println("EPM Document checked in successfully.");
}
}
}