-
ChatterFeed
-
0Best Answers
-
0Likes Received
-
0Likes Given
-
3Questions
-
3Replies
Custom Domain Setup
Hi Experts,
Hope you all doing well !!!
I want to have our own custom domain which is customDomain.com
For example: Suppose we want to open a site page ‘testPage’ then currently the whole link opens in browser looks like https://salessand-xyz.cs16.force.com/testPage
But we want our custom domain replaces salessand-xyz.cs16.force.com
So the final link we want to have in the address bar of a browser should be http://customDomain.com/testpage not the old link as mentioned above
Can this be achieved, if yes please share the steps.
Thanks,
Prabhata
Hope you all doing well !!!
I want to have our own custom domain which is customDomain.com
For example: Suppose we want to open a site page ‘testPage’ then currently the whole link opens in browser looks like https://salessand-xyz.cs16.force.com/testPage
But we want our custom domain replaces salessand-xyz.cs16.force.com
So the final link we want to have in the address bar of a browser should be http://customDomain.com/testpage not the old link as mentioned above
Can this be achieved, if yes please share the steps.
Thanks,
Prabhata
- Prabhata
- April 06, 2015
- Like
- 0
How to change email Id displayed in from address in a customized email message
Hi Experts,
For example:
Public void SendOrderEmail(){ String Uname, ToAddress; String AccFirstName, AccLastName, ContFirstName, ContLastName; /* Added for UpperCase */ if(ConId==null && AId!=null){ List<Account> acc = [SELECT First_Name__c, Last_Name__c, Email_Address__c FROM Account WHERE Id = :AId limit 1]; /* Added for UpperCase *******************************************Start*/ AccFirstName = acc[0].First_Name__c; AccFirstName = AccFirstName.substring(0,1).toUpperCase() + AccFirstName.substring(1).toLowerCase(); AccLastName = acc[0].Last_Name__c; AccLastName = AccLastName.substring(0,1).toUpperCase() + AccLastName.substring(1).toLowerCase(); Uname = AccFirstName+' '+AccLastName; /* Added for UpperCase ********************************************End*/ // Uname = acc[0].First_Name__c+' '+acc[0].Last_Name__c; ToAddress = acc[0].Email_Address__c; }else{ // List<Contact> con = [SELECT Name, Email_Address__c FROM Contact WHERE Id = :ConId limit 1]; // Uname = con[0].Name; /* Added for UpperCase *******************************************Start*/ List<Contact> con = [SELECT FirstName, LastName, Email_Address__c FROM Contact WHERE Id = :ConId limit 1]; ContFirstName = con[0].FirstName; ContFirstName = ContFirstName.substring(0,1).toUpperCase() + ContFirstName.substring(1).toLowerCase(); ContLastName = con[0].LastName; ContLastName = ContLastName.substring(0,1).toUpperCase() + ContLastName.substring(1).toLowerCase(); Uname = ContFirstName+' '+ContLastName; /* Added for UpperCase ********************************************End*/ ToAddress = con[0].Email_Address__c; } String OrderAmt = String.valueOf(odr.TotalAmount); String EmailContent = '<table style="background: #E32237;color:#fff;">'; EmailContent += '<tr><td colspan=2 style="padding-bottom:10px;font-weight:bold;">Cher '+Uname+',</td></tr>'; EmailContent += '<tr><td colspan=2 style="padding-bottom:5px;">'+Label.Order_Summary_Page_Success_Message+'</td></tr>'; EmailContent += '<tr><td style="font-weight:bold;">'+Label.Order_Summary_Order_Number+'</td><td>'+odr.OrderNumber+'</td></tr>'; // EmailContent += '<tr><td style="font-weight:bold;">'+Label.Order_Summary_Seasonal_Offers+'</td><td>'+odr.Seasonal_Offers__c+'</td></tr>'; // EmailContent += '<tr><td style="font-weight:bold;">'+Label.Order_Summary_Permanent_Offers+'</td><td>'+odr.Permanent_Offers__c+'</td></tr>'; EmailContent += '<tr><td style="font-weight:bold;">'+Label.Order_Summary_Order_Amount+'</td><td>'+OrderAmt.replace('.',',')+'€</td></tr>'; EmailContent += '<tr><td style="font-weight:bold;width: 35%;">'+Label.Order_Summary_Status+'</td><td style="width: 65%;">Commande reçue</td></tr>'; EmailContent += '<tr><td colspan=2 style="padding:10px 0 3px;font-weight:bold;">'+Label.Order_Summary_Page_Order_Products+'</td></tr>'; EmailContent += '<tr><td colspan=2 style="padding-bottom:10px;"><table style="color:#fff;border-collapse: collapse;border-spacing: 2px;" border=0>'; EmailContent += '<tr style="font-weight:bold;background:#B50E20;"><td style="padding:5px">'+Label.Order_Summary_Page_Product+'</td><td style="padding:5px">'+Label.Order_Summary_Page_Product_Code+'</td><td style="padding:5px">'+Label.Order_Summary_Page_Quantity+'</td><td style="padding:5px">'+Label.Order_Summary_Page_Unit_Price+' (€)</td><td style="padding:5px">'+Label.Order_Summary_Page_Total_Price+' (€)</td></tr>'; for(OrderItemWrapperClass oi : OrderItemWrapperList){ String Qty = String.valueOf(oi.Qty); String Prce = String.valueOf(oi.Prce); String Ttl = String.valueOf(oi.Ttl); EmailContent += '<tr style="color:#000;font-size:13px;background:#fff"><td style="padding:5px">'+oi.Prod+'</td><td style="padding:5px">'+oi.PCode+'</td><td style="padding:5px;text-align:right;">'+Qty.replace('.',',')+'</td><td style="padding:5px;text-align:right;">'+Prce.replace('.',',')+'</td><td style="padding:5px;text-align:right;">'+Ttl.replace('.',',')+'</td></tr>'; } String freeSeasonalProduct = String.valueOf(odr.Seasonal_Free_Product__c); String freePermanentProduct = String.valueOf(odr.Permanent_Free_Product__c); String freeSeasonalQuantity = String.valueOf(odr.Seasonal_Offers__c); String freePermanentQuantity = String.valueOf(odr.Permanent_Offers__c); if((freeSeasonalQuantity != null && Integer.valueOf(freeSeasonalQuantity) != 0) || (freePermanentQuantity != null && Integer.valueOf(freePermanentQuantity) !=0)){ EmailContent += '</table><tr><td colspan=2 style="padding:10px 0 3px;font-weight:bold;">'+Label.Order_Summary_Page_Free_Products+'</td></tr>'; EmailContent += '<tr><td colspan=2 style="padding-bottom:10px;"><table style="color:#fff;border-collapse: collapse;border-spacing: 2px;" border=0>'; EmailContent += '<tr style="font-weight:bold;background:#B50E20;"><td style="padding:5px">'+Label.Order_Summary_Page_Product+'</td><td style="padding:5px">'+Label.Order_Summary_Page_Product_Category+'</td><td style="padding:5px">'+Label.Order_Summary_Page_Quantity+'</td></tr>'; if(freeSeasonalQuantity != null && Integer.valueOf(freeSeasonalQuantity) != 0){ EmailContent += '<tr style="color:#000;font-size:13px;background:#fff"><td style="padding:5px">'+freeSeasonalProduct.replace('.',',')+'</td><td style="padding:5px">'+Label.Order_Summary_Seasonal_Offers+'</td><td style="padding:5px;text-align:left;">'+freeSeasonalQuantity.replace('.',',')+'</td></tr>'; } if(freePermanentQuantity != null && Integer.valueOf(freePermanentQuantity) !=0){ EmailContent += '<tr style="color:#000;font-size:13px;background:#fff"><td style="padding:5px">'+freePermanentProduct.replace('.',',')+'</td><td style="padding:5px">'+Label.Order_Summary_Permanent_Offers+'</td><td style="padding:5px;text-align:left;">'+freePermanentQuantity.replace('.',',')+'</td></tr>'; } } EmailContent += '</table><tr><td colspan=2 style="padding-bottom:10px;"><a style="color:#fff;" href="'+Label.Order_Page_Domain_Name+'/OrderCreation?id='+AId+'&cid='+ConId+'">'+Label.Order_Summary_Page_Click_Here+'</a> '+Label.Order_Summary_Page_Clickhere_Message+'</td></tr>'; EmailContent += '<tr><td colspan=2 style="font-weight:bold;">'+Label.Order_Summary_Page_Thanks+',<br/>'+Label.Order_Summary_Page_Mars_Chocolate+' </td></tr>'; EmailContent += '</table>'; Messaging.SingleEmailMessage email = new Messaging.SingleEmailMessage(); email.setToAddresses(new String[] { ToAddress }); email.setSubject(Label.Order_Summary_Subject); email.setHTMLBody(EmailContent); Messaging.sendEmail(new Messaging.Email[] { email }); }In the output, I am getting an email in which I am unable to change the email displayed in From field.
For example:
From: Order Summary Site Guest User to you <xyz@gmail.com> Date: Wed, Jan 28,2015 at 5.24 PM Subject: Sandbox: Order SummaryUsing setSenderDisplayName, setReplyTo, I am able to change "Order Summary Site Guest User to you" part, not "xyz@gmail.com". Is there any way to change the email address appearing by default.
- Prabhata
- January 29, 2015
- Like
- 0
test class
Hi Experts,
I need your help on test coverage for the class "AccountValidation" given below:
Kindly help me out in this.
I need your help on test coverage for the class "AccountValidation" given below:
public class AccountValidation { public Account acc; Public String AccErr1 {get;set;} Public String AccErr4 {get;set;} Public String LoginErr {get;set;} Public String DomainName {get;set;} Public Id AccId {get;set;} Public Id ConId {get;set;} Public List<String> characters; public String input {get; set;} public String result {get; set;} public String char1,char2,char3,char4,char5,char6; Public Decimal CaptchaErr {get; set;} public AccountValidation(ApexPages.StandardController controller) { if(ApexPages.currentPage().getParameters().get('id')!='' && ApexPages.currentPage().getParameters().get('id')!=null) AccId = ApexPages.currentPage().getParameters().get('id'); DomainName = Label.Order_Page_Domain_Name; acc = (Account)controller.getRecord(); CaptchaErr = 0; characters = new List<String>{'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z','1','2','3','4','5','6','7','8','9','0'}; ContactId(); } public PageReference SaveAccount(){ if(acc.Name!='' && acc.Name!=null && acc.City__c!='' && acc.City__c!=null){ if(input!='' && input!=null && input.length() == 6 && input.subString(0,1) == char1 && input.subString(1,2) == char2 && input.subString(2,3) == char3 && input.subString(3,4) == char4 && input.subString(4,5) == char5 && input.subString(5,6) == char6) CaptchaErr = 0; else CaptchaErr = 1; list<Account> accounts = [Select Id, Email_Address__c from Account where Name=:acc.Name and City__c=:acc.City__c limit 1]; list<Contact> contacts = new list<Contact>(); if(acc.Email_Address__c!='' && acc.Email_Address__c!=null && accounts.size()>0) contacts = [Select Id from Contact where AccountId=:accounts[0].Id and City__c=:acc.City__c and Email_Address__c=:acc.Email_Address__c limit 1]; if(contacts.size()>0 && CaptchaErr == 0){ AccErr4 = Label.Order_First_Page_Error4; AccErr1 = ''; } else if(accounts.size()>0 && CaptchaErr == 0){ AccErr1 = Label.Order_First_Page_Error1; AccErr4 = ''; } else{ AccErr1 = AccErr4 = ''; if(CaptchaErr == 0){ insert acc; List<Lead> TransformedLeadsList = new List<Lead>(); list<Lead> leads = [Select Transformed_Date__c from Lead where Company=:acc.Name and City__c=:acc.City__c]; if(leads.size()>0){ for(Lead ld : leads){ ld.Transformed_Date__c = (Date)system.today(); TransformedLeadsList.add(ld); } update TransformedLeadsList; } PageReference orderref = new PageReference(DomainName+'/AccCreation?id='+acc.Id); orderref.setRedirect(true); return orderref; } return null; } } return null; } public PageReference CreateContact(){ if(acc.Name!='' && acc.Name!=null && acc.City__c!='' && acc.City__c!=null){ list<Account> accounts = [Select Id from Account where Name=:acc.Name and City__c=:acc.City__c limit 1]; final String chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz'; String randStr = ''; while (randStr.length() < 6) { Integer idx = Math.mod(Math.abs(Crypto.getRandomInteger()), 62); randStr += chars.substring(idx, idx+1); } Contact con = new Contact(); con.FirstName = acc.First_Name__c; con.LastName = acc.Last_Name__c; con.AccountId = accounts[0].Id; con.Organisation_Type__c = acc.Organisation_Type__c; con.Road__c = acc.Road__c; con.Postal_Code__c = acc.Postal_Code__c; con.Function__c = acc.Function__c; con.Phone_Number__c = acc.Phone_Number__c; con.Email_Address__c = acc.Email_Address__c; con.Password__c = acc.First_Name__c+''+randStr; if(acc.Fax!=null && acc.Fax!='') con.Fax = acc.Fax; if(acc.Opening_Hours__c!=null && acc.Opening_Hours__c!='') con.Opening_Hours__c = acc.Opening_Hours__c; insert con; PageReference conref = new PageReference(DomainName+'/ContactCreation?id='+con.Id); conref.setRedirect(true); return conref; } return null; } public void ContactId(){ if(acc.Name!='' && acc.Name!=null && acc.City__c!='' && acc.City__c!=null && acc.Email_Address__c!='' && acc.Email_Address__c!=null){ list<Contact> cons = [Select Id from Contact where AccountId=:acc.Id and City__c=:acc.City__c and Email_Address__c=:acc.Email_Address__c limit 1]; if(cons.size()>0) ConId = cons[0].Id; } } public PageReference CheckAccount(){ return null; } public Integer randomNumber(){ Integer random = Math.Round(Math.Random() * characters.Size()); if(random == characters.size()){ random--; } return random; } public String getChar1(){ char1 = characters[randomNumber()]; return char1; } public String getChar2(){ char2 = characters[randomNumber()]; return char2; } public String getChar3(){ char3 = characters[randomNumber()]; return char3; } public String getChar4(){ char4 = characters[randomNumber()]; return char4; } public String getChar5(){ char5 = characters[randomNumber()]; return char5; } public String getChar6(){ char6 = characters[randomNumber()]; return char6; } }and the test class which I have started writing but unable to get the control inside CreateContact(). Given below is my test code
@isTest private class Test_AccountValidation{ static testMethod void runTest_AccountValidation(){ PageReference prf = Page.AccLogin; Test.setCurrentPage(prf); // Account acc = new Account(Name = 'Test Account', City__c = 'Test_City', Password__c = 'TestPassword'); // AccountValidation accVal = new AccountValidation(new ApexPages.StandardController(acc)); Account acnt = new Account(Name = 'Test Account', First_Name__c = 'Test FirstName', Last_Name__c = 'Test LastName', Organisation_Type__c = 'Association', Road__c = 'Test Road', Postal_Code__c = '12345', City__c = 'Test City', Function__c = 'other', Phone_Number__c = '1234567890', Email_Address__c = 'Test@testmail.com', Fax = '1234567890', Number_of_Employees__c = 'Between 100 and 500', Opening_Hours__c = 'Monday Morning'); ApexPages.currentPage().getParameters().get('id'); AccountValidation controller = new AccountValidation(new ApexPages.StandardController(acnt)); controller.SaveAccount(); insert acnt; /* AccountValidation controller1 = new AccountValidation(new ApexPages.StandardController(acnt)); Contact con = new Contact(FirstName = 'Test FirstName', LastName = 'Test LastName', Password__c = 'Testcon123', Organisation_Type__c = 'Association', Road__c = 'Test Road', Postal_Code__c = '12345', Function__c = 'other', Phone_Number__c = '1234567890', Email_Address__c = 'Test@testmail.com', Fax = '1234567890', Opening_Hours__c = 'Monday Morning'); insert con; controller1.CreateContact(); */ } }While I uncomment every line in the test class and run it following error is showing as below:
Kindly help me out in this.
- Prabhata
- January 13, 2015
- Like
- 0
Custom Domain Setup
Hi Experts,
Hope you all doing well !!!
I want to have our own custom domain which is customDomain.com
For example: Suppose we want to open a site page ‘testPage’ then currently the whole link opens in browser looks like https://salessand-xyz.cs16.force.com/testPage
But we want our custom domain replaces salessand-xyz.cs16.force.com
So the final link we want to have in the address bar of a browser should be http://customDomain.com/testpage not the old link as mentioned above
Can this be achieved, if yes please share the steps.
Thanks,
Prabhata
Hope you all doing well !!!
I want to have our own custom domain which is customDomain.com
For example: Suppose we want to open a site page ‘testPage’ then currently the whole link opens in browser looks like https://salessand-xyz.cs16.force.com/testPage
But we want our custom domain replaces salessand-xyz.cs16.force.com
So the final link we want to have in the address bar of a browser should be http://customDomain.com/testpage not the old link as mentioned above
Can this be achieved, if yes please share the steps.
Thanks,
Prabhata
- Prabhata
- April 06, 2015
- Like
- 0
How to change email Id displayed in from address in a customized email message
Hi Experts,
For example:
Public void SendOrderEmail(){ String Uname, ToAddress; String AccFirstName, AccLastName, ContFirstName, ContLastName; /* Added for UpperCase */ if(ConId==null && AId!=null){ List<Account> acc = [SELECT First_Name__c, Last_Name__c, Email_Address__c FROM Account WHERE Id = :AId limit 1]; /* Added for UpperCase *******************************************Start*/ AccFirstName = acc[0].First_Name__c; AccFirstName = AccFirstName.substring(0,1).toUpperCase() + AccFirstName.substring(1).toLowerCase(); AccLastName = acc[0].Last_Name__c; AccLastName = AccLastName.substring(0,1).toUpperCase() + AccLastName.substring(1).toLowerCase(); Uname = AccFirstName+' '+AccLastName; /* Added for UpperCase ********************************************End*/ // Uname = acc[0].First_Name__c+' '+acc[0].Last_Name__c; ToAddress = acc[0].Email_Address__c; }else{ // List<Contact> con = [SELECT Name, Email_Address__c FROM Contact WHERE Id = :ConId limit 1]; // Uname = con[0].Name; /* Added for UpperCase *******************************************Start*/ List<Contact> con = [SELECT FirstName, LastName, Email_Address__c FROM Contact WHERE Id = :ConId limit 1]; ContFirstName = con[0].FirstName; ContFirstName = ContFirstName.substring(0,1).toUpperCase() + ContFirstName.substring(1).toLowerCase(); ContLastName = con[0].LastName; ContLastName = ContLastName.substring(0,1).toUpperCase() + ContLastName.substring(1).toLowerCase(); Uname = ContFirstName+' '+ContLastName; /* Added for UpperCase ********************************************End*/ ToAddress = con[0].Email_Address__c; } String OrderAmt = String.valueOf(odr.TotalAmount); String EmailContent = '<table style="background: #E32237;color:#fff;">'; EmailContent += '<tr><td colspan=2 style="padding-bottom:10px;font-weight:bold;">Cher '+Uname+',</td></tr>'; EmailContent += '<tr><td colspan=2 style="padding-bottom:5px;">'+Label.Order_Summary_Page_Success_Message+'</td></tr>'; EmailContent += '<tr><td style="font-weight:bold;">'+Label.Order_Summary_Order_Number+'</td><td>'+odr.OrderNumber+'</td></tr>'; // EmailContent += '<tr><td style="font-weight:bold;">'+Label.Order_Summary_Seasonal_Offers+'</td><td>'+odr.Seasonal_Offers__c+'</td></tr>'; // EmailContent += '<tr><td style="font-weight:bold;">'+Label.Order_Summary_Permanent_Offers+'</td><td>'+odr.Permanent_Offers__c+'</td></tr>'; EmailContent += '<tr><td style="font-weight:bold;">'+Label.Order_Summary_Order_Amount+'</td><td>'+OrderAmt.replace('.',',')+'€</td></tr>'; EmailContent += '<tr><td style="font-weight:bold;width: 35%;">'+Label.Order_Summary_Status+'</td><td style="width: 65%;">Commande reçue</td></tr>'; EmailContent += '<tr><td colspan=2 style="padding:10px 0 3px;font-weight:bold;">'+Label.Order_Summary_Page_Order_Products+'</td></tr>'; EmailContent += '<tr><td colspan=2 style="padding-bottom:10px;"><table style="color:#fff;border-collapse: collapse;border-spacing: 2px;" border=0>'; EmailContent += '<tr style="font-weight:bold;background:#B50E20;"><td style="padding:5px">'+Label.Order_Summary_Page_Product+'</td><td style="padding:5px">'+Label.Order_Summary_Page_Product_Code+'</td><td style="padding:5px">'+Label.Order_Summary_Page_Quantity+'</td><td style="padding:5px">'+Label.Order_Summary_Page_Unit_Price+' (€)</td><td style="padding:5px">'+Label.Order_Summary_Page_Total_Price+' (€)</td></tr>'; for(OrderItemWrapperClass oi : OrderItemWrapperList){ String Qty = String.valueOf(oi.Qty); String Prce = String.valueOf(oi.Prce); String Ttl = String.valueOf(oi.Ttl); EmailContent += '<tr style="color:#000;font-size:13px;background:#fff"><td style="padding:5px">'+oi.Prod+'</td><td style="padding:5px">'+oi.PCode+'</td><td style="padding:5px;text-align:right;">'+Qty.replace('.',',')+'</td><td style="padding:5px;text-align:right;">'+Prce.replace('.',',')+'</td><td style="padding:5px;text-align:right;">'+Ttl.replace('.',',')+'</td></tr>'; } String freeSeasonalProduct = String.valueOf(odr.Seasonal_Free_Product__c); String freePermanentProduct = String.valueOf(odr.Permanent_Free_Product__c); String freeSeasonalQuantity = String.valueOf(odr.Seasonal_Offers__c); String freePermanentQuantity = String.valueOf(odr.Permanent_Offers__c); if((freeSeasonalQuantity != null && Integer.valueOf(freeSeasonalQuantity) != 0) || (freePermanentQuantity != null && Integer.valueOf(freePermanentQuantity) !=0)){ EmailContent += '</table><tr><td colspan=2 style="padding:10px 0 3px;font-weight:bold;">'+Label.Order_Summary_Page_Free_Products+'</td></tr>'; EmailContent += '<tr><td colspan=2 style="padding-bottom:10px;"><table style="color:#fff;border-collapse: collapse;border-spacing: 2px;" border=0>'; EmailContent += '<tr style="font-weight:bold;background:#B50E20;"><td style="padding:5px">'+Label.Order_Summary_Page_Product+'</td><td style="padding:5px">'+Label.Order_Summary_Page_Product_Category+'</td><td style="padding:5px">'+Label.Order_Summary_Page_Quantity+'</td></tr>'; if(freeSeasonalQuantity != null && Integer.valueOf(freeSeasonalQuantity) != 0){ EmailContent += '<tr style="color:#000;font-size:13px;background:#fff"><td style="padding:5px">'+freeSeasonalProduct.replace('.',',')+'</td><td style="padding:5px">'+Label.Order_Summary_Seasonal_Offers+'</td><td style="padding:5px;text-align:left;">'+freeSeasonalQuantity.replace('.',',')+'</td></tr>'; } if(freePermanentQuantity != null && Integer.valueOf(freePermanentQuantity) !=0){ EmailContent += '<tr style="color:#000;font-size:13px;background:#fff"><td style="padding:5px">'+freePermanentProduct.replace('.',',')+'</td><td style="padding:5px">'+Label.Order_Summary_Permanent_Offers+'</td><td style="padding:5px;text-align:left;">'+freePermanentQuantity.replace('.',',')+'</td></tr>'; } } EmailContent += '</table><tr><td colspan=2 style="padding-bottom:10px;"><a style="color:#fff;" href="'+Label.Order_Page_Domain_Name+'/OrderCreation?id='+AId+'&cid='+ConId+'">'+Label.Order_Summary_Page_Click_Here+'</a> '+Label.Order_Summary_Page_Clickhere_Message+'</td></tr>'; EmailContent += '<tr><td colspan=2 style="font-weight:bold;">'+Label.Order_Summary_Page_Thanks+',<br/>'+Label.Order_Summary_Page_Mars_Chocolate+' </td></tr>'; EmailContent += '</table>'; Messaging.SingleEmailMessage email = new Messaging.SingleEmailMessage(); email.setToAddresses(new String[] { ToAddress }); email.setSubject(Label.Order_Summary_Subject); email.setHTMLBody(EmailContent); Messaging.sendEmail(new Messaging.Email[] { email }); }In the output, I am getting an email in which I am unable to change the email displayed in From field.
For example:
From: Order Summary Site Guest User to you <xyz@gmail.com> Date: Wed, Jan 28,2015 at 5.24 PM Subject: Sandbox: Order SummaryUsing setSenderDisplayName, setReplyTo, I am able to change "Order Summary Site Guest User to you" part, not "xyz@gmail.com". Is there any way to change the email address appearing by default.
- Prabhata
- January 29, 2015
- Like
- 0
test class
Hi Experts,
I need your help on test coverage for the class "AccountValidation" given below:
Kindly help me out in this.
I need your help on test coverage for the class "AccountValidation" given below:
public class AccountValidation { public Account acc; Public String AccErr1 {get;set;} Public String AccErr4 {get;set;} Public String LoginErr {get;set;} Public String DomainName {get;set;} Public Id AccId {get;set;} Public Id ConId {get;set;} Public List<String> characters; public String input {get; set;} public String result {get; set;} public String char1,char2,char3,char4,char5,char6; Public Decimal CaptchaErr {get; set;} public AccountValidation(ApexPages.StandardController controller) { if(ApexPages.currentPage().getParameters().get('id')!='' && ApexPages.currentPage().getParameters().get('id')!=null) AccId = ApexPages.currentPage().getParameters().get('id'); DomainName = Label.Order_Page_Domain_Name; acc = (Account)controller.getRecord(); CaptchaErr = 0; characters = new List<String>{'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z','1','2','3','4','5','6','7','8','9','0'}; ContactId(); } public PageReference SaveAccount(){ if(acc.Name!='' && acc.Name!=null && acc.City__c!='' && acc.City__c!=null){ if(input!='' && input!=null && input.length() == 6 && input.subString(0,1) == char1 && input.subString(1,2) == char2 && input.subString(2,3) == char3 && input.subString(3,4) == char4 && input.subString(4,5) == char5 && input.subString(5,6) == char6) CaptchaErr = 0; else CaptchaErr = 1; list<Account> accounts = [Select Id, Email_Address__c from Account where Name=:acc.Name and City__c=:acc.City__c limit 1]; list<Contact> contacts = new list<Contact>(); if(acc.Email_Address__c!='' && acc.Email_Address__c!=null && accounts.size()>0) contacts = [Select Id from Contact where AccountId=:accounts[0].Id and City__c=:acc.City__c and Email_Address__c=:acc.Email_Address__c limit 1]; if(contacts.size()>0 && CaptchaErr == 0){ AccErr4 = Label.Order_First_Page_Error4; AccErr1 = ''; } else if(accounts.size()>0 && CaptchaErr == 0){ AccErr1 = Label.Order_First_Page_Error1; AccErr4 = ''; } else{ AccErr1 = AccErr4 = ''; if(CaptchaErr == 0){ insert acc; List<Lead> TransformedLeadsList = new List<Lead>(); list<Lead> leads = [Select Transformed_Date__c from Lead where Company=:acc.Name and City__c=:acc.City__c]; if(leads.size()>0){ for(Lead ld : leads){ ld.Transformed_Date__c = (Date)system.today(); TransformedLeadsList.add(ld); } update TransformedLeadsList; } PageReference orderref = new PageReference(DomainName+'/AccCreation?id='+acc.Id); orderref.setRedirect(true); return orderref; } return null; } } return null; } public PageReference CreateContact(){ if(acc.Name!='' && acc.Name!=null && acc.City__c!='' && acc.City__c!=null){ list<Account> accounts = [Select Id from Account where Name=:acc.Name and City__c=:acc.City__c limit 1]; final String chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz'; String randStr = ''; while (randStr.length() < 6) { Integer idx = Math.mod(Math.abs(Crypto.getRandomInteger()), 62); randStr += chars.substring(idx, idx+1); } Contact con = new Contact(); con.FirstName = acc.First_Name__c; con.LastName = acc.Last_Name__c; con.AccountId = accounts[0].Id; con.Organisation_Type__c = acc.Organisation_Type__c; con.Road__c = acc.Road__c; con.Postal_Code__c = acc.Postal_Code__c; con.Function__c = acc.Function__c; con.Phone_Number__c = acc.Phone_Number__c; con.Email_Address__c = acc.Email_Address__c; con.Password__c = acc.First_Name__c+''+randStr; if(acc.Fax!=null && acc.Fax!='') con.Fax = acc.Fax; if(acc.Opening_Hours__c!=null && acc.Opening_Hours__c!='') con.Opening_Hours__c = acc.Opening_Hours__c; insert con; PageReference conref = new PageReference(DomainName+'/ContactCreation?id='+con.Id); conref.setRedirect(true); return conref; } return null; } public void ContactId(){ if(acc.Name!='' && acc.Name!=null && acc.City__c!='' && acc.City__c!=null && acc.Email_Address__c!='' && acc.Email_Address__c!=null){ list<Contact> cons = [Select Id from Contact where AccountId=:acc.Id and City__c=:acc.City__c and Email_Address__c=:acc.Email_Address__c limit 1]; if(cons.size()>0) ConId = cons[0].Id; } } public PageReference CheckAccount(){ return null; } public Integer randomNumber(){ Integer random = Math.Round(Math.Random() * characters.Size()); if(random == characters.size()){ random--; } return random; } public String getChar1(){ char1 = characters[randomNumber()]; return char1; } public String getChar2(){ char2 = characters[randomNumber()]; return char2; } public String getChar3(){ char3 = characters[randomNumber()]; return char3; } public String getChar4(){ char4 = characters[randomNumber()]; return char4; } public String getChar5(){ char5 = characters[randomNumber()]; return char5; } public String getChar6(){ char6 = characters[randomNumber()]; return char6; } }and the test class which I have started writing but unable to get the control inside CreateContact(). Given below is my test code
@isTest private class Test_AccountValidation{ static testMethod void runTest_AccountValidation(){ PageReference prf = Page.AccLogin; Test.setCurrentPage(prf); // Account acc = new Account(Name = 'Test Account', City__c = 'Test_City', Password__c = 'TestPassword'); // AccountValidation accVal = new AccountValidation(new ApexPages.StandardController(acc)); Account acnt = new Account(Name = 'Test Account', First_Name__c = 'Test FirstName', Last_Name__c = 'Test LastName', Organisation_Type__c = 'Association', Road__c = 'Test Road', Postal_Code__c = '12345', City__c = 'Test City', Function__c = 'other', Phone_Number__c = '1234567890', Email_Address__c = 'Test@testmail.com', Fax = '1234567890', Number_of_Employees__c = 'Between 100 and 500', Opening_Hours__c = 'Monday Morning'); ApexPages.currentPage().getParameters().get('id'); AccountValidation controller = new AccountValidation(new ApexPages.StandardController(acnt)); controller.SaveAccount(); insert acnt; /* AccountValidation controller1 = new AccountValidation(new ApexPages.StandardController(acnt)); Contact con = new Contact(FirstName = 'Test FirstName', LastName = 'Test LastName', Password__c = 'Testcon123', Organisation_Type__c = 'Association', Road__c = 'Test Road', Postal_Code__c = '12345', Function__c = 'other', Phone_Number__c = '1234567890', Email_Address__c = 'Test@testmail.com', Fax = '1234567890', Opening_Hours__c = 'Monday Morning'); insert con; controller1.CreateContact(); */ } }While I uncomment every line in the test class and run it following error is showing as below:
Kindly help me out in this.
- Prabhata
- January 13, 2015
- Like
- 0