Exception thrown when trying to create WTPartUsage using Info*Engine API
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Exception thrown when trying to create WTPartUsage using Info*Engine API
Version: Windchill 12.1
Use Case: Using a DAO class that extends com.infoengine.connector.DataAccessObject to link 2 parts: public com.ptc.windchill.ws.GenericBusinessObject [] Link ( java.lang.String parentUfid, com.ptc.windchill.ws.GenericBusinessObject [] associations, java.lang.String [] propertyNames ) throws Exception { String [] ie$dao$names = { "parentUfid", "associations", "propertyNames", }; Object [] ie$dao$vals = { parentUfid, associations, propertyNames, }; Object ie$dao$ret = execute ( "Link", ie$dao$names, ie$dao$vals ); return (com.ptc.windchill.ws.GenericBusinessObject [])ie$dao$ret; }
Description:
Exception thrown when trying to create WTPartUsage between 2 parts. Same call works in other WC installations (11, 12, 13, etc...) but failed in 12.1.2. The settings are the same for all the WC servers tested.
2025-01-27 19:15:35,902 ERROR [ajp-nio-127.0.0.1-8010-exec-3] wt.adapter.exception aphung - WTAdapterImpl com.ptc.core.command.common.CommandException: EXCEPTION DURING SAVE[ SOURCE: @@@ BEGIN TYPE INSTANCE @@@ Identifier: WCTYPE|wt.part.WTPartUsageLink~~NEW|-8287685863323502768 @@@ BEGIN ATTRIBUTE CONTAINER @@@ @@@ ID: WCTYPE|wt.part.WTPartUsageLink~~NEW|-8287685863323502768 @@@ : ~MBA|usedBy^WCTYPE|wt.part.WTPart~~WCP|168971|-1 @@@ Content: WCTYPE|wt.part.WTPart~~WCP|168971|-1 @@@ State: NEW @@@ @@@ ID: WCTYPE|wt.part.WTPartUsageLink~~NEW|-8287685863323502768 @@@ : ~MBA|uses^WCTYPE|wt.part.WTPartMaster~~WCP|168948|-1 @@@ Content: WCTYPE|wt.part.WTPartMaster~~WCP|168948|-1 @@@ State: NEW @@@ @@@ ATTRIBUTE IDENTIFIER COUNT = 2
....
@@@ REPLACEMENTS : NONE @@@ @@@ END ATTRIBUTE CONTAINER @@@ END TYPE INSTANCE ]EXCEPTION DURING SAVE Nested exception is: com.ptc.core.command.common.CommandException: (wt.part.partResource/QUANTITY_UNIT_EMPTY_VALUE_MSG) com.ptc.core.command.common.CommandException: The unit cannot be empty Nested exception is: (wt.part.partResource/QUANTITY_UNIT_EMPTY_VALUE_MSG) com.ptc.core.command.common.CommandException: The unit cannot be empty at wt.part.PartUsesLinkValidationeHelper.validateQuantityUnitForEach(PartUsesLinkValidationeHelper.java:86) at com.ptc.core.foundation.occurrence.server.impl.SavePartUsesSubCommandDelegate.validateUsageLink(SavePartUsesSubCommandDelegate.java:646) at com.ptc.core.foundation.occurrence.server.impl.SavePartUsesSubCommandDelegate.updatePartUsageLink(SavePartUsesSubCommandDelegate.java:713) at com.ptc.core.foundation.occurrence.server.impl.SavePartUsesSubCommandDelegate.doExecution(SavePartUsesSubCommandDelegate.java:418)
...
- Labels:
-
Info*Engine
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Article - "Getting the error "The unit cannot be empty" when adding a part to a structure in Windchill PDMLink": https://www.ptc.com/en/support/article/CS379043
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
This same request works in Windchill 10, 11, 12, 13. It just does not work in Windchill 12.1.2. I have checked the settings and they are the same in all the WC servers. It appears that in 12.1.2, there is this validation check that does not allow this operation.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
The error clearly state the quantity unit cannot be empty.
Are you specifying the quantity and the units?
If no, it look like doing so would fix this particular error.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
I understand. If I change my code to provide quantity and unit, it does work. If this is how it should work, then will future versions behave the same way? Again, this same code works in WC 10, 11, 12, AND 13. Will there be a patch to fix this in WC 13 and any future versions of WC?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Also, is the setting applicable to this operation or any Info*Engine requests?
Currently, quantity.unit/amount is set to have a default value. The settings is specific to the value, type, etc... When a part usage is created from the web client, no unit/amount is specified, and the usage is correctly created with the default value as specified in the setting. I assume this behavior would be the same for all Info*Engine request.
So are the setting ignored for all Info*Engine requests? or just this particular one? and will changes be applied to all future versions of WC?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
I would definitely not assume that behavoir seen from picking action would be identical to executing a Create-Links webject in an IE task.
webjects simply run the Windchill APIs and webjects were make it "easier" from customer that don't know Java APIs to create customization that use the Java APIs.
And webjects in theory always work when we upgrading Windchill as presumably PTC has tested each webject.
I think it's fair to say any validation done by running a webject is the same as that done by running the corresponding Java API. I don't see how this could not be the case as the webject runs the API.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
I don't understand webjects. I am making a SOAP call using Windchill Info*Engine provided class -- in this case executing a "Link" giving the id of 2 parts. This call works for various versions of Windchill (10, 11, 12, 13), but it does not work for 12.1.2.
If I make the change here to include the required quantity.unit/amount, then what other calls do I need to change? It appears that the setting is completely ignored in this particular version of Windchill.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Post what code you have to date. All of it.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
This is the method being called. It is code generated following the "Generating DAOs" section of https://support.ptc.com/help/wnc/r11.2.1.0/en/index.html#page/Windchill_Help_Center%2FIEUG_SOAPStdaloneJavaClients.html%23
(the class extends com.infoengine.connector.DataAccessObject)
/**
* Creates an association between one object called the parent object and each of
* one or more other objects called child objects. The parent object is identified
* by UFID. Generic business objects specify characteristics of each association.
* The typeIdentifier of each one specifies the type of the association (i.e., the
* link class), the UFID specifies the associated child object, and the properties
* specify the attributes of the association (if any). The new link objects are
* returned.
*
* @param parentUfid
* @param associations
* @param propertyNames
*
* @return com.ptc.windchill.ws.GenericBusinessObject []
**/
public com.ptc.windchill.ws.GenericBusinessObject [] Link ( java.lang.String parentUfid, com.ptc.windchill.ws.GenericBusinessObject [] associations, java.lang.String [] propertyNames ) throws Exception {
String [] ie$dao$names = {
"parentUfid",
"associations",
"propertyNames",
};
Object [] ie$dao$vals = {
parentUfid,
associations,
propertyNames,
};
Object ie$dao$ret = execute ( "Link", ie$dao$names, ie$dao$vals );
return (com.ptc.windchill.ws.GenericBusinessObject [])ie$dao$ret;
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Below is the code that calls the generated DAO. quantity.unit/amount is required for WC 12.1.2 (not required in 10, 11, 12.1, 13.1)
private String createWTPartUsageLink (String parentUfid,GenericBusinessObject childMasterRefs){
logger.debug("Entering createWTPartUsageLink() with Empty attribute...");
GenericBusinessObject gb = new GenericBusinessObject();
String tempLinkType = "wt.part.WTPartUsageLink";
String tempMasterRef = childMasterRefs.getPropertyValue("masterReference");
gb.setTypeIdentifier(tempLinkType);
gb.addProperty("obid", getObidFromUfid(tempMasterRef));
// "The value for attribute Unit must be one of the following: ea, as_needed, kg, m, l, sq_m, cu_m."
// default unit AND amount required (only in WC12.1.2)
gb.addProperty("quantity.unit", "ea");
gb.addProperty("quantity.amount", "1");
GenericBusinessObject[] gbs = {gb};
GenericBusinessObject[] rtngbs = new GenericBusinessObject[gbs.length];
try {
String[] rtnPrty = null; // {"quantity.unit", "quantity.amount", "referenceDesignatorRange", "uses", "usesOccurrence"};
rtngbs = this.daows.Link(parentUfid, gbs, rtnPrty);
} catch (Exception ex) {
logger.error("Exception: " + ex, ex);
}
return rtngbs[0].getUfid();
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Again this is only an issue with Windchill 12.1.2. Works for 10, 11, 12.1, 13.1. I tried to create an issue, but it leads me to this community. Is there a way to have someone from PTC/Windchill look at this?
