How to create Data Utility in Windchill

Data Utility Example

Add Comment
1 Answer(s)

1. Create a class that extends any OOTB data utility class that falls in your context. Also override the method getDataValue according to your requirement.

public class TextColorDataUtility extends TypeDataUtility {

 public Object getDataValue(String comp_id, Object datum, ModelContext mc) throws WTException {

  WTPart part = null;
  TextDisplayComponent tdp = null;
  if (datum instanceof WTPart) {
   part = (WTPart) datum;
   tdp = new TextDisplayComponent(part.getName());

  return tdp;

2. Register your data utility in <windchill>/codebase/ and run xconfmanager -p to propagate the changes.

<Service name="com.ptc.core.components.descriptor.DataUtility">
 <Option serviceClass="ext.custom.datautilities.TextColorDataUtility" requestor="java.lang.Object" selector="textColorDataUtility"/>


3. There are two ways you can call your data utility. Any of the two listed methods can be used to call the data utility.

First: You can call it for attributes using Type and Attribute Management.
For eg.

Go to Type and Attribute Manager ->
Part(Get into Edit Mode) ->
Layouts(Choose a layout) ->
Add Data Utility Id to the desired attribute ->
Save the changes and exit.

Second: You can call it in Table Builder
For eg.

public class MVCTableBuilder extends AbstractComponentBuilder {

 public Object buildComponentData(ComponentConfig config, ComponentParams params) throws Exception {
  QuerySpec query =  new QuerySpec(WTPart.class);
  // You can specify the search condition according to you
  query.appendWhere(new SearchCondition(WTPart.class,WTPart.NAME,SearchCondition.LIKE,"%Part%"), null);
  return PersistenceHelper.manager.find(query);

 public ComponentConfig buildComponentConfig(ComponentParams arg0) throws WTException {

  ComponentConfigFactory factory = getComponentConfigFactory();

  TableConfig table = factory.newTableConfig();

  table.setLabel("Selected Parts");

  ColumnConfig column = factory.newColumnConfig("name",true);
  column.setDataUtilityId("textColorDataUtility"); // set the data utility id
  table.addComponent(factory.newColumnConfig("number", true));
  table.addComponent(factory.newColumnConfig("type", true));
  table.addComponent(factory.newColumnConfig("thePersistInfo.modifyStamp", true));
  table.addComponent(factory.newColumnConfig("thePersistInfo.createStamp", true));

  return table;



Add Comment

Your Answer

By posting your answer, you agree to the privacy policy and terms of service.