<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Windchill 11 Set Part Classification Attributes Programatically in Windchill Customization</title>
    <link>https://www.ptcusercommunity.com/t5/Windchill-Customization/Windchill-11-Set-Part-Classification-Attributes-Programatically/m-p/681878#M4146</link>
    <description>&lt;PRE&gt;adapter.set((String)entry.getKey(), entry.getValue());&lt;/PRE&gt;
&lt;P&gt;What is the value you are setting here? Is it the display value of the classification node ?&lt;/P&gt;
&lt;P&gt;You should pass the 'internal name' of the classification node that you are trying to set.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;That should work.&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 11 Aug 2020 10:30:39 GMT</pubDate>
    <dc:creator>wcpeetc</dc:creator>
    <dc:date>2020-08-11T10:30:39Z</dc:date>
    <item>
      <title>Windchill 11 Set Part Classification Attributes Programatically</title>
      <link>https://www.ptcusercommunity.com/t5/Windchill-Customization/Windchill-11-Set-Part-Classification-Attributes-Programatically/m-p/620768#M4145</link>
      <description>&lt;P&gt;Hi Everyone,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; I am trying to set Classification attributes on a WTPart for windchill 11 M30 CPS 14.&amp;nbsp; I already have the binding attribute set, I am just having trouble setting the attributes.&amp;nbsp; I was able to get this to work using the PersistableAdapter and using the AttributeTypeIdentifier's toLogicalForm()) on my local install of Windchill 11 CPS15.&amp;nbsp; However this doesn't work on the Client's CPS 14 Windchill because toLogicalForm returns null.&amp;nbsp; I am not sure if this is a bug in CPS14 or if I am going about saving the attributes incorrectly.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;/**&lt;BR /&gt;* &lt;BR /&gt;* @param workable - The Object being updated&lt;BR /&gt;* @param bindingAttributeName - This is the name of the IBA for the classification binding &lt;BR /&gt;* @param classificationNode - this is the name of the Classification Node to set into bindingAttributeName&lt;BR /&gt;* @param attributeValueMap - &amp;lt;String,String&amp;gt; = &amp;lt;attribute name, value&amp;gt; - classification attributes and values.&lt;BR /&gt;* @param leaveCheckedOut - use this if continue to edit the workabale&lt;BR /&gt;* @return&lt;BR /&gt;* @throws WTException&lt;BR /&gt;* @throws WTPropertyVetoException&lt;BR /&gt;*/&lt;BR /&gt;public static Persistable setClassificationAttributes(Workable workable, String bindingAttributeName, String classificationNode, Map&amp;lt;String, String&amp;gt; attributeValueMap,boolean leaveCheckedOut) throws WTException, WTPropertyVetoException{
	// TODO Need logic in case it is checked out to another user	
	boolean isOrgianllyCheckedout = WorkInProgressHelper.isCheckedOut(workable, SessionHelper.getPrincipal());
	// check out the object
	if(!isOrgianllyCheckedout) {
		workable = WorkInProgressHelper.service.checkout(workable, WorkInProgressHelper.service.getCheckoutFolder(), null).getWorkingCopy();
	} else {
		if( !WorkInProgressState.WORKING.equals(workable.getCheckoutInfo().getState())) {
			workable = WorkInProgressHelper.service.workingCopyOf(workable);
		}
	}
	PersistableAdapter adapter = new PersistableAdapter(workable,null,SessionHelper.getLocale(), new UpdateOperationIdentifier());
		 
	if (!StringUtils.isEmpty(classificationNode)) {
		adapter.load(bindingAttributeName);
		adapter.set(bindingAttributeName,classificationNode);
		adapter.apply();
	} 
	if (attributeValueMap != null &amp;amp;&amp;amp; !attributeValueMap.isEmpty()) {
		Iterator it = attributeValueMap.entrySet().iterator();
			
		while (it.hasNext()) {
			Entry entry = (Entry) it.next();&lt;BR /&gt;                        // Also check for string "undefined"
			if(entry.getValue() != null &amp;amp;&amp;amp; !UNDEFINED.equalsIgnoreCase((String)entry.getValue())){
					
				adapter.load((String)entry.getKey());
				adapter.set((String)entry.getKey(), entry.getValue());  &lt;FONT color="#FF0000"&gt;&lt;STRONG&gt;// ERROR HAPPENS HERE, see note below code section.&lt;/STRONG&gt;&lt;/FONT&gt;
				adapter.apply();
			}
		}
			
	}
	PersistenceHelper.manager.modify(workable);
	if(!leaveCheckedOut) {	
		workable = WorkInProgressHelper.service.checkin(workable, null);
	}
	return workable;
}&lt;/PRE&gt;
&lt;P&gt;However the error happens on the adapter.set() because the key is null(obviously this is bad) on the client's Windchill CPS14 .&amp;nbsp; The key is null because the data is coming from atSummary.getAttributeTypeIdentifier().toLogicalForm()) which returns null when looping through AttributeTypeSummaryHelper.SERVICE.getATS() from the classificationFacadeInstance.getClassificationAttributes().&amp;nbsp;&amp;nbsp; However, This does returns a value on my local Windchill CPS15 (Note: it uses demo classification data).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So basically my questions is whether the PersistanceAdapter is the right api to use to save classification attributes.&amp;nbsp; If this is the right API, is the logicalform the right value to pass to the load method?&amp;nbsp; I tried internalName which is ideal,&amp;nbsp; but that is not found in the load() method on either system.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 15 Mar 2024 13:21:15 GMT</pubDate>
      <guid>https://www.ptcusercommunity.com/t5/Windchill-Customization/Windchill-11-Set-Part-Classification-Attributes-Programatically/m-p/620768#M4145</guid>
      <dc:creator>gferda</dc:creator>
      <dc:date>2024-03-15T13:21:15Z</dc:date>
    </item>
    <item>
      <title>Re: Windchill 11 Set Part Classification Attributes Programatically</title>
      <link>https://www.ptcusercommunity.com/t5/Windchill-Customization/Windchill-11-Set-Part-Classification-Attributes-Programatically/m-p/681878#M4146</link>
      <description>&lt;PRE&gt;adapter.set((String)entry.getKey(), entry.getValue());&lt;/PRE&gt;
&lt;P&gt;What is the value you are setting here? Is it the display value of the classification node ?&lt;/P&gt;
&lt;P&gt;You should pass the 'internal name' of the classification node that you are trying to set.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;That should work.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 11 Aug 2020 10:30:39 GMT</pubDate>
      <guid>https://www.ptcusercommunity.com/t5/Windchill-Customization/Windchill-11-Set-Part-Classification-Attributes-Programatically/m-p/681878#M4146</guid>
      <dc:creator>wcpeetc</dc:creator>
      <dc:date>2020-08-11T10:30:39Z</dc:date>
    </item>
    <item>
      <title>Re: Windchill 11 Set Part Classification Attributes Programatically</title>
      <link>https://www.ptcusercommunity.com/t5/Windchill-Customization/Windchill-11-Set-Part-Classification-Attributes-Programatically/m-p/681919#M4147</link>
      <description>&lt;P&gt;Thank you wcpeetc,&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; The issue was that the client had not set the Logical Identifier attribute on the "Manage Reusable Attributes" for the attributes they used for the Classification.&amp;nbsp; Once this was set then everything worked fine.&amp;nbsp; It's been over a year since I looked at this, but I remember the internal name not working and had to use the Logical Identifier (was set the same value as internal name).&amp;nbsp; I don't see it now, but the internalName looked to be returning generated classification IDs which did not work in the PersistanceAdapter.&amp;nbsp; I don't see those values now in the classification administrator so not sure if something changed since then.&lt;/P&gt;</description>
      <pubDate>Tue, 11 Aug 2020 13:19:15 GMT</pubDate>
      <guid>https://www.ptcusercommunity.com/t5/Windchill-Customization/Windchill-11-Set-Part-Classification-Attributes-Programatically/m-p/681919#M4147</guid>
      <dc:creator>gferda</dc:creator>
      <dc:date>2020-08-11T13:19:15Z</dc:date>
    </item>
    <item>
      <title>Re: Windchill 11 Set Part Classification Attributes Programatically</title>
      <link>https://www.ptcusercommunity.com/t5/Windchill-Customization/Windchill-11-Set-Part-Classification-Attributes-Programatically/m-p/968781#M8618</link>
      <description>&lt;P&gt;We were fighting with loading classification attribute values, until reading this update.&lt;BR /&gt;We had loaded attributes without logical identifiers, trying to use the internal name for update.&lt;BR /&gt;After adding logical identifiers the loader started working.&lt;/P&gt;</description>
      <pubDate>Thu, 29 Aug 2024 12:39:00 GMT</pubDate>
      <guid>https://www.ptcusercommunity.com/t5/Windchill-Customization/Windchill-11-Set-Part-Classification-Attributes-Programatically/m-p/968781#M8618</guid>
      <dc:creator>Juha_Kokko</dc:creator>
      <dc:date>2024-08-29T12:39:00Z</dc:date>
    </item>
  </channel>
</rss>

