Hi, is it possible to access the display value of an ENUM field in script?
Announcement
Collapse
No announcement yet.
Accessing the display value of an ENUM field
Collapse
X
-
-
Originally posted by MatLudlam View PostHi, is it possible to access the display value of an ENUM field in script?
To access the display value of enum fied directly you edit this line :
https://github.com/espocrm/espocrm/b...ds/enum.js#L52
here you can play with the value as you want,
Please note that this is not safe upgrade and to make it safe upgrade you need to define custom view class for the enumLast edited by eymen-elkum; 06-06-2020, 05:02 AM.
Comment
-
Hi esforim and eymen-elkum Thanks all for the feedback. Let me give a little background. We use the cloud version of ESPO so don't have access to the code behind the scenes, all we have is the script language, so this is where we have to do all of the work.
The problem that I am trying to solve is around tracking how far an opportunity goes before it gets "Closed Lost". I want to analyse how quickly we are qualifying out of opportunities. So what I need a filed on the opportunity called maxStage that holds the furthest through the sales cycle that an Opportunity got.
The issue is that stages are things like "Prospecting", "Demo", "Eval", "Won" etc. I can tell you the sequence but this is a real mess too write in script language.
The correct solution would be for the programmer to have access to the sequence of ENUM value as defined in entity manager.
The second best solution for me was to use the display names because I have them as things like "1 - Prospecting", "3 - Demo", "9 - Won". These sort nicely so I can just compare one to the other and pick the greatest.
The 3rd best solution, that I am thinking through is around probabilities. We don't use the system maintained probability, and these do sort nicely. So I may end up with 2 fields maxStage and maxProbability and I will do all of the comparing on the latter.
If you have any other ideas, it would be appreciated.
In an ideal world there would be 2 new functions:- entity\attributeEnumDisplayName(ATTRIBUTE) - that would return the external name of an ENUM field
- entity\attributeEnumOrder(ATTRIBUTE) - that would return the order from entity manager of the given value
- Likes 1
Comment
-
Sound like it is out of my league at this stage, firstly I don't even use these function (and secondly due to lack to skill and complexity in knowledge).
In my opinion, yes, two different fields is best to be use. One for the name and one for the order (too bad we can't multi-sort yet, e.g. Sort by Number then by Name, then by something else). Don't use it as a single field, if you want it as single field better to use a "concatenate"/combine field.
In term of tracking I see a couple of Formula on the forum where people use "days" calculation to assign these status.
-
Originally posted by MatLudlam View PostHi esforim and eymen-elkum Thanks all for the feedback. Let me give a little background. We use the cloud version of ESPO so don't have access to the code behind the scenes, all we have is the script language, so this is where we have to do all of the work.
The problem that I am trying to solve is around tracking how far an opportunity goes before it gets "Closed Lost". I want to analyse how quickly we are qualifying out of opportunities. So what I need a filed on the opportunity called maxStage that holds the furthest through the sales cycle that an Opportunity got.
The issue is that stages are things like "Prospecting", "Demo", "Eval", "Won" etc. I can tell you the sequence but this is a real mess too write in script language.
The correct solution would be for the programmer to have access to the sequence of ENUM value as defined in entity manager.
The second best solution for me was to use the display names because I have them as things like "1 - Prospecting", "3 - Demo", "9 - Won". These sort nicely so I can just compare one to the other and pick the greatest.
The 3rd best solution, that I am thinking through is around probabilities. We don't use the system maintained probability, and these do sort nicely. So I may end up with 2 fields maxStage and maxProbability and I will do all of the comparing on the latter.
If you have any other ideas, it would be appreciated.
In an ideal world there would be 2 new functions:- entity\attributeEnumDisplayName(ATTRIBUTE) - that would return the external name of an ENUM field
- entity\attributeEnumOrder(ATTRIBUTE) - that would return the order from entity manager of the given value
We have implemented this feature into our extension Ebla Enum Plus, if you are still interesting on it you can find more information here:
- Likes 1
Comment
Comment