function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Dmytro DovbiiDmytro Dovbii 

Generate activation url which runs some logic on SF side

Hi Folks!
I want to have some button on Opportunity page which will generate some temporary link and send it to a prospect via mail.
Once prospect clicks this link, some apex code should be triggered on Salesforce side.
is it possible?
Thanks! 

Bhargav vaishnav 2Bhargav vaishnav 2
Hello, 

Greeting from Bhargav 

As I try to understand your question and wrote one code for it. If its working fine than mark as good 


trigger SendEmail on Sent_Feedback__c (after insert) {
   
        set<id> ContactId = new set<id>();
 
  // Step 0: Create a master list to hold the emails we'll send
  List<Messaging.SingleEmailMessage> mails =
  new List<Messaging.SingleEmailMessage>();
 
  for (Sent_Feedback__c myContact : Trigger.new) {
    
    if (myContact.Contact__c != null )
    {
          ContactId.add(myContact.Contact__c);
    }
         Contact con = [Select firstname,lastname,email,id,name,MobilePhone from Contact where id in :ContactId];
      // Step 1: Create a new Email
      Messaging.SingleEmailMessage mail =  new Messaging.SingleEmailMessage();
   
      // Step 2: Set list of people who should get the email
      List<String> sendTo = new List<String>();
      sendTo.add(con.email);
      mail.setToAddresses(sendTo);
   
      // Step 3: Set who the email is sent from
      mail.setReplyTo('utkarsha.up10@gmail.com');
      mail.setSenderDisplayName('Utz patil');
   
      // (Optional) Set list of people who should be CC'ed
      List<String> ccTo = new List<String>();
      ccTo.add('puja.patil@aress.com');
      mail.setCcAddresses(ccTo);
 
      // Step 4. Set email contents - you can use variables!
      mail.setSubject('URGENT BUSINESS PROPOSAL');
      String body = 'Dear ' + con.FirstName;
     
      mail.setHtmlBody(body);
   
      // Step 5. Add your email to the master list
      mails.add(mail);
        Messaging.sendEmail(mails);
    }
  }
Bhargav vaishnav 2Bhargav vaishnav 2
For link 

Vf page:
<apex:page action={!redirect}> </apex:page>



Contoller:
public class handle_controller{

public PageReference redirect(){

String licenceid = apexpages.getcurrentpage().getparameters().get('id');

//select a licence file with that id //update this licence file which has a custom field isclicked__c //and after that redirect user to this licence attachement file Pagereference pg = new pagereference('/servlet/....'); Pg.isredirect(true);

return pg; } }
Dmytro DovbiiDmytro Dovbii

Hi Bhargav!

 

As I understood, your fist comment show how can I send an email. This is clear. But I didn't get your second comment. Could you please elaborate?