Announcement

Collapse
No announcement yet.

Add elements to enum field

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

  • Add elements to enum field


    Hi,

    I have an enum field in quotes item which need to be populated on selecting item name. How can I achieve this.
    How to add elements to enum field in name.js?

    Please help.
    Thanks.



  • #2
    Hello
    application/Espo/Modules/Crm/Resources/metadata/entityDefs/Opportunity.json
    look how stage field is defined, also check it's view

    Comment


    • #3
      Hello,

      Something like this is possible?


      var userList = [];

      userList.push({
      name: "test",
      value: "test"
      });

      this.model.set("itemList",userList);

      where itemList is the enum field.

      Comment


      • #4
        No. Check enum field view. It works with array and translation, not with object

        Comment


        • #5
          As you said I checked application/Espo/Modules/Crm/Resources/metadata/entityDefs/Opportunity.json and stage view. But Probability field is int only.

          If we needed to copy all the values of stage field to another enum field in opportunities, and that also when selecting something from stage field, How can we do that?

          Comment


          • #6
            application/Espo/Modules/Crm/Resources/metadata/entityDefs/Lead.json industry

            Comment


            • #7

              Espo.define('Advanced:Views.QuoteItem.Fields.itemL ist', 'Views.Fields.Enum', function (Dep) {
              return Dep.extend({

              setup: function () {
              alert('success');
              this.params.options = this.getMetadata().get('entityDefs.Account.fields. industry.options');
              this.params.translation = 'Account.options.industry';
              Dep.prototype.setup.call(this);
              }

              });

              });


              And in quoteItem.json

              "itemList": {
              "type": "enum",
              "required": false,
              "view": "advanced:views/quote-item/fields/item-list",
              "options": [
              "",
              ],
              "isSorted": false,
              "audited": false,
              "readOnly": false,
              "tooltip": false,
              "isCustom": true
              }



              in item.js


              this.createView('itemList','views/fields/enum', {
              model: this.model,
              defs: {
              name: 'itemList'

              },
              mode: 'edit',
              el: this.options.el + ' .field-description',
              inlineEditDisabled: false,
              readOnlyDisabled: false

              });


              setup() in view not working. Tried with alert
              Please help.

              Comment


              • #8
                It is working now.
                Mistake was, I should have given like this.createView('itemList','Advanced:QuoteItem.Fie lds.itemList')
                Thanks.

                Comment


                • #9
                  Hello,

                  How to get saved phoneNumber types and values of an entity in js file?
                  Like this code $this->getEntityManager()->getRepository('PhoneNumber')->getPhoneNumberData($entity) in record.php

                  Please help.
                  Thanks.

                  Comment


                  • #10
                    Hello
                    Better to add this loading to the record, if it is some field
                    If not, you need to create ajax request

                    Comment


                    • #11
                      Contacts have multiple phone numbers of types office,home and mobile.

                      In quotes, When we select a billing contact, I need to display all phone numbers of that contact item.

                      How will be the ajax request for that.

                      Please help.

                      Comment


                      • #12
                        create notStorable readOnly field with phone view or view extended phone view
                        set the value in loadAditionalFields and in Entity, where you load phoneNumberData of your billing contact

                        Comment


                        • #13
                          Anywhere can I find this logic implemented?

                          I need those values to be displayed as dropdownList in quotes.

                          Please help.

                          Comment


                          • #14
                            I tried one ajax call


                            In quote-item/name.js

                            $.ajax({
                            url: 'Product/action/loadListItemField',
                            type: 'GET',
                            success: function (data) {
                            alert('success');
                            }
                            });
                            In Controllers/Product.php

                            class Product extends \Espo\Core\Controllers\Record
                            {

                            public function actionLoadListItemField($params, $data, $request)
                            {
                            return 'hi';
                            }

                            }

                            which gives Bad server response: hi as the result.

                            Please help.

                            Comment


                            • #15
                              read the reason in log file
                              try to return an array

                              Comment

                              Working...
                              X