Announcement

Collapse
No announcement yet.

Pre-Popluate a New Entity?

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

  • Pre-Popluate a New Entity?

    Hello,

    I was wondering if there is a way currently to pre-populate a new entity entry from the URL? Something like:
    /#Contact/create?firstName=Stephen&lastName=Test

    Thanks,
    Stephen

  • #2
    Hello,

    No, from the url it's impossible. Only set the attributes in js, when view creates
    Last edited by tanya; 07-05-2017, 08:02 AM.

    Comment


    • #3
      How can I extend the js the Contact detail view? Would I need to copy all the contact files from the CRM module into custom?

      Or is it possible to add a global js hook in the afterRender?

      Thanks,
      Stephen

      Comment


      • #4
        Hello


        I need to edit a view in EspoCrm. Should i inherit it from excisting, or just edit? Used documentation, but nothing happens. I added views and recordViews fields in custom/Espo/Custom/Resources/met...


        What do you mean "global hook"? You can extend other view and overrite only methods you want to change

        Comment


        • #5
          thank you very much. I missed configured the clientDefs. I will give this another try.

          For global hook as in application level. But this won't be necessary.

          Thanks again for your help,
          Stephen

          Comment


          • #6
            Got it working, here is what I used In case anyone else wants to do something similar.

            eg: /#Contact/create?firstName=first&lastName=last&emailAddress= test@test.test
            Code:
                    afterRender: function () {
                        Dep.prototype.afterRender.call(this);
            
                        hash = location.hash;
                        if (hash.indexOf('?') == -1) {
                            return;
                        }
                        prePop = hash.split('?');
                        prePopVars = prePop[1].split('&');
                        for (var i = 0,len=prePopVars.length;i<len;i++) {
                            keyValue = prePopVars[i].split('=');
                            //find firstName / lastName fields
                            var fieldElement = this.$el.find('input[name="'+keyValue[0]+'"]');
                            if (fieldElement.length==0){
                                // find emailAddress field
                                fieldElement = this.$el.find('div[data-name="'+keyValue[0]+'"] input');
                            }
                            fieldElement.val(keyValue[1]);
                        }
            
                    }

            Comment

            Working...
            X