Community Tip - Need to share some code when posting a question or reply? Make sure to use the "Insert code sample" menu option. Learn more! X
I'm looking to add an action to the PrimaryContent attribute in General group under the Details Tab as shown in the attached image.
Just like how the PDF icon in the value downloads the PDF when clicked upon, I need to add another icon that performs an action.
Could anyone help me with it? Need API ways or any other workaround.
Solved! Go to Solution.
Hi @MV_10441462
You need to extend the PrimaryAttachmentPropertiesDataUtility.class
then you need to generate standard DataValue from that class and in the end you generate own GuiComponent and add it to the final GuiArrayComponent.
Example of code is here
public class MultiComponentDataUtility extends PrimaryAttachmentPropertiesDataUtility //AssignmentsTableNmActionsDataUtility
{
public Object getDataValue(String component_id, Object obj, ModelContext modelContext) throws WTException
{
// create original Component
GUIComponentArray retObject = (GUIComponentArray) super.getDataValue(component_id, obj, modelContext);
//example of menuaction from Workflow table so generate own nmAction used in the wf table
AssignmentsTableNmActionsDataUtility actionDataUtility = new AssignmentsTableNmActionsDataUtility();
NmAction nmAction = (NmAction) actionDataUtility.getDataValue(component_id, obj, modelContext);
// crate new NmActionGuiComponent from nmAction that allows to add it to the GUIComponentArray
NmActionGuiComponent nmActionGuiComponent = new NmActionGuiComponent(nmAction);
// adding own custom NmActionGuiComponent to the finall array
retObject.addGUIComponent(nmActionGuiComponent);
return retObject;
}
}
also do not forget to redefine the DataUtility in the enterprise.dataUtilities.properties to set your own custom datautility Class for primaryAttachmentProperties selector
PetrH
I would think this can be done in one of two ways. It depends on how that URL to the content and the icons are generated. My guess is that its a data utility. We would need to find the right one and extend it. This would the allow you to add additional actions and icons next to the open content type icon. I checked jcaDebug quickly but it did not give me data on which one it was,
Hi @avillanueva
DataUtility is com.ptc.windchill.enterprise.attachments.dataUtilities.PrimaryAttachmentPropertiesDataUtility
PetrH
Hi @HelesicPetr Yes exactly. I need to add a similar icon next to the info icon on the PrimaryContent attribute value only for wt.doc.WtDocument types.
The icon when clicked will open a url that's generated dynamically.
Hi @MV_10441462
You need to extend the PrimaryAttachmentPropertiesDataUtility.class
then you need to generate standard DataValue from that class and in the end you generate own GuiComponent and add it to the final GuiArrayComponent.
Example of code is here
public class MultiComponentDataUtility extends PrimaryAttachmentPropertiesDataUtility //AssignmentsTableNmActionsDataUtility
{
public Object getDataValue(String component_id, Object obj, ModelContext modelContext) throws WTException
{
// create original Component
GUIComponentArray retObject = (GUIComponentArray) super.getDataValue(component_id, obj, modelContext);
//example of menuaction from Workflow table so generate own nmAction used in the wf table
AssignmentsTableNmActionsDataUtility actionDataUtility = new AssignmentsTableNmActionsDataUtility();
NmAction nmAction = (NmAction) actionDataUtility.getDataValue(component_id, obj, modelContext);
// crate new NmActionGuiComponent from nmAction that allows to add it to the GUIComponentArray
NmActionGuiComponent nmActionGuiComponent = new NmActionGuiComponent(nmAction);
// adding own custom NmActionGuiComponent to the finall array
retObject.addGUIComponent(nmActionGuiComponent);
return retObject;
}
}
also do not forget to redefine the DataUtility in the enterprise.dataUtilities.properties to set your own custom datautility Class for primaryAttachmentProperties selector
PetrH
Hi @HelesicPetr
I implemented the dataUtility class as per the sample you shared and updated the xconf as well. My question is, should this dataUtility be called from anywhere? Because my requirement is that the icon I'm trying to add should be added to the value of PrimaryContent attribute and only for WtDocument types.