Announcement

Collapse
No announcement yet.

Hide Create button

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Hide Create button

    Hello

    Is it posible to hide the create buton from only 1 entity? I'm creating new entris in this entity only from other related entitys, and i use some formul when creating a entri to get some data from thows relations. If i restrict the user's rols to not create in theat entity ... yes the button is gon but thei cant create from the related entitys eder and theat is not good

    So if anidoby can tell my what i have to do to acomplis hiding theat buton plis ?

  • #2
    Hello
    Override list view of this entity and remove Create button there

    Comment


    • #3
      So to override a view i hav to go in /client/modules/crm/src/views/ if the entity is new i have to do this https://www.espocrm.com/documentatio.../custom-views/

      Comment


      • #4
        why in crm module, but not in custom?

        Comment


        • #5
          /custom/Espo/Custom/ Controllers ?? / myEntity.php

          Comment


          • #6
            you want to override the view.
            you found the tutorial about VIEW
            (before now we have talked about frontend)

            why do you ask about controller in backend?

            Comment


            • #7
              i'm stil traing to make the button 'not vizible' in front end i just dont realy undestend the file structure ...

              Comment


              • #8
                also you can add in clientDefs of this entity the parameter "createDisabled": true

                Comment


                • #9
                  ok pls help me get pass some issu i have whit the documentation from the link https://www.espocrm.com/documentatio...nt-field-views

                  Let's say i have a new entity Test, and 2 bool variabels bool1 and bool2
                  the gold is to put them toghether in a box-view edit style

                  so at step 1 from the link

                  in custom/Espo/Custom/Resorces/metadata/ClientDefs/test.json
                  we will find:
                  {
                  "controller": "controllers/record",
                  "boolFilterList": [
                  "onlyMy"
                  ]
                  }

                  We need to edit the file in order to overide the view of list detali and edit of awer element
                  "views": {
                  "list": "custom:views/test/list",
                  "detail": "custom:views/test/detail",
                  "edit": "custom:views/test/edit"
                  },
                  "recordViews": {
                  "list": "custom:views/test/record/list",
                  "detail": "custom:views/test/record/detail",
                  "edit": "custom:views/test/record/edit"
                  }

                  Q:1 wher is the file "custom:views/test/"
                  Q:2 Do i have to replace the "views" and "recordViews" ?


                  at step 2 it realy lost me

                  In client/custom/src/views/test/record/detail.js

                  Q:1 ther is no client/custom/src file

                  Comment


                  • #10
                    if you need only to set a view for some field, you don't need to override "views" and "recordViews". You don't need clientDefs at all for this....
                    just set in entityDefs a view for field and create a file client/custom/src/views/test/fields/your-field-name"....
                    how do you read the article?

                    Comment


                    • #11
                      ok i think i got it

                      in /custom/Espo/Custom/Resources/metadata/entityDefs/ test.json


                      under the { "fields": {
                      i pu in
                      "bol3": { "view": "custom:views/test/fields/bol3", },


                      and in /client/custom/src/views/test/fields/ bol3.js
                      i put in
                      {
                      "actualFields":[
                      "bol1",
                      "bol2"
                      ],
                      "fields":{
                      "bol1": {
                      "notNull": true,
                      "type": "bool",
                      "default": false,
                      "audited": false,
                      "readOnly": false,
                      "tooltip": false,
                      "isCustom": true
                      },
                      "bol2": {
                      "notNull": true,
                      "type": "bool",
                      "default": false,
                      "audited": false,
                      "readOnly": false,
                      "tooltip": false,
                      "isCustom": true
                      }

                      },
                      "notMergeable":true,
                      "notCreatable": false,
                      "filter": true,
                      "fieldDefs":{
                      "skipOrmDefs":true
                      }
                      }

                      is theat corect ?

                      Comment


                      • tanya
                        tanya commented
                        Editing a comment
                        Is it work? If yes - it is correct, if no - it's not....
                        (as I see, the answer is no)
                        on the forum you can find examples

                    • #12
                      Hello,

                      I've read thru a lot of posts related to custom views, ther is not one single post where it's explain how this works, so i com back to my thred and i wood like to go throw the creating procces step bay stem..
                      • you sead "set in entityDefs a view for field and create a file client/custom/src/views/test/fields/"


                      so if i undestend corecly when you say "entityDefs" you refer to /custom/Espo/Custom/Resources/metadata/entityDefs/
                      and you say to set up "a view for field" this meen i have to first create a entity from the admin>entity manager then a file will aper in this folder whit the seim name as my new entity.
                      In this file i can see all the fields of theat entity, eachi fild have a list of atributs.
                      So if i whant to combine 2 filds toghether i have to create them in admin ( i dont know if i have to crate only the 2 fild i whant to join or 2+1 ) afther going in admin and creating the filds
                      when we luck in the file we will se them ther.
                      so now if i oly created 2 filds i have to put in a 3' file and put a view atribut whit a sorce,
                      Cod sorce from documentation https://www.espocrm.com/documentatio...nt-field-views
                      PHP Code:
                         "yourFieldName": {       "view""custom:views/your-entity-type/fields/your-field-name"     
                      • ather this you sead "create a file client/custom/src/views/test/fields/your-field-name"

                      So in client/custom/ create he fowloing folder structur and in the file whit the name of the entity i need to create a your-field-name.js
                      from looking to forum and file i found theat in theat file i have to have somthing like this
                      PHP Code:
                      {

                         
                      "actualFields":[
                            
                      "your-field-name-thet-you-whant-to-combine-1",
                            
                      "your-field-name-thet-you-whant-to-combine-2"
                         
                      ],
                         
                      "fields":{
                            
                      "your-field-name-thet-you-whant-to-combine-1": {
                      //      the atributs of the fils
                      //      i copy the atribut's from the entityDefs wher thei wher created.
                              
                      },
                              
                      "your-field-name-thet-you-whant-to-combine-2": {
                      //      seim       
                              
                      }

                         },
                         
                      "notMergeable":true,
                         
                      "notCreatable"false,
                         
                      "filter"true,
                         
                      "fieldDefs":{
                            
                      "skipOrmDefs":true
                         
                      }

                      IF this was all then this is veri simple but for my it dosen't worck when i go in the platform if i dont creat 3 fils i dont see the 3'th fild if i creat it it all gos verry verry roung and schous up the entier entity.

                      Comment


                      • #13
                        Try to find something looks like you want in the system and use it as example

                        as example you can get entity Account field shipping address (
                        application/Espo/Modules/Crm/Resources/metadata/entityDefs/Account.json - fields - "shippingAddress"
                        /client/modules/crm/src/views/account/fields/shipping-address.js
                        )
                        (has "view" in entityDefs and contains few other fields)

                        if you want to use this field for Account entity, for entityDefs you need to use
                        custom/Espo/Custom/Resources/metadata/entityDefs/Account.json
                        if for a new entity custom/Espo/Custom/Resources/metadata/entityDefs/{YourEntityName}.json

                        But it depends on what you want to create - just one field for one entity or a field type for all entities. How do you want to store it in database?
                        You combine to variants.

                        and why we talk about this in Hide Create Button topic?

                        Comment


                        • #14
                          I'm very sory about the name if you can change the name to Cutstom View i realy aprisiate it !



                          Befor posting this thred i deed just theat.
                          Went in Account.json from application/Espo/Modules/Crm/Resources/metadata/entityDefs file and i whas luking for the 2 custom fild theat the entity comes by defult. billingg address and shipping address.
                          Hears what i found ther :
                          • the billingg address is defin like this

                          PHP Code:
                          "billingAddress": {
                                      
                          "type""address"
                                  
                          }, 
                          • and the shipping address

                          PHP Code:
                          "shippingAddress": {
                                      
                          "type""address",
                                      
                          "view""crm:views/account/fields/shipping-address"
                                  
                          }, 
                          If the 2 filds in front end works the seim ( meening thei bouf have similar fucesr like thei bouf have a list of filds theat shous up when in front end ) i didant see the seim similarity hear becous the type is just selectig what theat fild sood luck like and the in shipping adress we can se this line
                          PHP Code:
                          "view""crm:views/account/fields/shipping-address" 
                          the only difrance betwin billingAddress and shippingAddress is the buton theat copys the content from billingAddress to shippingAddress.
                          and theat is what this line is indicating to the file shipping-address.js from /client/modules/crm/src/views/account/fields/
                          PHP Code:
                          Espo.define('Crm:Views.Account.Fields.ShippingAddress''Views.Fields.Address', function (Dep) {

                              return 
                          Dep.extend({

                                  
                          copyFrom'billingAddress',

                                  
                          afterRender: function () {
                                      
                          Dep.prototype.afterRender.call(this);

                                      if (
                          this.mode == 'edit') {
                                          var 
                          label this.translate('Copy Billing''labels''Account');
                                          
                          $btn = $('<button class="btn btn-default btn-sm">' label '</button>').on('click', function () {
                                              
                          this.copy(this.copyFrom);
                                          }.
                          bind(this));
                                          
                          this.$el.append($btn);
                                      }
                                  },

                                  
                          copy: function (fieldFrom) {
                                      var 
                          attrList Object.keys(this.getMetadata().get('fields.address.fields')).forEach(function (attr) {
                                          
                          destField this.name Espo.Utils.upperCaseFirst(attr);
                                          
                          sourceField fieldFrom Espo.Utils.upperCaseFirst(attr);

                                          
                          this.model.set(destFieldthis.model.get(sourceField));
                                      }, 
                          this);

                                  },

                              });
                          }); 
                          Ther is noting in this file theat specifi anithing alce besid returning this buton and his functions.....


                          But it depends on what you want to create - just one field for one entity or a field type for all entities.

                          I whant to creat a custom fild theat will store existend filds ( so theat when i put the fild in entity layout manager wher ther is only 2 coloms in detail /edit i can sho more then 2 fild on the seim row)
                          the fild type i'm luking to put togheter is bool, so just what a fild theat will contain multiple chekboxe's one afther a nother theat i can edit and chek.

                          How do you want to store it in database?
                          You combine to variants.
                          I dont need or whant to combine contatenate information using custom view. the filds i'm troaing to put toghete oredy exist and have thei own tabel in databei.

                          Comment

                          Working...
                          X