I wrote a display method for an extension table. ServiceSubStatus is an enum field so 0,1,2 are displaying but I need to display the value of the enum.
Can you please help me with this?
[ExtensionOf(tableStr(EntAssetObjectTable))] public final class ObjectTable_Extension { public display ServiceSubStatus ServiceSubStatus() { return (ServiceStatus::findByRecId(this.ServiceStatus).ServiceSubStatus); } }
public display str ServiceSubStatus() { SysDictEnum dictEnum = new SysDictEnum(enumNum(ServiceSubStatusEnum)); ServiceStatus serviceStatus = ServiceStatus::findByRecId(this.ServiceStatus); if(serviceStatus) { return dictEnum.value2Label(serviceStatus.ServiceSubStatus); }
I coded this way and it worked but thank you so much for your answer
[ExtensionOf(tableStr(EntAssetObjectTable))] public final class ObjectTable_Extension { public display str ServiceSubStatus() { return (enum2str(ServiceStatus::findByRecId(this.ServiceStatus).ServiceSubStatus)); } }
Try the code above (I used enum2str and changed return type to string)
ServiceSubStatus exists as Base Enum (I have created it) and labels are fine, I am not sure why I get this result
What you're describing isn't the expected behavior. What you should see is enum's label, not numeric values.
Could you please look at ServiceSubStatus enum (it doesn't exist in my F&O application) and check the Label property of enum elements? A possible explaination is that somebody set the numbers as labels.
You can use enum2Str function to get the string value of Enum, refer to:
Stay up to date on forum activity by subscribing. You can also customize your in-app and email Notification settings across all subscriptions.
André Arnaud de Cal... 291,240 Super User 2024 Season 2
Martin Dráb 230,149 Most Valuable Professional
nmaenpaa 101,156