- Gattam Rakesh (SFDC)
- NEWBIE
- 15 Points
- Member since 2014
- Sfdc Developer
-
ChatterFeed
-
0Best Answers
-
0Likes Received
-
0Likes Given
-
11Questions
-
16Replies
How to send a email in trigger
Hi All i have a requirement like this an lead should be created once the lead created a contact should be created and lead should be deleted
1st part is working fine and for second part:
if we have exisitng contact with same email and an email should be sent for the user and it should be updates with exisitng contact
Can any one help with this :
Please see my code below :
trigger CreateContactTest on Lead (After Insert)
{
//Map<string,Id> mapaddress = New Map<String,Id>();
List<Lead> toDelete =New List<Lead>();
Set<string> Email= new Set<string>();
List<Contact>Contacts=[Select Id,Email from Contact Where Email=:Email];
List <Contact>Con= new List<Contact>();
For( Lead LD:Trigger.new)
{
Contact cc = New Contact();
cc.FirstName= LD.FirstName;
cc.LastName=LD.LastName;
// cc.Name=LD.Name;
cc.Salutation=LD.Salutation;
cc.Email=LD.Email;
cc.Title=LD.Title;
cc.Phone=LD.Phone;
Con.add(cc);
Todelete.Add(LD);
}
insert con;
if(todelete.size()>0)
Delete [Select ID from lead where Id In:ToDelete];
}
1st part is working fine and for second part:
if we have exisitng contact with same email and an email should be sent for the user and it should be updates with exisitng contact
Can any one help with this :
Please see my code below :
trigger CreateContactTest on Lead (After Insert)
{
//Map<string,Id> mapaddress = New Map<String,Id>();
List<Lead> toDelete =New List<Lead>();
Set<string> Email= new Set<string>();
List<Contact>Contacts=[Select Id,Email from Contact Where Email=:Email];
List <Contact>Con= new List<Contact>();
For( Lead LD:Trigger.new)
{
Contact cc = New Contact();
cc.FirstName= LD.FirstName;
cc.LastName=LD.LastName;
// cc.Name=LD.Name;
cc.Salutation=LD.Salutation;
cc.Email=LD.Email;
cc.Title=LD.Title;
cc.Phone=LD.Phone;
Con.add(cc);
Todelete.Add(LD);
}
insert con;
if(todelete.size()>0)
Delete [Select ID from lead where Id In:ToDelete];
}
- Gattam Rakesh (SFDC)
- June 07, 2016
- Like
- 0
- Continue reading or reply
Facing issue in Translation
Hi All
I have an issue with Translation i can see one field on Account Page layout which spelt wrongly in Italian language can any one help me out how can we change it ? Do we need to Raise a case for Salesforce or we can directly change it?
Thanks
I have an issue with Translation i can see one field on Account Page layout which spelt wrongly in Italian language can any one help me out how can we change it ? Do we need to Raise a case for Salesforce or we can directly change it?
Thanks
- Gattam Rakesh (SFDC)
- May 17, 2016
- Like
- 0
- Continue reading or reply
How to inactive a user using batch apex if the user has not logged for 90days??
global class Inactiveuser implements Database.Batchable<sObject>
{
global Database.QueryLocator start(Database.BatchableContext BC)
{
String query = 'SELECT Id,Name,Isactive From User WHERE Isactive=TRUE';
return Database.getQueryLocator(query);
}
global void execute(Database.BatchableContext BC, List<user> scope)
{
for(user a : scope)
{
if(a.LastLoginDate> )
{
}
}
update scope;
}
global void finish(Database.BatchableContext BC)
{
}
}
{
global Database.QueryLocator start(Database.BatchableContext BC)
{
String query = 'SELECT Id,Name,Isactive From User WHERE Isactive=TRUE';
return Database.getQueryLocator(query);
}
global void execute(Database.BatchableContext BC, List<user> scope)
{
for(user a : scope)
{
if(a.LastLoginDate> )
{
}
}
update scope;
}
global void finish(Database.BatchableContext BC)
{
}
}
- Gattam Rakesh (SFDC)
- October 19, 2015
- Like
- 0
- Continue reading or reply
Date Function in Formulaes
Hai all I have two Fields Start date and End Date if Start Date and End date lies Between Total status Should be updated to Active
How to Do it?
Thanks In Advance
How to Do it?
Thanks In Advance
- Gattam Rakesh (SFDC)
- May 30, 2015
- Like
- 0
- Continue reading or reply
How to popup a Vf Page From a Vf Page
Hai all
can any one explain me how to populate a vf page from a vf page for example i have two pages page1 and page2 in page1 we will be having one button open Page2 by clicking that page2 should populate in page1
Thanks in advance
can any one explain me how to populate a vf page from a vf page for example i have two pages page1 and page2 in page1 we will be having one button open Page2 by clicking that page2 should populate in page1
Thanks in advance
- Gattam Rakesh (SFDC)
- April 06, 2015
- Like
- 0
- Continue reading or reply
How to write test class for select list and select Option
Hai all can any one tell me how to write test class for select list and select option?
- Gattam Rakesh (SFDC)
- April 02, 2015
- Like
- 0
- Continue reading or reply
How to Create a same task on other Object
Hai all
Can any one Explain me how to create a same task on the Other Custom Object automatically??
Here is my Requirement
I have one custom Object Retailer__c and custom Button on Retailer Object Take Order once we click on it A task should be created on retailer and same task should be created on Account for me now task is creating on both account and retailer but fileds are not mapping can any 1 help me out here is my code:
Public PageReference Save()
{
odd.Distributor__c=acc.Id;
odd.Retailer__c=ret.id;
Insert odd;
task1.Subject='Order/Visit' ;
task1.Status__c='Order Taken';
task1.Whatid=ret.id;
task1.Date__c=odd.Order_Date__c;
task1.Comments__c=ret.Comments__c;
task1.Country__c=ret.Billing_Country__c;
task1.State__c= ret.Billing_State__c;
task1.City__c=ret.Billing_City__c;
task1.Street__c=ret.Billing_Street__c;
task1.Zip_Postal_Code__c=ret.Billing_Zip_Postal_Code__c;
task1.Province__c=ret.Billing_Province__c;
Insert task1;
task2.Whatid=acc.id;
Insert task2;
Can any one Explain me how to create a same task on the Other Custom Object automatically??
Here is my Requirement
I have one custom Object Retailer__c and custom Button on Retailer Object Take Order once we click on it A task should be created on retailer and same task should be created on Account for me now task is creating on both account and retailer but fileds are not mapping can any 1 help me out here is my code:
Public PageReference Save()
{
odd.Distributor__c=acc.Id;
odd.Retailer__c=ret.id;
Insert odd;
task1.Subject='Order/Visit' ;
task1.Status__c='Order Taken';
task1.Whatid=ret.id;
task1.Date__c=odd.Order_Date__c;
task1.Comments__c=ret.Comments__c;
task1.Country__c=ret.Billing_Country__c;
task1.State__c= ret.Billing_State__c;
task1.City__c=ret.Billing_City__c;
task1.Street__c=ret.Billing_Street__c;
task1.Zip_Postal_Code__c=ret.Billing_Zip_Postal_Code__c;
task1.Province__c=ret.Billing_Province__c;
Insert task1;
task2.Whatid=acc.id;
Insert task2;
- Gattam Rakesh (SFDC)
- March 19, 2015
- Like
- 0
- Continue reading or reply
How to use Java script in Visual force page
Hai all
Can any one tell me how to use java script in visual force page by using static resources
Can any one tell me how to use java script in visual force page by using static resources
- Gattam Rakesh (SFDC)
- February 27, 2015
- Like
- 0
- Continue reading or reply
How to override a standard Button with a popup message
Hello all ,
Can any one tell me how to override a standard button with popup message
for example if the user click on new button in Account Page he need to get a popup message "Sorry you account create a new Account"
Can any one tell me how to override a standard button with popup message
for example if the user click on new button in Account Page he need to get a popup message "Sorry you account create a new Account"
- Gattam Rakesh (SFDC)
- February 26, 2015
- Like
- 0
- Continue reading or reply
Visual Force Page Making Header to be freeze
I have a Bulit a visual Force page I have Got all the contact list by using recordsetVar now my requirment is when i scroll down the header should be Freezed it means it should not move all the records should move down when we scroll here is my code
<apex:page standardController="Contact" recordSetVar="contacts" >
<apex:form >
<apex:pageBlock title="Contacts List">
<apex:outputPanel layout="block" style="overflow:auto;width:750px;height:250px" >
<style>
</style>
<apex:pageBlockTable value="{! contacts }" var="Contact1">
<apex:column value="{! Contact1.FirstName }" />
<apex:column value="{! Contact1.LastName }"/>
<apex:column value="{! Contact1.Email }"/>
<apex:column value="{! Contact1.Account.Name }"/>
<apex:column headerValue="Phone">
<apex:inputText value="{!Contact1.Phone}" size="10"/>
</apex:column>
</apex:pageBlockTable>
</apex:outputPanel>
</apex:pageBlock>
</apex:form>
</apex:page>
<apex:page standardController="Contact" recordSetVar="contacts" >
<apex:form >
<apex:pageBlock title="Contacts List">
<apex:outputPanel layout="block" style="overflow:auto;width:750px;height:250px" >
<style>
</style>
<apex:pageBlockTable value="{! contacts }" var="Contact1">
<apex:column value="{! Contact1.FirstName }" />
<apex:column value="{! Contact1.LastName }"/>
<apex:column value="{! Contact1.Email }"/>
<apex:column value="{! Contact1.Account.Name }"/>
<apex:column headerValue="Phone">
<apex:inputText value="{!Contact1.Phone}" size="10"/>
</apex:column>
</apex:pageBlockTable>
</apex:outputPanel>
</apex:pageBlock>
</apex:form>
</apex:page>
- Gattam Rakesh (SFDC)
- February 05, 2015
- Like
- 0
- Continue reading or reply
A case and a contact should be created when user clicks on submit for a existing user directly a case should be crerates under his contact can any one please help me this
public with sharing class CaseEmailClass
{ Public Contact cc{get;set;}
Public list<Contact> cn{get;set;}
public String Comment { get; set; }
public String Emailid { get; set; }
public String ContactNo { get; set; }
public String Name { get; set; }
public PageReference submit()
{
cn=[SELECT Id,Email FROM Contact];
if(cn.Email==EmailId)
{
Case c=new Case();
c.Status='New';
c.ContactId=cn.id;
c.Priority='High';
c.Description=Comment;
c.Subject='A New Case Has Been Rasied';
insert c;
}
List<Messaging.SingleEmailMessage> mails = new List<Messaging.SingleEmailMessage>();
Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
mail.setToAddresses(new String[] {'mail2gattam@gmail.com'});
mail.setSubject('A New Case Has Been Raised');
String table = '';
String body='';
/* table=table+'Name:'+Name+'<br/>';
table=table+'ContactNo:'+ContactNo+'<br/>';
table=table+'Email Id:'+Emailid+'<br/>';
table=table+'Comment:'+Comment+'<br/>'; */
table = table + '<b><table align="center" width="50%" border: 1px solid black;>';
table = table + '<tr>';
table = table + '<td width="25%" align="center"><b>Name: </b>'+Name+'</td>';
table = table + '</tr>';
table = table + '<tr>';
table = table + '<td width="25%" align="center"><b>ContactNo: </b>'+ContactNo+'</td>';
table = table + '</tr>';
table = table + '<tr>';
table = table + '<td width="25%" align="center"><b>Email Id: </b>'+Emailid+'</td>';
table = table + '</tr>';
table = table + '<tr>';
table = table + '<td width="25%" align="center"><b>Comment: </b>'+Comment+'</td>';
table = table + '</tr>';
body=table;
mail.setHTMLbody(body);
Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail });
// return null;
Contact con= New Contact();
con.LastName=Name;
con.MobilePhone=ContactNo;
con.Email=EmailId;
insert con;
Case c=new Case();
c.Status='New';
c.ContactId=con.id;
c.Priority='High';
c.Description=Comment;
c.Subject='A New Case Has Been Rasied';
insert c;
return null;
}
}
{ Public Contact cc{get;set;}
Public list<Contact> cn{get;set;}
public String Comment { get; set; }
public String Emailid { get; set; }
public String ContactNo { get; set; }
public String Name { get; set; }
public PageReference submit()
{
cn=[SELECT Id,Email FROM Contact];
if(cn.Email==EmailId)
{
Case c=new Case();
c.Status='New';
c.ContactId=cn.id;
c.Priority='High';
c.Description=Comment;
c.Subject='A New Case Has Been Rasied';
insert c;
}
List<Messaging.SingleEmailMessage> mails = new List<Messaging.SingleEmailMessage>();
Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
mail.setToAddresses(new String[] {'mail2gattam@gmail.com'});
mail.setSubject('A New Case Has Been Raised');
String table = '';
String body='';
/* table=table+'Name:'+Name+'<br/>';
table=table+'ContactNo:'+ContactNo+'<br/>';
table=table+'Email Id:'+Emailid+'<br/>';
table=table+'Comment:'+Comment+'<br/>'; */
table = table + '<b><table align="center" width="50%" border: 1px solid black;>';
table = table + '<tr>';
table = table + '<td width="25%" align="center"><b>Name: </b>'+Name+'</td>';
table = table + '</tr>';
table = table + '<tr>';
table = table + '<td width="25%" align="center"><b>ContactNo: </b>'+ContactNo+'</td>';
table = table + '</tr>';
table = table + '<tr>';
table = table + '<td width="25%" align="center"><b>Email Id: </b>'+Emailid+'</td>';
table = table + '</tr>';
table = table + '<tr>';
table = table + '<td width="25%" align="center"><b>Comment: </b>'+Comment+'</td>';
table = table + '</tr>';
body=table;
mail.setHTMLbody(body);
Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail });
// return null;
Contact con= New Contact();
con.LastName=Name;
con.MobilePhone=ContactNo;
con.Email=EmailId;
insert con;
Case c=new Case();
c.Status='New';
c.ContactId=con.id;
c.Priority='High';
c.Description=Comment;
c.Subject='A New Case Has Been Rasied';
insert c;
return null;
}
}
- Gattam Rakesh (SFDC)
- January 03, 2015
- Like
- 0
- Continue reading or reply
Date Function in Formulaes
Hai all I have two Fields Start date and End Date if Start Date and End date lies Between Total status Should be updated to Active
How to Do it?
Thanks In Advance
How to Do it?
Thanks In Advance
- Gattam Rakesh (SFDC)
- May 30, 2015
- Like
- 0
- Continue reading or reply
How to change the position of input text fields in Visualforce
I am try to change the positon of input text fields dynamically.i.e city3 in first position .
<apex:inputText value="{!city1}" /> <apex:inputText value="{!city2}" /> <apex:inputText value="{!city3}" />
- janardhan m
- April 08, 2015
- Like
- 0
- Continue reading or reply
How to write test class for select list and select Option
Hai all can any one tell me how to write test class for select list and select option?
- Gattam Rakesh (SFDC)
- April 02, 2015
- Like
- 0
- Continue reading or reply
How to override a standard Button with a popup message
Hello all ,
Can any one tell me how to override a standard button with popup message
for example if the user click on new button in Account Page he need to get a popup message "Sorry you account create a new Account"
Can any one tell me how to override a standard button with popup message
for example if the user click on new button in Account Page he need to get a popup message "Sorry you account create a new Account"
- Gattam Rakesh (SFDC)
- February 26, 2015
- Like
- 0
- Continue reading or reply
Visual Force Page Making Header to be freeze
I have a Bulit a visual Force page I have Got all the contact list by using recordsetVar now my requirment is when i scroll down the header should be Freezed it means it should not move all the records should move down when we scroll here is my code
<apex:page standardController="Contact" recordSetVar="contacts" >
<apex:form >
<apex:pageBlock title="Contacts List">
<apex:outputPanel layout="block" style="overflow:auto;width:750px;height:250px" >
<style>
</style>
<apex:pageBlockTable value="{! contacts }" var="Contact1">
<apex:column value="{! Contact1.FirstName }" />
<apex:column value="{! Contact1.LastName }"/>
<apex:column value="{! Contact1.Email }"/>
<apex:column value="{! Contact1.Account.Name }"/>
<apex:column headerValue="Phone">
<apex:inputText value="{!Contact1.Phone}" size="10"/>
</apex:column>
</apex:pageBlockTable>
</apex:outputPanel>
</apex:pageBlock>
</apex:form>
</apex:page>
<apex:page standardController="Contact" recordSetVar="contacts" >
<apex:form >
<apex:pageBlock title="Contacts List">
<apex:outputPanel layout="block" style="overflow:auto;width:750px;height:250px" >
<style>
</style>
<apex:pageBlockTable value="{! contacts }" var="Contact1">
<apex:column value="{! Contact1.FirstName }" />
<apex:column value="{! Contact1.LastName }"/>
<apex:column value="{! Contact1.Email }"/>
<apex:column value="{! Contact1.Account.Name }"/>
<apex:column headerValue="Phone">
<apex:inputText value="{!Contact1.Phone}" size="10"/>
</apex:column>
</apex:pageBlockTable>
</apex:outputPanel>
</apex:pageBlock>
</apex:form>
</apex:page>
- Gattam Rakesh (SFDC)
- February 05, 2015
- Like
- 0
- Continue reading or reply
A case and a contact should be created when user clicks on submit for a existing user directly a case should be crerates under his contact can any one please help me this
public with sharing class CaseEmailClass
{ Public Contact cc{get;set;}
Public list<Contact> cn{get;set;}
public String Comment { get; set; }
public String Emailid { get; set; }
public String ContactNo { get; set; }
public String Name { get; set; }
public PageReference submit()
{
cn=[SELECT Id,Email FROM Contact];
if(cn.Email==EmailId)
{
Case c=new Case();
c.Status='New';
c.ContactId=cn.id;
c.Priority='High';
c.Description=Comment;
c.Subject='A New Case Has Been Rasied';
insert c;
}
List<Messaging.SingleEmailMessage> mails = new List<Messaging.SingleEmailMessage>();
Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
mail.setToAddresses(new String[] {'mail2gattam@gmail.com'});
mail.setSubject('A New Case Has Been Raised');
String table = '';
String body='';
/* table=table+'Name:'+Name+'<br/>';
table=table+'ContactNo:'+ContactNo+'<br/>';
table=table+'Email Id:'+Emailid+'<br/>';
table=table+'Comment:'+Comment+'<br/>'; */
table = table + '<b><table align="center" width="50%" border: 1px solid black;>';
table = table + '<tr>';
table = table + '<td width="25%" align="center"><b>Name: </b>'+Name+'</td>';
table = table + '</tr>';
table = table + '<tr>';
table = table + '<td width="25%" align="center"><b>ContactNo: </b>'+ContactNo+'</td>';
table = table + '</tr>';
table = table + '<tr>';
table = table + '<td width="25%" align="center"><b>Email Id: </b>'+Emailid+'</td>';
table = table + '</tr>';
table = table + '<tr>';
table = table + '<td width="25%" align="center"><b>Comment: </b>'+Comment+'</td>';
table = table + '</tr>';
body=table;
mail.setHTMLbody(body);
Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail });
// return null;
Contact con= New Contact();
con.LastName=Name;
con.MobilePhone=ContactNo;
con.Email=EmailId;
insert con;
Case c=new Case();
c.Status='New';
c.ContactId=con.id;
c.Priority='High';
c.Description=Comment;
c.Subject='A New Case Has Been Rasied';
insert c;
return null;
}
}
{ Public Contact cc{get;set;}
Public list<Contact> cn{get;set;}
public String Comment { get; set; }
public String Emailid { get; set; }
public String ContactNo { get; set; }
public String Name { get; set; }
public PageReference submit()
{
cn=[SELECT Id,Email FROM Contact];
if(cn.Email==EmailId)
{
Case c=new Case();
c.Status='New';
c.ContactId=cn.id;
c.Priority='High';
c.Description=Comment;
c.Subject='A New Case Has Been Rasied';
insert c;
}
List<Messaging.SingleEmailMessage> mails = new List<Messaging.SingleEmailMessage>();
Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
mail.setToAddresses(new String[] {'mail2gattam@gmail.com'});
mail.setSubject('A New Case Has Been Raised');
String table = '';
String body='';
/* table=table+'Name:'+Name+'<br/>';
table=table+'ContactNo:'+ContactNo+'<br/>';
table=table+'Email Id:'+Emailid+'<br/>';
table=table+'Comment:'+Comment+'<br/>'; */
table = table + '<b><table align="center" width="50%" border: 1px solid black;>';
table = table + '<tr>';
table = table + '<td width="25%" align="center"><b>Name: </b>'+Name+'</td>';
table = table + '</tr>';
table = table + '<tr>';
table = table + '<td width="25%" align="center"><b>ContactNo: </b>'+ContactNo+'</td>';
table = table + '</tr>';
table = table + '<tr>';
table = table + '<td width="25%" align="center"><b>Email Id: </b>'+Emailid+'</td>';
table = table + '</tr>';
table = table + '<tr>';
table = table + '<td width="25%" align="center"><b>Comment: </b>'+Comment+'</td>';
table = table + '</tr>';
body=table;
mail.setHTMLbody(body);
Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail });
// return null;
Contact con= New Contact();
con.LastName=Name;
con.MobilePhone=ContactNo;
con.Email=EmailId;
insert con;
Case c=new Case();
c.Status='New';
c.ContactId=con.id;
c.Priority='High';
c.Description=Comment;
c.Subject='A New Case Has Been Rasied';
insert c;
return null;
}
}
- Gattam Rakesh (SFDC)
- January 03, 2015
- Like
- 0
- Continue reading or reply