cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - You can Bookmark boards, posts or articles that you'd like to access again easily! X

Translate the entire conversation x

Create Part Picker for New Attribute

BF_13811900
12-Amethyst

Create Part Picker for New Attribute

I have created a new local (according to https://www.ptc.com/en/support/article/CS348371?source=search , the attribute cannot be global) attribute associated with a "WTDocument" sub-type. I intend on adding this new attribute to one of the layouts associated with the sub-type. I wish to configure the attribute in such a way so that, when a user wishes to populate the attribute value field, they have the ability to use a "Picker" to make a selection from the WTParts that exist in the instance. Specifically, I would want the part number to be inputted into the attribute field upon selection.

 

I have been looking at various articles/resources of PTCs and I can see that there is potentially a number of ways of doing this. My understanding is that a "Data Utility" could potentially provide the functionality I'm looking for.

 

Can anybody advise on the best way of achieving my requirement? If any files need to be updated on the server as part of any solutions, please could the full paths be stated? I have noticed that some of the paths referenced on the PTC sites are not featured as part of my server install.

ACCEPTED SOLUTION

Accepted Solutions
HelesicPetr
22-Sapphire II
(To:BF_13811900)

Hi @BF_13811900 

The DataUtility is the best way.

You have to write onw one class that is used as a DataUtility and then register the DataUtility in the service.properties with your key name id

for example .com.ext.MyDataUtility can have have a name as myDatautil 

xconfmanager -t codebase/service.properties -s wt.services/svc/default/com.ptc.core.components.descriptor.DataUtility/myDatautil/java.lang.Object/0=com.ext.MyDataUtility/singleton -p

then you use the myDatautil in a creation wizard layout on your attribute. 

 

[Knowledge Hub] Windchill PLM - Data Utility

CS139540 - How to return a Combo Box from custom Data Utility in Windchill PDMLink

 

You just need to write own code to get the WTPart numbers and add them to the combobox .

PS: ComboBox is a selection list , you have to know how to write code

 

PetrH

View solution in original post

4 REPLIES 4
HelesicPetr
22-Sapphire II
(To:BF_13811900)

Hi @BF_13811900 

The DataUtility is the best way.

You have to write onw one class that is used as a DataUtility and then register the DataUtility in the service.properties with your key name id

for example .com.ext.MyDataUtility can have have a name as myDatautil 

xconfmanager -t codebase/service.properties -s wt.services/svc/default/com.ptc.core.components.descriptor.DataUtility/myDatautil/java.lang.Object/0=com.ext.MyDataUtility/singleton -p

then you use the myDatautil in a creation wizard layout on your attribute. 

 

[Knowledge Hub] Windchill PLM - Data Utility

CS139540 - How to return a Combo Box from custom Data Utility in Windchill PDMLink

 

You just need to write own code to get the WTPart numbers and add them to the combobox .

PS: ComboBox is a selection list , you have to know how to write code

 

PetrH

Hello @HelesicPetr !

 

Thanks for getting in touch.

 

I have found the article seen below that includes a link to some script which can be used to create a class for an "Organization picker".

 

https://www.ptc.com/en/support/article/CS80307

 

I was thinking about copying this code and modifying it where appropriate to make it a "Part picker". I believe I can then run the code in your comment above to register the new class in service.properties (which will also update the neccesary .xconf files?).

 

1. I have noticed the code for the "Organization picker" makes reference to classes such as "com.ptc.core.components.factory.dataUtilities.DefaultPickerDataUtility". Some of which I can find no "CLASS" files for under my Windchill install directory. Do you have any idea why these might be missing? and if this is normal?

 

2. The article I have referred to in this comment mentions making changes to "buildUserPickerConfig" and "getDataValue". Are you clear on what the instruction is here? If so, please could you elaborate on what needs to be done?

HelesicPetr
22-Sapphire II
(To:BF_13811900)

hi @BF_13811900 

The class is nice example how to build the datautility, but it does not do what you need.

 

You have to write own code to get the information how to get all values used in the picker.

btw I would preferer to use the ComboBox to build a list picker. 

 

here is really simple example how to crate the ComboBox object and how to add a values to  this object as a list.

 

@Override
public ComboBox getDataValue(String component_id, Object obj, ModelContext modelContext) throws WTException
{
	if (obj != null && obj instanceof WTDocument)
	{
		WTDocument wtDoc = (WTDocument) obj;
		//create combobox
		ComboBox comboBox = new ComboBox();
		comboBox.setLabel(component_id);
		comboBox.setId(component_id);
		comboBox.setColumnName(AttributeDataUtilityHelper.getColumnName(component_id, obj, modelContext));
		String columName = comboBox.getColumnName();
		ArrayList<String> enumerationsInter = new ArrayList<>();
		ArrayList<String> enumerationsDisplay = new ArrayList<>();
		enumerationsInter.add("");
		enumerationsDisplay.add("");

		enumerationsInter.add(Boolean.TRUE.toString());
		enumerationsDisplay.add("True");
		enumerationsInter.add(Boolean.FALSE.toString());
		enumerationsDisplay.add("False");

		comboBox.setInternalValues(enumerationsInter);
		comboBox.setValues(enumerationsDisplay);

		//comboBox.addStyleClass("overdueDate");

		return comboBox;
	}
	return null;
}

 

PetrH

Thank you so much @HelesicPetr  !

Announcements

Top Tags