Announcement

Collapse
No announcement yet.

Templates for Call/Meeting Activities

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

  • Templates for Call/Meeting Activities

    Does anyone have any ideas on how I could implement templates for calls? Especially the description field. That is, the user can select from a predefined list of descriptions for what a phone call or meeting conversation was about, rather than having to type all of it each time.

    I've add a look at the Email Templates, but I can't work out how the view is getting the list of templates.

    Cheers.




  • #2
    Hello axyl
    you can create new entity like CallTemplate which will contain all templates. Then you can populate a template with javascript: https://www.youtube.com/watch?v=MdaJIGxOWpU

    Comment


    • #3
      You could:
      1: make a browser extension containing various templates in the context menu
      2: Use dropdown actions to make a list of predefined templates, this is what I use for common email templates
      3: Modal Dialog with dropdown enum option pasting the call/meeting template
      These are probably the easiest options.

      Comment


      • #4
        If you don't want to be a pro coder like these two, one other option is to create a new field, call it, "Template". Add drop down to it, then create Formula base on that. This still require coding but Formula code is easier than 'file code'

        If you planning to do emillod method, I made 2 post in my Learning thread with my own code which you can use as reference.

        Comment


        • Kharg
          Kharg commented
          Editing a comment
          Yes, this may be an easier alternative

      • #5
        Thanks Everyone,

        Some good ideas, I'll have a think about it and report back.

        Comment


        • #6
          I ended up using a dynamic handler with emillod's idea of a separate entity that has the templates stored... This is just a prototype at the moment, but others might find it interesting.

          The Call entity has an extra enum called Template. This code will populate that enum with the names of records in the CallTemplate entity. Selecting a template will then load the description field of the Call Template record into the Call's description field.

          Code:
          define('custom:views/call-templates-handler', ['dynamic-handler'], function (Dep) {
          
              return Dep.extend({
          
                  init: function () {
                      this.templates= [];  // Will contain the list of available call templates.
                      this.loadTemplates();
          
                      this.recordView.listenTo(
                          this.model,
                          'change:template',
                          this.controlFields.bind(this),
                      );
                  },
          
                  loadTemplates: function() {
                      // Load up the templates available.
                      // TODO: Pagination etc...maybe ajax instead?
                      this.recordView.getCollectionFactory().create('CallTemplate')
                      .then(collection=> {
                          collection.data.select='name,description'; // don't need all the fields...
                          return collection.fetch();
                      })
                      .then(templates=> {
                          console.log(JSON.stringify(templates, null, 2));
                          this.templates= templates.list;
                          let templateNames=[''];  //Empty by default.  This will contain the list of template names
                          this.templates.forEach((template)=>{
                              console.log(template);
                              templateNames.push(template.name);
                          });
                          // Can we add an id???
                          return this.recordView.setFieldOptionList('template', templateNames);
                      });
                  },
          
                  controlFields: function () {
                      let selectedTemplate = this.recordView.model.get('template') || "";
                      console.log(`Selected template is ${selectedTemplate}`);
                      if (selectedTemplate!= '') {
                          // Looks like we're searching by name here to find the matching template...hmmm
                          console.log(this.recordView);
                          for (let loopTemplates= 0;loopTemplates< this.templates.length; loopTemplates++) {
                              if (this.templates[loopTemplates].name=== selectedTemplate) {
                                  this.model.set('description', this.templates[loopTemplates].description);  //Could do a handlebars thing here.
                                  break;
                              }
                          }
                      };
                  },
              });
          });
          
          ​

          Comment


          • telecastg
            telecastg commented
            Editing a comment
            Don't forget to define the "template" field "options" value in the Custom Call entityDefs metadata file as null otherwise the 7.2 validation enforcement mechanism might throw a validation error because it expects only values that are predefined in entityDefs by default.
            Last edited by telecastg; 11-17-2022, 05:01 AM.

          • espcrm
            espcrm commented
            Editing a comment
            Good job axyl. I added your post to the 'wiki' and realize there was 3 other thread about dynamic handler. It may or may not help you by reading through them for reference.

            You can search for 'dyanmic handler' here: https://github.com/o-data/EspoCRM-Le...nd-Design/wiki
        Working...
        X