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

Hi Team,

I have created a custom field as Email of datatype is TextField in Cases Module.

When am Creating a new record in Cases Module am enter email id and saving the record.

Now my question is when i open the record i want:

1. Email id which i enter should be in Link.

2. When i click this email link it should open Create Compose Email with already filled value in Subject field.

Thanks in Advance.

Regards

Syed

Tevfik Tümer, Ramana Raju Santhana, Angel Magana

Parents Reply Children
  • Hi Sayad Sharif

    Once try following 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';
        },  
        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);
              
         },
        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 Ramana Raju Santhana

    Thanks for the code.

    I will try and let you know.

    Once again thanks in Advance Ramana

    Regards

    Syed Sharif

  • Hi Ramana Raju Santhana

    Its working like a charm Ramana.

    I thought i wont be solving this problem, but with the help of your code i did it.

    Sirji tussi great ho..!!

    A small question.. when i load the record at first time its working.

    But when i click on Edit record and save or cancel button then its not working.

    Can you also solve this one Ramana.

    Anyway Thanks a lot for full working code.

    Regards

    Syed Sharif