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

  • Hi Sayad Sharif

    Sorry for the late reply.

    Are you able to manage to solve this out.

    Best Regards

    S Ramana Raju

  • Hi Ramana Raju Santhana

    Finally one reply for my question.

    Nope, It will be helpful if you give answer Ramana.

    Thanks in Advance.

    Regards

    Syed

  • Hi Sayad Sharif

    1. On render call a function and in that function define your logic such that Email custom field should be append with an anchor tag and give unique name to that anchor tag. ( Now you can see your Email field as Link ).

    2. When you click the Email filed Link trigger an event and calll a function in that function again write logic such that :

    Opening Compose Email - get it by opening a drawer of compose and pass the values which you want to fill in that compse email.

    3. Do Quick R&R

    Dats it.

    Let me know for further Help..!!

    Note: All above code do it in custom/modules/Cases/clients/base/views/record/record.js file

    Best Regards

    S Ramana Raju

  • Hi Ramana Raju Santhana

    What an Idea sirji

    I will be thankful if you give the code, mean while i will try from my side as you suggested.

    Thanks in Advance.

    Regards

    Syed Sharif

  • 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