No announcement yet.

Add and remove custom fields programaticaly

  • Filter
  • Time
  • Show
Clear All
new posts

  • Add and remove custom fields programaticaly

    Hi guys! First, thanks for all the help, this forum is really helpful. I'm a developer understanding just now how this CRM works,

    Is there an "easy" or made way to make something like this: (I attach the image)

    In a custom model (entity) , i need another entity with 3 fields attached. Relation is one to many. (One case has many cupons). Limit is 10 , but i can handle that with js.

    My idea was to:

    -create the new entity
    -relate both entity in the entityDef
    -on the client def, i have no idea here, but i think there is something?

    then i would create a dinamic js handler for the add and remove

    and figured something with a controller to save , delete and update those fields ....

    Im going in the right directions here? Any help would be very appreciated and welcome.

    Thanks again!!!

  • #2
    Hi, there is no thread from my knowledge that is relevant to what you trying to achieve (least not one a solution that I can remember).

    The closest is the Invoice/Sales extension that have a feature, if you have that extensions you can see how is coded. Can't help you but perhaps my thread may contain some thread that give provide some hints.

    Have a check here:


    • #3
      Hi changos ,

      Unfortunately there is no "easy" way to accomplish the layout that you describe by coding.

      One option without coding would be to purchase eblasoft's extension which I understand can provide the capability that you describe.

      If you prefer to develop your own solution, Espo offers a very similar layout as part of the Sales Pack Extension (check the demo site if you do not own the extension), but that being a paid extension, imply that any modifications to the code for personal or commercial use would almost certainly be a violation of copyright. (You could check with the developers to confirm).

      The good news for developing your own solution, is that Espo already offers all the basic functionality to achieve your basic goal which as I understand is to be able to add or remove "cupons" to a "case".

      If that is correct, then you would not need to add or delete "fields" but rather add or delete "records" (a "cupon") and you could do that by having a list of linked "cupons" displayed in a panel below the "case" detail view.

      For example, in our application we have a "Service Ticket" entity which is linked in a One-to-Many relationship with another entity called "Work Order" and when you select a Service Ticket from a list, the display looks like this:

      Click image for larger version  Name:	Detail with Children list.PNG Views:	0 Size:	65.4 KB ID:	63283
      As you can see, it is possible to add a new "Work Order" to the "Service Ticket", edit such Work Order or remove. So the functionality that you want would be basically the same, but the special layout is what would need to be developed if you want it.

      Implementing the standard layout is very simple and can be done through the GUI like this (assuming that "case" and cupon" have already been defined and linked)

      Admin > Layout Manager > Cases > Bottom Panels
      Move the "Cupons" item to the "Enabled" panel"
      Click "Save"
      Clear cache and rebuild.
      Last edited by telecastg; 10-06-2020, 04:53 PM.


      • #4
        Some additional comments regarding developing your own custom layout:

        One feature that you can add to make the standard EspoCRM (form - subform or parent-children) display paradigm closer to a true form - subform paradigm is to add the capability of performing inline editing to the children records, instead of having to open each child record in a modal view as it is currently done

        That capability is not part of Espo but you can check this post to see how it can be implemented:

        Also, to help guiding possible development, these are the view classes that control the "children" display area:
        Click image for larger version  Name:	Detail with Children list.png Views:	0 Size:	71.0 KB ID:	63309

        After you have developed the custom view classes, they will need to be specified in the parent's entity clientDefs metadata file.

        For example: Suppose that I have two custom entities: "AnyParentEntity" linked to "AnyChildEntity" in a one-to-many relationship, and I have developed two view classes and I want to apply it to display a list of "AnyChildEntity" entities under the "AnyParentEntity" detail view.

        The scripts are:

        a) client/custom/src/views/record/panels/my-custom-relationship,js extended from client/src/views/record/panels/relationship.js intended to change something at the "A" panel.

        b) client/custom/src/views/record/my-custom-list.js extended from client/src/views/record/list.js intended to change something in the "B" panel.

        At custom/Espo/Custom/Resources/metadata/clientDefs/AnyParentEntity.json I would enter:
        "relationshipPanels": {
            "anyChildEntitys": {
                "label": "Any Children Entities",
                "rowActionsView": "views/record/row-actions/edit-and-remove",
                "view": "custom:views/record/panels/my-custom-relationship",
                "recordListView": "custom:views/record/my-custom-list"
        Please note that when I say "parent" or "children" records I mean entities which are linked in a one-to-many relationship, not only an Espo parent-children relationship.

        Finally, if you decide to give it a try coding your customization, please share so we can all benefit
        Last edited by telecastg; 10-06-2020, 04:55 PM.


        • espcrm
          espcrm commented
          Editing a comment
          Suddenly a tutorial; any recommendation to the Description/Title should link this post if I want to add it to Learning Thread?

        • telecastg
          telecastg commented
          Editing a comment
          It's kind of a mixed bag. We are discussing how to add a list of "children" or "many" entity records to the bottom panel and then a discussion of which view classes control the display of the parent detail view and the children list.

          I would say that the latter one belongs to the GUI guide for coders, which scripts control what sections.

      • #5
        telecastg This is awesome!!! Today I will start coding and see witch port I can arrive. I will share everything here so any future developer can use this for help.

        Thanks a lot, is a very big help you give me to start.

        Hope today / tomorrow I can have something to share.


        • #6
          Hi telecastg , finally I ended up using just the common layout for the record, It's working very well, and I didn't want to make some custom modification as well the User approves this.

          Thanks a lot for all the help, you guys really rock!!


          • #7
            Hi telecastg , regarding this Issue, I don't know if your application does the same, but you must first "create" a case , and the I can view the cupons sections (in my case). I mean, you need to do two steps before adding a cupon to a case (first create a case, and then you can add the cupon).

            Is this a limitation by Espo? Any ideas or how maybe workaround this?

            Thanks in advance


            • #8
              Hi changos
              you must first "create" a case , and the I can view the cupons
              Yes that is how we have it set up. A Work Order is specifically created for a single Service Ticket. There are no "free floating" (unlinked) Work Orders available to be assigned to a Service Ticket.
              Last edited by telecastg; 10-20-2020, 06:04 AM.