<?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: extract initial characters from attribute in Windchill Customization</title>
    <link>https://www.ptcusercommunity.com/t5/Windchill-Customization/extract-initial-characters-from-attribute/m-p/495260#M5725</link>
    <description>&lt;P&gt;Hi Roy,&lt;/P&gt;
&lt;P&gt;Not directly, but with yes. In Windchill 10.2 you can do it by using&amp;nbsp;com.ptc.core.lwc.server.PersistableAdapter API.&lt;/P&gt;
&lt;P&gt;First get the IBA value and then use core java substring API to get first desired characters.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Something like below:&lt;/P&gt;
&lt;P&gt;Note: Here I took WTDocument&amp;nbsp;handle, but you can take any object type.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;// Retrieve handle for WTPart
ObjectIdentifier oid = ObjectIdentifier.newObjectIdentifier("wt.doc.WTDocument:228878");
WTDocument doc = (WTDocument)PersistenceHelper.manager.refresh(oid);
System.out.println(" ### Handler Retrieved..!!!");
Locale locale = SessionHelper.getLocale();
PersistableAdapter perAdap = new PersistableAdapter(doc, null,locale,new SearchOperationIdentifier()); 
perAdap.load("COUNTRY");
Object val = perAdap.get("COUNTRY");
if (val != null) {
	System.out.println(" Value is -&amp;gt; " + &lt;FONT color="#FF0000"&gt;val.toString().substring(0, 3)&lt;/FONT&gt;);
}&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Above applies to IBA value. But in your case you're looking for name field. So you can directly query name using getName(); API.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For example:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;ObjectIdentifier oid = ObjectIdentifier.newObjectIdentifier("wt.doc.WTDocument:228878");
WTDocument doc = (WTDocument)PersistenceHelper.manager.refresh(oid);
System.out.println(" Value is -&amp;gt; " + &lt;FONT color="#FF0000"&gt;doc.getName().substring(0, 3)&lt;/FONT&gt;);
&lt;/PRE&gt;
&lt;P&gt;I hope it will help you.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Regards,&lt;/P&gt;
&lt;P&gt;Shirish&lt;/P&gt;</description>
    <pubDate>Wed, 20 Dec 2017 16:39:44 GMT</pubDate>
    <dc:creator>ShirishMorkhade</dc:creator>
    <dc:date>2017-12-20T16:39:44Z</dc:date>
    <item>
      <title>extract initial characters from attribute</title>
      <link>https://www.ptcusercommunity.com/t5/Windchill-Customization/extract-initial-characters-from-attribute/m-p/495256#M5724</link>
      <description>&lt;P&gt;Hi, I am looking to extract the first 4 characters from an attribute to use elsewhere in Windchill. Is this possible?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am attempting to grab the project code from a much longer project name&amp;nbsp; and the first 4 characters&amp;nbsp; are that code.&lt;/P&gt;</description>
      <pubDate>Fri, 15 Mar 2024 14:42:26 GMT</pubDate>
      <guid>https://www.ptcusercommunity.com/t5/Windchill-Customization/extract-initial-characters-from-attribute/m-p/495256#M5724</guid>
      <dc:creator>RoyCrerar</dc:creator>
      <dc:date>2024-03-15T14:42:26Z</dc:date>
    </item>
    <item>
      <title>Re: extract initial characters from attribute</title>
      <link>https://www.ptcusercommunity.com/t5/Windchill-Customization/extract-initial-characters-from-attribute/m-p/495260#M5725</link>
      <description>&lt;P&gt;Hi Roy,&lt;/P&gt;
&lt;P&gt;Not directly, but with yes. In Windchill 10.2 you can do it by using&amp;nbsp;com.ptc.core.lwc.server.PersistableAdapter API.&lt;/P&gt;
&lt;P&gt;First get the IBA value and then use core java substring API to get first desired characters.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Something like below:&lt;/P&gt;
&lt;P&gt;Note: Here I took WTDocument&amp;nbsp;handle, but you can take any object type.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;// Retrieve handle for WTPart
ObjectIdentifier oid = ObjectIdentifier.newObjectIdentifier("wt.doc.WTDocument:228878");
WTDocument doc = (WTDocument)PersistenceHelper.manager.refresh(oid);
System.out.println(" ### Handler Retrieved..!!!");
Locale locale = SessionHelper.getLocale();
PersistableAdapter perAdap = new PersistableAdapter(doc, null,locale,new SearchOperationIdentifier()); 
perAdap.load("COUNTRY");
Object val = perAdap.get("COUNTRY");
if (val != null) {
	System.out.println(" Value is -&amp;gt; " + &lt;FONT color="#FF0000"&gt;val.toString().substring(0, 3)&lt;/FONT&gt;);
}&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Above applies to IBA value. But in your case you're looking for name field. So you can directly query name using getName(); API.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For example:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;ObjectIdentifier oid = ObjectIdentifier.newObjectIdentifier("wt.doc.WTDocument:228878");
WTDocument doc = (WTDocument)PersistenceHelper.manager.refresh(oid);
System.out.println(" Value is -&amp;gt; " + &lt;FONT color="#FF0000"&gt;doc.getName().substring(0, 3)&lt;/FONT&gt;);
&lt;/PRE&gt;
&lt;P&gt;I hope it will help you.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Regards,&lt;/P&gt;
&lt;P&gt;Shirish&lt;/P&gt;</description>
      <pubDate>Wed, 20 Dec 2017 16:39:44 GMT</pubDate>
      <guid>https://www.ptcusercommunity.com/t5/Windchill-Customization/extract-initial-characters-from-attribute/m-p/495260#M5725</guid>
      <dc:creator>ShirishMorkhade</dc:creator>
      <dc:date>2017-12-20T16:39:44Z</dc:date>
    </item>
  </channel>
</rss>

