Parse imprint to create account or contact

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • philzo
    Junior Member
    • May 2024
    • 7

    Parse imprint to create account or contact

    Hello,
    when creating an account or a contact, I find it tedious to populate each field manually.
    In my previous CRM I simply used to click "Create Account from Clipboard" and the system would attempt to parse the free text into the respective field.
    This works especially well when copying the imprint text from a website.

    Cheers,
    Phil
  • rabii
    Active Community Member
    • Jun 2016
    • 1250

    #2
    Which CRM you used before ?

    I think you ca build such feature using this

    Rabii
    Web Dev

    Comment

    • philzo
      Junior Member
      • May 2024
      • 7

      #3
      Thanks Rabii,
      I will investigate what the ModelDefaultsPreparator does.
      We used to use Cobra CRM but I prefer EspoCRM

      Comment

      • philzo
        Junior Member
        • May 2024
        • 7

        #4
        Hi Rabii,
        do you know if this is this how the ModelDefaultsPreparator is to be used?

        ../clientDef/Account.json
        Code:
        "modelDefaultsPreparator": "create-from-clipboard-module:defaults-preparator",
        ../src/defaults-preparator.js
        Code:
        define('create-from-clipboard-module:create-from-clipboard-handler', ['handlers/model/defaults-preparator'], (Dep) => {
          return class extends Dep {
            prepare(model) {
              model.name = "Company Name.. Will be fetched from Clipboard";
              return Promise.resolve(model);
            }
          };
        });​

        Comment

        • rabii
          Active Community Member
          • Jun 2016
          • 1250

          #5
          Hey,

          You can access model attributes as model.attributes.attribueName and promise needs to resolve the attributes see the class here



          This is how it could be used
          PHP Code:
          define('create-from-clipboard-module:create-from-clipboard-handler', ['handlers/model/defaults-preparator'], function (DefaultsPreparator) {
          
              return DefaultsPreparator.extend({
                
                prepare: function(model) {
                    const name = model.attributes.name;
                    name = "Company Name.. Will be fetched from Clipboard";
                    
                    const attributes = {};
          
                    
                    attributes.name = name;
                    
                    return Promise.resolve(attributes);
                }
                
              });
          });

          I hope this helps
          Rabii
          Web Dev

          Comment

          Working...