Announcement

Collapse
No announcement yet.

How to configure auto-complete fields when creating an object through another object?

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

  • How to configure auto-complete fields when creating an object through another object?

    Hello, tell me how to configure the autocomplete fields when creating an object through another object:
    Last edited by roman042; 11-03-2017, 09:21 AM. Reason: auto-complete fields

  • #2
    Hello

    in custom clientDefs of entity define createAction and view, extends views/record/panels/relationship, like custom/Espo/Custom/Resources/metadata/clientDefs/Account.json
    Code:
    {
      "relationshipPanels": {
        "opportunities": {
          "createAction":"createRelatedOpportunity",
          "view":"custom:views/account/record/panels/opportunities"
        }
      }
    }
    and define in your view the method actionCreateRelatedOpportunity

    Code:
    actionCreateRelatedOpportunity: function () {
                this.notify('Loading...');
                var viewName = this.getMetadata().get('clientDefs.Opportunity.modalViews.edit') || 'views/modals/edit';
    
                var attributes = {}; // <=== here set field values
    
    
                this.createView('quickCreate', viewName, {
                    scope: 'Opportunity',
                    relate: {
                        model: this.model,
                        link: 'account',
                    },
                    attributes: attributes,
                }, function (view) {
                    view.render();
                    view.notify(false);
                    this.listenToOnce(view, 'after:save', function () {
                        this.collection.fetch();
                    }, this);
                }, this);
            },
    
        });
    Last edited by tanya; 11-03-2017, 03:11 PM.

    Comment


    • #3
      You can ask for an example of the file "custom: views / account / record / panels / opportunities"...

      Comment


      • #4
        I did this, gives an error, the card does not load ...

        Code:
        Espo.define('custom:views/account/record/panels/opportunities', 'views/modals/edit', function (Dep) {
        
            return Dep.extend({
        
                actionCreateRelatedOpportunity: function () {
                    this.notify('Loading...');
                    var viewName = this.getMetadata().get('clientDefs.Opportunity.modalViews.edit') || 'views/modals/edit';
        
                    var attributes = {}; // <=== here set field values
        
        
                    this.createView('quickCreate', viewName, {
                        scope: 'Opportunity',
                        relate: {
                            model: this.model,
                            link: 'account',
                        },
                        attributes: attributes,
                        }, function (view) {
                        view.render();
                        view.notify(false);
                        this.listenToOnce(view, 'after:save', function () {
                            this.collection.fetch();
                        }, this);
                    }, this);
                },
        
            });
        
        });

        The error is this:
        espo.min.js?r=1510035457:17 Uncaught (in promise) TypeError: Cannot read property 'split' of undefined

        Comment


        • #5
          write the path of your file
          Originally posted by tanya View Post
          in custom clientDefs of entity define createAction and view, extends views/record/panels/relationship

          Comment


          • #6
            Many thanks, sorry for the inattention: (
            Everything is working!

            Comment

            Working...
            X