After linking Email field to Compose Email create when i edit or save email link is not working

Hi Friends

My first question Created Custom Field of Email and i want it to link to Compose Email create

After linking Email field to Compose Email create when i edit or save email link is not working

Thanks in Advance Ramana Raju Santhana Mehul  Bhandari Alan Apter

Regards

Syed

  • Hi Sayad Sharif

    Here is the full working code:

    In custom/modules/Cases/clients/base/views/record/record.js file add code as:

    ({
        extendsFrom: 'RecordView',
        initialize: function(options) {       
            this._super('initialize', [options]);
            this.on("render",this.emailAsLink,this);        
            this.events['click a[name=email_compose]'] = 'openComposerModal';
            this.events['click a[name=cancel_button]'] = 'linkCancel'; 
            this.events['click a[name=save_button]'] = 'linkCancel'; 
        },  
        emailAsLink: function(){
              var emailtoLink = $("span[data-fieldname='your-custom-fieldname'] span div").text();
              var rLink = '<a data-event="button:email_compose:click" href="javascript:void(0)" rel="tooltip" data-placement="bottom" title="'+emailtoLink+'" name="email_compose">'+emailtoLink+'</a>';         
              $("span[data-fieldname='your-custom-fieldname'] span div").html(rLink);
             
         },
         linkCancel: function(){           
              this.render();          
         },
        openComposerModal: function(){         
              var emailAddress = this.model.get('your-custom-fieldname');
              var caseName = '[CASE:'+this.model.get('case_number')+'] '+this.model.get('name');    
              //console.log("emailAddress: ",emailAddress);    
              toAddresses =({
                email: emailAddress,
                module: 'Contacts'           
              });
              console.log("toAddresses: ",toAddresses);    
              options = ({
                   to_addresses: toAddresses,
                            subject: caseName
              });
              app.drawer.open({
                layout:'compose',
                context:{
                   create: true,
                   prepopulate: options,
                   module:'Emails',
                 }
              });
         }
    })

    Hope this Helps..

    Best Regards

    S Ramana Raju

  • Hi Sayad Sharif

    I tried in my local and its working for me.

    Okay.. Take your own time.

    Best Regards

    S Ramana Raju