Find your content:

Search form

You are here

how to get the value of a variable from save method

 
Share

I'm getting value of billing.billingfirstname in save method.Now I need to pass this value into another method....How can I get it.here is the code

 @future(callout=true)
 public static void sendEmail(string emailcontentbody,string template,string useremail,string textname){
  Messaging.singleEmailMessage email1 = new Messaging.singleEmailMessage();
  Invoice_Setting__c SettingsRec = [select SiteUrl__c from Invoice_Setting__c limit 1 ];
          string record = Settingsrec.SiteUrl__c; 
   *record+='?fname1='+billing.billingfirstName;*
  email1.setplaintextbody(textname+record);
       email1.setSubject('Response');
       email1.setToAddresses(new string[] {useremail});
         Messaging.sendEmailResult[] res = Messaging.sendEmail(new Messaging.singleEmailMessage[]{email1});
       system.debug('resulttt'+res);
}

How do I pass the value of billing.billingfirstName which I got from save method into record.


Attribution to: Eagerin Sf

Possible Suggestion/Solution #1

The apex PageReference class is useful for building up and manipulating URLs.

You could try something like:

@future(callout=true)
public static void sendEmail(string emailcontentbody,string template,string useremail,string textname){

    // missing code that creates the billing object

    Invoice_Setting__c SettingsRec = [select SiteUrl__c from Invoice_Setting__c limit 1 ];
    PageReference pageRef = new PageReference(SettingsRec.SiteUrl__c);
    Map<String, String> params = pageRef.getParameters();
    params.add('fname1', billing.billingfirstName);
    string urlForEmail = pageRef.getUrl();

    Messaging.singleEmailMessage email1 = new Messaging.singleEmailMessage();
    email1.setPlainTextBody(textname + '\n\n' +
                            record);
    email1.setSubject('Response');
    email1.setToAddresses(new string[] {useremail});
    Messaging.sendEmailResult[] res = Messaging.sendEmail(new Messaging.singleEmailMessage[]{email1});
}

If you want the URL to be a hyperlink use setHtmlBody rather than setPlainTextBody.


Attribution to: Daniel Ballinger
This content is remixed from stackoverflow or stackexchange. Please visit https://salesforce.stackexchange.com/questions/4238

My Block Status

My Block Content