Announcement
Collapse
No announcement yet.
Enhanced Dynamic Logic
Collapse
X
-
tothewine
Can we have a default dynamic handler that uses ajax to make calls to a controller/service we can then extend with custom class ?
- Likes 2
-
I totally agree that making feature requests is important to keep the forum alive and to give first hand feedback to the developers, and I would also like to see more developers sharing their implementations or solutions to enrich this fantastic framework and make it even more appealing and increase its adoption.
-
Just regarding the 2nd paragraph, don't be afraid to try your luck or revive an old thread! Some of my feature request manage to get approve so was quite happy that a feature become reality.
Not all feature request was accept, but the more important one did.
Keep forum alive.
-
Espo, out of the box, allows a high degree of customization from the Administration module, but these facilities, just as any first class "code generator" can do, will work hopefully for 90% of the customization needs of hopefully 90% of the users because they are meant for the widest use possible, so by definition they can not accommodate all use cases.
Of course it is always possible to request features from the developers but there is no guarantee that they will find a suggestion compelling enough to justify the effort and investment required for development and maintenance of the additional code.
To achieve a higher degree of GUI customization, beyond what is provided by the Administration module, will require either coding or hiring a developer to create the necessary code.
For those willing to do some basic code, Espo provides dynamic handler https://docs.espocrm.com/development/dynamic-handler/ , a single script where you can write highly complex logic to modify the display and characteristics of fields in any entity and even writing some front-end "hook" like functions without having to mess with writing custom views, controllers, etc.
I have included some enhancements to this class as part of the enhanced-dynamic-logic free plugin latest release. https://github.com/telecastg/enhance...ic-for-espocrm and also posted a step by step tutorial, for those interested, on how to apply custom logic, including manipulating options of enum fields, changing field colors and using User properties to achieve highly customized GUI effects. https://forum.espocrm.com/forum/deve...gic-conditions
SaludosLast edited by telecastg; 06-17-2020, 04:26 AM.
- Likes 1
Leave a comment:
-
I use another way, more restricting: clear forbidden options by formula, when they've been chosen by user. But this is awkward.
-
I agree with Oleskii. Lack of current user/role/team base Contitional Options support is a big drawback. For example, if option A B instead of A B C D are supposed to be shown based on a condition, when I create a new one, that condition is going to work as ALL fields are empty at this point. So on UI , we end up seeing A B C D as options. The only work around now is to force the user to save it first by filling out the condition field , then go back to edit it to see option A and B.
Leave a comment:
-
Originally posted by telecastg View PostAt present the enhanced dynamic logic plugin does not cover placing restrictions on enum fields.
Originally posted by telecastg View Post…out-of-the-box dynamic logic:
- The attributes of another field and comparisons (greater than, less than, contains, not contains, etc)
Originally posted by telecastg View PostFor your current goal, I think that the new dynamic-handler is more appropriate and although it requires some simple coding it can be a very useful tool to learn.
Leave a comment:
-
You're welcome Oleksii S.
At present the enhanced dynamic logic plugin does not cover placing restrictions on enum fields.
The plugin only covers the same types of changes as the out-of-the-box dynamic logic:
- Show or hide a field
- Show or hide a Panel
- Make a field read-only
- Make a field required
PLUS: Change a field's css (color, background-color,font,etc) in detail and in list display.
Regarding the type of conditions that can be evaluated with the plug they are the same as the out-of-the-box dynamic logic:
- The attributes of another field and comparisons (greater than, less than, contains, not contains, etc)
PLUS the current user attributes (isAdmin, isPortal, Role membership, etc)
Also at present, the plug-in does not have an Admin interface and requires some coding because it overrides the out-of-the-box dynamic logic. It is more of a tool for developers than an Administrator feature. I can't promise but I will check the possibility to make it more "user friendly" in the future when I have some time.
For your current goal, I think that the new dynamic-handler is more appropriate and although it requires some simple coding it can be a very useful tool to learn.
Leave a comment:
-
Thanks, telecastg !
But what I asked about is your plugin.
I`d like to see a cloud/box instance as flexible, as god`s clay, so a hard coding is a last option.
The dynamic logic, as a tool for data restriction, lacks some power, so I wonder if your plugin could help.
What I can see for now, I`d wish attributes-comparing operators and mentioned Current User properties.
If this is realizable by kind of simple installation of the plugin, I`d try to use it, till Dear Developers will implement some in native.
Or maybe, you could let it as a payable extension, for an option.
- Likes 1
Leave a comment:
-
Hello Oleksii,
If I understand correctly, you want to change the enum options of a field based on the condition that the current user is or is not the record creator.
You can do this with Dynamic Handler https://docs.espocrm.com/development/dynamic-handler/
Follow the example provided in the documentation and adapt to your own entity.
To test if a user is the same as the one who created the record, use this condition inside the function "controlFields":
Code:if(this.recordView.getUser().id == this.model.attributes.createdById) { // set the options for your enum field when the current user is the person that created the record } else { // set the options for your enum field when the user is NOT the person that created the record }
- Likes 2
Leave a comment:
-
Hello telecastg,
I need to exclude some options of the Enum field depending on the Current user: If CurrentUser IS NOT CreatedBy one.
Is it a case within the topic?Last edited by Oleksii S.; 05-20-2020, 02:13 PM.
- Likes 1
Leave a comment:
-
Hello Peter,
As I mentioned, it would be possible to establish the current User Id as a Dynamic Logic condition, but it would require to hard code the target User Id in metadata as an input.
Dynamic Logic (original and enhanced) are front-end (client-side) implementations so they occur immediately, before the data is sent to the server, while Formula (in my opinion) is essentially a user friendly way to write a Hook which is a back-end (server-side) implementation so it happens after the entity has been modified in the front-end but depending on the hook it can happen before or after a record has been updated in the database.
So in that sense Dynamic Logic is client-side and Formula is server-side so they are not compatible.
What would be desirable for Administrators not wanting to deal with coding metadata, is to be able to include the enhanced dynamic options in the field Administration facility as part of the Dynamic Logic section but that requires changes to Espo's application files and would not be "upgrade safe".Last edited by telecastg; 01-24-2020, 07:16 PM.
- Likes 2
Leave a comment:
Leave a comment: