Skip to main content
10-Marble
November 1, 2023
Solved

WF activity instructions that include attributes from Enum list not showing display name

  • November 1, 2023
  • 1 reply
  • 5994 views

I trying to write some Workflow Activity instructions that include attributes (workflow variables) derived from enumerated lists chosen when creating the object. For example, we have a list of Technical Approves. Each approver has a unique internal name that is different from their display name.

 

The instructions need to say "talk with J. Baker about this" but they are coming out as "talk with TA_JBaker about this". The problem is even worse when the user's name has changed (i.e. through marriage their display name should now be J. Reynolds).

 

How can I tell the instructions to use the display name and not the internal name?

We are using Release 12.0.2.12 with PLMlink 12.0.2.7.

 

 

Best answer by Ben_A

@HelesicPetrand @BjoernRueegg Thank you both for your help on this. I got the following code working. It extracts the display name of a Global Enumerated Value.

 

 

com.ptc.core.lwc.server.PersistableAdapter obj = new com.ptc.core.lwc.server.PersistableAdapter(primaryBusinessObject,null, java.util.Locale.US, new com.ptc.core.meta.common.DisplayOperationIdentifier());
obj.load("my_enum_attribute");
Object enumValue = obj.get("my_enum_attribute");

System.out.println("Attribute Value = internal name of Enumerated Value: " + (java.lang.String) obj.get("my_enum_attribute"));
//Returns TA_JBaker

com.ptc.core.meta.container.common.AttributeTypeSummary ats = obj.getAttributeDescriptor("my_enum_attribute");
com.ptc.core.meta.common.DataSet ds = ats.getLegalValueSet();
com.ptc.core.meta.common.EnumerationEntryIdentifier enumerationEntryIdentifier = ((com.ptc.core.meta.common.EnumeratedSet) ds).getElementByKey(enumValue.toString());
com.ptc.core.lwc.server.LWCEnumerationEntryValuesFactory lwcEnumerationEntryValuesFactory = new com.ptc.core.lwc.server.LWCEnumerationEntryValuesFactory();

//System.out.println(lwcEnumerationEntryValuesFactory.get(enumerationEntryIdentifier, java.util.Locale.US));
//Returns: {IS_SELECTABLE=true, displayName=J. Reynolds, display=J. Reynolds, abbreviatedDisplay=J. Reynolds, selectable=true, fullDisplay=J. Reynolds, sort_order=0}

wt.meta.LocalizedValues localizedValues = lwcEnumerationEntryValuesFactory.get(enumerationEntryIdentifier, java.util.Locale.US);
String enum_display_name = localizedValues.getDisplay();

System.out.println("Enumerated Value's Display Name: " + enum_display_name);
//Returns: J. Reynolds

 

 

1 reply

avillanueva
23-Emerald I
23-Emerald I
November 1, 2023

You want to use user.getFullName() to see Display name.

Ben_A10-MarbleAuthor
10-Marble
November 1, 2023

But these are instructions written in the Activity tab of a task assignment node. Can I use code the activity tab? If so, that would be great. How though?

Right now I'm having to use: talk with {ta_name_wf} about this to show the value. Where ta_name_wf is the variable mapped to the attribute. 

HelesicPetr
22-Sapphire II
22-Sapphire II
November 2, 2023

Hi @Ben_A 

You need to create new variable where you fill the display name by  code, and you use this attribute in the instructions.

PetrH