Sunday 8 February 2015

Trigger on task object by using messaging class

Require ment:
 
/* whenever task is completed we need send
confirmation mail to related account....

*/

Trigger Send_Email on Task (after insert,after update) {

list<account> acc;

for(Task tsk : Trigger.New)
{

if(tsk.status == 'completed'){

acc = [select name,email__C from account where id =: tsk.whatid];
}
}
for(account a :acc){
if(a.email__c != null){

string mal = a.email__C;
Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
String[] toAddresses = new String[] {mal};
mail.setToAddresses(toAddresses);  
mail.setSubject('A task owned by you has been updated');  
String body = 'Dear ' + a.name + ', ';
        body += 'I am informing about your task .';
        body += 'I am varaprasad CEO of salesforce.';
        body += 'your task is completed succesfully.. ';
       
mail.setHtmlBody(body);

Messaging.SendEmail(new Messaging.SingleEmailMessage[] {mail});


}
}
}

                             

Tuesday 3 February 2015

Global Variables In salesforce

Use global variables to reference general information about the current user and your organization on a page.

More Info about Global variables follow below link.

http://www.salesforce.com/docs/developer/pages/Content/pages_variables_global.htm




                       Global Variable info on visual force page

 

<apex:page standardController="Account" extensions="DemoController" sidebar="false"> 
<apex:form >  

   <apex:pageblock >  
       <center>

            <b> Userid :  <apex:outputText value="{!LoggedInUSerId}"/> <br></br> </b>

           <b> User Name : <apex:outputText value="{!uname}"/> <br></br> </b>

           <b> profilename : <apex:outputText value="{!$Profile.Name}"></apex:outputText></b>

           <b> User Name : <apex:outputText value="{!$User.LastName}"/> <br></br> </b> 

           <b> User Role: <apex:outputText value="{!$UserRole.Name}"/> <br></br> </b>

            <b> Static Recourse : <apex:outputText value="{!$Resource.bulbon}"/> <br></br> </b>

           </center>        

    </apex:pageblock>

  </apex:form>

</apex:page>

 ----------------------------------------------------------------------------------------------------------------

public class DemoController {

    public id LoggedInUSerId{get;set;}
     public string uname{get;set;}
    public string pname{get;set;}

  public DemoController(ApexPages.StandardController controller) {
     LoggedInUSerId = userinfo.getuserid();
     uname = userinfo.getusername();

    }
}
 

Complete Salesforce CPQ training Free videos

Salesforcestart:: We are excited to announce that our YouTube channel, Salesforcestart, is your one-stop-shop for all things Salesforce CPQ!...