<?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: API to get display name for attributes? in Windchill Customization</title>
    <link>https://community.ptc.com/t5/Windchill-Customization/API-to-get-display-name-for-attributes/m-p/803622#M3293</link>
    <description>&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="WM_9965332_0-1656012572168.png" style="width: 400px;"&gt;&lt;img src="https://community.ptc.com/t5/image/serverpage/image-id/59227i26EFFB6F53E12353/image-size/medium?v=v2&amp;amp;px=400" role="button" title="WM_9965332_0-1656012572168.png" alt="WM_9965332_0-1656012572168.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Is it possible to get the display value for specific attributes instead of this? I am using PersistableAdapter&lt;/P&gt;</description>
    <pubDate>Thu, 23 Jun 2022 19:30:37 GMT</pubDate>
    <dc:creator>WM_9965332</dc:creator>
    <dc:date>2022-06-23T19:30:37Z</dc:date>
    <item>
      <title>API to get display name for attributes?</title>
      <link>https://community.ptc.com/t5/Windchill-Customization/API-to-get-display-name-for-attributes/m-p/796719#M3290</link>
      <description>&lt;P&gt;I am trying to retrieve display name for an attribute in WTPart or WTDocument. I can retrieve attribute values using the internal name of the attribute but would like to also get the display name using same process. Is there an API for this?&lt;/P&gt;</description>
      <pubDate>Fri, 15 Mar 2024 13:16:17 GMT</pubDate>
      <guid>https://community.ptc.com/t5/Windchill-Customization/API-to-get-display-name-for-attributes/m-p/796719#M3290</guid>
      <dc:creator>WM_9965332</dc:creator>
      <dc:date>2024-03-15T13:16:17Z</dc:date>
    </item>
    <item>
      <title>Re: API to get display name for attributes?</title>
      <link>https://community.ptc.com/t5/Windchill-Customization/API-to-get-display-name-for-attributes/m-p/796733#M3291</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I get a display name with following logic.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I hope this will be helpful to you.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="java"&gt;PersistableAdapter persistableAdapter = new PersistableAdapter(object, null, locale, null);
persistableAdapter.load(ATTRIBUTE_INTERNAL_NAME);
Object attributeValue = persistableAdapter.get(ATTRIBUTE_INTERNAL_NAME);
AttributeTypeSummary attributeTypeSummary = persistableAdapter.getAttributeDescriptor(ATTRIBUTE_INTERNAL_NAME);
String displayName = getDisplayValue(attributeValue, attributeTypeSummary, locale);


private static String getDisplayValue(Object attributeValue, AttributeTypeSummary ats, Locale locale) {
	String result;
	DataSet ds = ats.getLegalValueSet();
	if (attributeValue instanceof Timestamp) {
		// Date
		String dataFormat = ats.getDateDisplayFormat();
		if (dataFormat == null || dataFormat.isEmpty()) {
			dataFormat = DateFormatter.getDefaultDisplayFormat(false, locale);
		}
		result = getDisplayDateValue((Timestamp) attributeValue, dataFormat, locale);
	} else if (attributeValue instanceof Number &amp;amp;&amp;amp; !(attributeValue instanceof FloatingPointWithUnits)) {
		// Number type
		result = attributeValue.toString();
	} else if (attributeValue instanceof String &amp;amp;&amp;amp; ds != null &amp;amp;&amp;amp; ds instanceof EnumeratedSet) {
		// Enum
		EnumerationEntryIdentifier eei = ((EnumeratedSet) ds).getElementByKey(attributeValue.toString());
		LWCEnumerationEntryValuesFactory eevf = new LWCEnumerationEntryValuesFactory();
		LocalizedValues localizedValues = eevf.get(eei, locale);
		result = localizedValues == null ? attributeValue.toString() : localizedValues.getDisplay();
	} else {
		result = DataTypesUtility.toString(attributeValue, locale);
	}
	return result;
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 18 May 2022 01:43:33 GMT</pubDate>
      <guid>https://community.ptc.com/t5/Windchill-Customization/API-to-get-display-name-for-attributes/m-p/796733#M3291</guid>
      <dc:creator>shin1h</dc:creator>
      <dc:date>2022-05-18T01:43:33Z</dc:date>
    </item>
    <item>
      <title>Re: API to get display name for attributes?</title>
      <link>https://community.ptc.com/t5/Windchill-Customization/API-to-get-display-name-for-attributes/m-p/797235#M3292</link>
      <description>&lt;P&gt;Saw this post and thought, now there's a new request.&lt;/P&gt;
&lt;P&gt;An easy way to do this that is completely independent of the attribute's datatype (String, Long, etc) is to use an sql query run from your Java class.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;From Type and Attribute Manager we see Company Name.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="d_graham_1-1652977361132.png" style="width: 400px;"&gt;&lt;img src="https://community.ptc.com/t5/image/serverpage/image-id/57620i53DC68C56E234210/image-size/medium?v=v2&amp;amp;px=400" role="button" title="d_graham_1-1652977361132.png" alt="d_graham_1-1652977361132.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If I pass my utility an attribute holder, such as a WTDocument, and the attribute's internal name the attribute's display name is returned.&amp;nbsp; Seems to work.&lt;/P&gt;
&lt;P&gt;BTW, You need to navigate six tables in total from WTDocument or WTPart (or whatever class) to finally get the display value.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="d_graham_0-1652977141842.png" style="width: 400px;"&gt;&lt;img src="https://community.ptc.com/t5/image/serverpage/image-id/57619iE2283C4EF897CE0A/image-size/medium?v=v2&amp;amp;px=400" role="button" title="d_graham_0-1652977141842.png" alt="d_graham_0-1652977141842.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;David&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 19 May 2022 16:34:20 GMT</pubDate>
      <guid>https://community.ptc.com/t5/Windchill-Customization/API-to-get-display-name-for-attributes/m-p/797235#M3292</guid>
      <dc:creator>d_graham</dc:creator>
      <dc:date>2022-05-19T16:34:20Z</dc:date>
    </item>
    <item>
      <title>Re: API to get display name for attributes?</title>
      <link>https://community.ptc.com/t5/Windchill-Customization/API-to-get-display-name-for-attributes/m-p/803622#M3293</link>
      <description>&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="WM_9965332_0-1656012572168.png" style="width: 400px;"&gt;&lt;img src="https://community.ptc.com/t5/image/serverpage/image-id/59227i26EFFB6F53E12353/image-size/medium?v=v2&amp;amp;px=400" role="button" title="WM_9965332_0-1656012572168.png" alt="WM_9965332_0-1656012572168.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Is it possible to get the display value for specific attributes instead of this? I am using PersistableAdapter&lt;/P&gt;</description>
      <pubDate>Thu, 23 Jun 2022 19:30:37 GMT</pubDate>
      <guid>https://community.ptc.com/t5/Windchill-Customization/API-to-get-display-name-for-attributes/m-p/803622#M3293</guid>
      <dc:creator>WM_9965332</dc:creator>
      <dc:date>2022-06-23T19:30:37Z</dc:date>
    </item>
  </channel>
</rss>

