• gautam123
  • NEWBIE
  • 0 Points
  • Member since 2009

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 3
    Questions
  • 4
    Replies

Hi everyone,

 

We have a requirement where in our customer portal's welcome visualforce page,we should be able to display different logos/graphics/messages depending on user's login credentials .

 

For example when user A logs in ,he should see his logo in logo space of our visualforce page .on the other hand ,when user B logs in ,he should see his logo .

 

Can anyone help me on how we can implement this requirement ? Thanks

Hi All,

 

I am trying to install a package .But getting the below error.

 

"Missing Organization Feature: GoogleDoc".

 

I have enabled Google Docs in my developer edition ,even after that i get the same error .

 

Has anyone experienced this error ?Plz help me to resolve it .Thanks.

Hi all,
I have written two classes and a vf page to add multiple contacts in a custom object .But now the issue is i am not able to achieve 75% code coverage for one of my classes .
Can anyone of you help me to get this 75% code coverage for the class !
Please find the classes attached below .The issue is with the test class "TestEventMassAddControllerExt".


EventMassAddControllerExt :
// This controller is used to mass signup contacts for a event Activity.
public class EventMassAddControllerExt
{   
private SFDC_Special_Event__c se;
public String name {get;set;}
public String id {get;set;}
public Integer TotalRegistrants {get;set;}
public Integer size {get;set;}
public Integer noOfRecordsToBeDisplayed {get;set;}
public static Integer maxRecordsPerPage = 25;
public Integer index{get;set;}
public String fname {get;set;}
public String lname {get;set;}
public EventMassAddControllerExt(ApexPages.StandardController stdController)
{
this.se = (SFDC_Special_Event__c) stdController.getRecord();
init();       
System.debug(Logginglevel.DEBUG, 'Constructor ' + se.Id);
}  
private Integer countQuery()
{
System.debug(Logginglevel.DEBUG, 'Executing Count Query ');
if (fname != null && fname != '' && lname != null && lname != '' )
{
return [select count() from Contact where FirstName like: fname+'%' and LastName like: lname+'%' ];
}
else if (fname != null && fname != '' )
{
return [select count() from Contact where FirstName like: fname+'%' ];
}
else if (lname != null && lname != '' )
{
return [select count() from Contact where LastName like: lname+'%' ];
}
else
{
System.debug(Logginglevel.DEBUG, 'Returning Count');           
return [select count() from Contact where Id!=null limit:500 ];
}
}
private List<Contact> resultsQuery(Integer limitRows, Integer next)
{
System.debug(Logginglevel.DEBUG, 'Executing Results Query ' + limitRows + 'next ' + next);
String query = ' select Id,name,FirstName,LastName,Email,Phone '+ ' from Contact '+' where Id!=null ';
String orderQuery = ' order by name '+ ' limit ' + limitRows ;                            
Integer rowCount = 0;
List<Contact> retContactList = new List<Contact>();
if (fname != null && fname != '' && lname != null && lname != '' )
{
for (List<Contact> contacts : [select Id,Name,FirstName,LastName,Email,Phone from Contact
where FirstName like : fname+'%' and LastName like : lname+'%' order by LastName limit:500])
{
for (Contact con : contacts)
{
if (rowCount >= next)
{
retContactList.add(con);
}
rowCount++;
}
}
}
else if (fname != null && fname != '' )
{
for (List<Contact> contacts : [select Id,name,FirstName,LastName,Email,Phone
from Contact where FirstName like : fname+'%' order by LastName limit:500])
{
for (Contact con : contacts)
{
if (rowCount >= next)
{
retContactList.add(con);
}
rowCount++;
}
}
}
else if (lname != null && lname != '' )
{
for (List<Contact> contacts : [select Id,name,FirstName,LastName,Email,Phone
from Contact where LastName like : lname+'%'order by LastName limit:500])
{
for (Contact con : contacts)
{
if (rowCount >= next)
{
retContactList.add(con);
}
rowCount++;
}
}
}
else
{
for (List<Contact> contacts : [select Id,name,FirstName,LastName,Email,Phone
from Contact where FirstName!=null and LastName!=null order by LastName limit:500 ])
{
for (Contact con : contacts)
{
if (rowCount >= next)
{
retContactList.add(con);
}
rowCount++;
}
}
}
System.debug(Logginglevel.DEBUG, 'Returning Results Query ' + retContactList.size());
return retContactList;
}
public Integer getCount()
{
return countQuery();
}
public List<Contact> getContactList(String id, Integer next)
{   
Integer rowCount = 0;      
Integer totRows = next + maxRecordsPerPage;
return resultsQuery(totRows, next);
}
public PageReference massSignUp()
{
String vaId = se.Id;
ApexPages.Message res;
if (selUsers.size() > 0)
{
res = eventmain.signUpBatch(vaId, selUsers);           
id = vaId;
Double totalParticipants = se.Total_Registrants__c;
TotalRegistrants = totalParticipants.intValue();           
}
else
{
res = new ApexPages.Message(ApexPages.Severity.ERROR, System.Label.SignupMassSelectAtLeastOneUser);
}
if (res != null)
{
ApexPages.addMessage(res);
return null;      
}
PageReference pageRef = Page.EventMassAddPage;
pageRef.getParameters().put('id', vaId);       
pageRef.setredirect(true);
return pageRef;
}
String[] selUsers = new String[]{};
public List<SelectOption> getItems() {     
System.debug(Logginglevel.DEBUG, 'Calling getItems');
List<SelectOption> options = new List<SelectOption>();
if (index == null)
{
index = 0;
}
List<Contact> allContacts = getContactList(se.Id, index);
System.debug(Logginglevel.DEBUG, 'All Contacts ' + allContacts.size());
Set<String> signedUpContacts = eventmain.getSignedUpUsers(se.Id, allContacts);
System.debug(Logginglevel.DEBUG, 'Signedup Contacts ' + signedUpContacts.size());
Integer lssize = allContacts.size(); 
if (size > index+maxRecordsPerPage) {
noOfRecordsToBeDisplayed = index+maxRecordsPerPage;
} else {
noOfRecordsToBeDisplayed = lssize;
}
Integer lSize = (noOfRecordsToBeDisplayed < lssize?noOfRecordsToBeDisplayed:lssize);
for (Integer i=0;i<lSize;i++) {
Contact u = allContacts[i];  
Boolean signedUp = false;
if (signedUpContacts.contains(u.Id)) {
signedUp = true;
}
String displayValue = 'Name:'+' '+u.Name;
if (u.Email!= null) {
displayValue += ' |   ' +'Email:'+' '+ u.Email;
if(u.Phone!=null) {
displayValue += ' |   ' +'Phone:'+' '+ u.Phone;
}
}
if (signedUp) {
options.add(new SelectOption(u.Id,displayValue,true));
} else {
options.add(new SelectOption(u.Id,displayValue));
}
}
System.debug(Logginglevel.DEBUG, 'Returning getItems ' + options.size());
return options;
}
public String[] getselUsers() {
return selUsers;
}
public void setSelUsers(String[] selUsers) {
this.selUsers = selUsers;
}
public void init()
{
System.debug(Logginglevel.DEBUG, 'Calling init()');
System.debug(Logginglevel.DEBUG, 'init volact name ' + se.Name);
id = se.Id;
name = se.Name;       
Double totalParticipants = se.Total_Registrants__c;
if (totalParticipants != null) {
TotalRegistrants = totalParticipants.intValue();
}
size = getCount();
index = 0;
System.debug(Logginglevel.DEBUG, 'Completing init()');
}
public void search() {
size = getCount();
index = 0;
}
public void nextPage() {
if (index == null) index = 0;
index = (index+maxRecordsPerPage);
if (index > size) {
index = size;
}
}
public void prevPage() {
index = (index-maxRecordsPerPage);
if (index < 0) {
index = 0;
}
}
public Boolean getRenderNext() {
if (index == null) {
index = 0;
 }
if (index+maxRecordsPerPage >= size) {
return false;
}
return true;
}
public Boolean getRenderPrev() {       
if (index > 0 ) {
return true;
}
return false;
}
public Boolean getRenderMaxParticipants() {
if (TotalRegistrants != null && TotalRegistrants > 0) {
return true;
}
return false;
}
}
 
Test EventMassAddControllerExt :
Problem lies in this class ..achieved just 62% code coverage .not able to achieve 75%+..plz help!!
 
@isTest
private class TestEventMassAddControllerExt
{   
private EventMassAddControllerExt setupController(SFDC_Special_Event__c va)
{
// Construct the controller that will be returned by this setup method.
ApexPages.StandardController standardcontroller = new ApexPages.StandardController(va) ;
EventMassAddControllerExt controller = new EventMassAddControllerExt(standardcontroller);
// Create a page for use in the test.
PageReference p = Page.EventMassAddPage;
// Set the case ID in the context for use by the controller.
p.getParameters().put('id',va.id);
// Set the case ID in the context for use by the controller.
Test.setCurrentPage(p);
return controller;
}
private SFDC_Special_Event__c setupTestCaseVA()
{
datetime myDateTime = datetime.now();
SFDC_Special_Event__c va1 = new SFDC_Special_Event__c(name='testevent',Type__c='Awareness',
Start_Date__c=myDateTime,ME_Status__c='Planned',Duration__c='1');
insert(va1);
Contact onecon=new Contact(lastname='testcon');
insert onecon;
System.assertEquals('testcon', onecon.lastname);
List<Contact> contacts = new List<Contact>();
for(integer i=0; i<20; i++) {
contacts.add( new Contact(lastname = 'a+i'));
}
insert contacts;
List<SFDC_Attendence__c> attendeeList = new List<SFDC_Attendence__c>();
for (Contact contact : contacts)
{
SFDC_Attendence__c attendees = new SFDC_Attendence__c(Special_Event__c=va1.Id,Attendee__c=contact.Id);
attendeeList.add(attendees);
}
return va1;
}
public static testMethod void massSignUpTest()
{
TestEventMassAddControllerExt testclass = new TestEventMassAddControllerExt();
SFDC_Special_Event__c va = testclass.setupTestCaseVA();
EventMassAddControllerExt controller = testclass.setupController(va);
controller.nextPage();
controller.prevPage();
controller.getRenderNext();
controller.getRenderPrev();
System.debug(Logginglevel.DEBUG, 'Mass sign up res: '+controller.massSignUp());
String[] selectedUsers = new String[1];
controller.setSelUsers(selectedUsers);
System.assertEquals(controller.getSelUsers().size(),1);
controller.fname='m';   
controller.search();
controller.getItems();
controller.getselUsers();
controller.getRenderNext();
controller.getRenderPrev();
controller.lname='a1';
controller.search();
controller.getItems();
controller.getselUsers();
controller.getRenderNext();
controller.getRenderPrev();
controller.fname='g';
controller.lname='r';
controller.search();
controller.getCount();
controller.getItems();
controller.getselUsers();
controller.init();
controller.nextPage();
controller.prevPage();
controller.getRenderNext();
controller.getRenderPrev();
controller.getRenderMaxParticipants();
Test.startTest();
Test.stopTest();    
}
}

Hi everyone,

 

We have a requirement where in our customer portal's welcome visualforce page,we should be able to display different logos/graphics/messages depending on user's login credentials .

 

For example when user A logs in ,he should see his logo in logo space of our visualforce page .on the other hand ,when user B logs in ,he should see his logo .

 

Can anyone help me on how we can implement this requirement ? Thanks

Hi All,

 

I am trying to install a package .But getting the below error.

 

"Missing Organization Feature: GoogleDoc".

 

I have enabled Google Docs in my developer edition ,even after that i get the same error .

 

Has anyone experienced this error ?Plz help me to resolve it .Thanks.

Hi all,
I have written two classes and a vf page to add multiple contacts in a custom object .But now the issue is i am not able to achieve 75% code coverage for one of my classes .
Can anyone of you help me to get this 75% code coverage for the class !
Please find the classes attached below .The issue is with the test class "TestEventMassAddControllerExt".


EventMassAddControllerExt :
// This controller is used to mass signup contacts for a event Activity.
public class EventMassAddControllerExt
{   
private SFDC_Special_Event__c se;
public String name {get;set;}
public String id {get;set;}
public Integer TotalRegistrants {get;set;}
public Integer size {get;set;}
public Integer noOfRecordsToBeDisplayed {get;set;}
public static Integer maxRecordsPerPage = 25;
public Integer index{get;set;}
public String fname {get;set;}
public String lname {get;set;}
public EventMassAddControllerExt(ApexPages.StandardController stdController)
{
this.se = (SFDC_Special_Event__c) stdController.getRecord();
init();       
System.debug(Logginglevel.DEBUG, 'Constructor ' + se.Id);
}  
private Integer countQuery()
{
System.debug(Logginglevel.DEBUG, 'Executing Count Query ');
if (fname != null && fname != '' && lname != null && lname != '' )
{
return [select count() from Contact where FirstName like: fname+'%' and LastName like: lname+'%' ];
}
else if (fname != null && fname != '' )
{
return [select count() from Contact where FirstName like: fname+'%' ];
}
else if (lname != null && lname != '' )
{
return [select count() from Contact where LastName like: lname+'%' ];
}
else
{
System.debug(Logginglevel.DEBUG, 'Returning Count');           
return [select count() from Contact where Id!=null limit:500 ];
}
}
private List<Contact> resultsQuery(Integer limitRows, Integer next)
{
System.debug(Logginglevel.DEBUG, 'Executing Results Query ' + limitRows + 'next ' + next);
String query = ' select Id,name,FirstName,LastName,Email,Phone '+ ' from Contact '+' where Id!=null ';
String orderQuery = ' order by name '+ ' limit ' + limitRows ;                            
Integer rowCount = 0;
List<Contact> retContactList = new List<Contact>();
if (fname != null && fname != '' && lname != null && lname != '' )
{
for (List<Contact> contacts : [select Id,Name,FirstName,LastName,Email,Phone from Contact
where FirstName like : fname+'%' and LastName like : lname+'%' order by LastName limit:500])
{
for (Contact con : contacts)
{
if (rowCount >= next)
{
retContactList.add(con);
}
rowCount++;
}
}
}
else if (fname != null && fname != '' )
{
for (List<Contact> contacts : [select Id,name,FirstName,LastName,Email,Phone
from Contact where FirstName like : fname+'%' order by LastName limit:500])
{
for (Contact con : contacts)
{
if (rowCount >= next)
{
retContactList.add(con);
}
rowCount++;
}
}
}
else if (lname != null && lname != '' )
{
for (List<Contact> contacts : [select Id,name,FirstName,LastName,Email,Phone
from Contact where LastName like : lname+'%'order by LastName limit:500])
{
for (Contact con : contacts)
{
if (rowCount >= next)
{
retContactList.add(con);
}
rowCount++;
}
}
}
else
{
for (List<Contact> contacts : [select Id,name,FirstName,LastName,Email,Phone
from Contact where FirstName!=null and LastName!=null order by LastName limit:500 ])
{
for (Contact con : contacts)
{
if (rowCount >= next)
{
retContactList.add(con);
}
rowCount++;
}
}
}
System.debug(Logginglevel.DEBUG, 'Returning Results Query ' + retContactList.size());
return retContactList;
}
public Integer getCount()
{
return countQuery();
}
public List<Contact> getContactList(String id, Integer next)
{   
Integer rowCount = 0;      
Integer totRows = next + maxRecordsPerPage;
return resultsQuery(totRows, next);
}
public PageReference massSignUp()
{
String vaId = se.Id;
ApexPages.Message res;
if (selUsers.size() > 0)
{
res = eventmain.signUpBatch(vaId, selUsers);           
id = vaId;
Double totalParticipants = se.Total_Registrants__c;
TotalRegistrants = totalParticipants.intValue();           
}
else
{
res = new ApexPages.Message(ApexPages.Severity.ERROR, System.Label.SignupMassSelectAtLeastOneUser);
}
if (res != null)
{
ApexPages.addMessage(res);
return null;      
}
PageReference pageRef = Page.EventMassAddPage;
pageRef.getParameters().put('id', vaId);       
pageRef.setredirect(true);
return pageRef;
}
String[] selUsers = new String[]{};
public List<SelectOption> getItems() {     
System.debug(Logginglevel.DEBUG, 'Calling getItems');
List<SelectOption> options = new List<SelectOption>();
if (index == null)
{
index = 0;
}
List<Contact> allContacts = getContactList(se.Id, index);
System.debug(Logginglevel.DEBUG, 'All Contacts ' + allContacts.size());
Set<String> signedUpContacts = eventmain.getSignedUpUsers(se.Id, allContacts);
System.debug(Logginglevel.DEBUG, 'Signedup Contacts ' + signedUpContacts.size());
Integer lssize = allContacts.size(); 
if (size > index+maxRecordsPerPage) {
noOfRecordsToBeDisplayed = index+maxRecordsPerPage;
} else {
noOfRecordsToBeDisplayed = lssize;
}
Integer lSize = (noOfRecordsToBeDisplayed < lssize?noOfRecordsToBeDisplayed:lssize);
for (Integer i=0;i<lSize;i++) {
Contact u = allContacts[i];  
Boolean signedUp = false;
if (signedUpContacts.contains(u.Id)) {
signedUp = true;
}
String displayValue = 'Name:'+' '+u.Name;
if (u.Email!= null) {
displayValue += ' |   ' +'Email:'+' '+ u.Email;
if(u.Phone!=null) {
displayValue += ' |   ' +'Phone:'+' '+ u.Phone;
}
}
if (signedUp) {
options.add(new SelectOption(u.Id,displayValue,true));
} else {
options.add(new SelectOption(u.Id,displayValue));
}
}
System.debug(Logginglevel.DEBUG, 'Returning getItems ' + options.size());
return options;
}
public String[] getselUsers() {
return selUsers;
}
public void setSelUsers(String[] selUsers) {
this.selUsers = selUsers;
}
public void init()
{
System.debug(Logginglevel.DEBUG, 'Calling init()');
System.debug(Logginglevel.DEBUG, 'init volact name ' + se.Name);
id = se.Id;
name = se.Name;       
Double totalParticipants = se.Total_Registrants__c;
if (totalParticipants != null) {
TotalRegistrants = totalParticipants.intValue();
}
size = getCount();
index = 0;
System.debug(Logginglevel.DEBUG, 'Completing init()');
}
public void search() {
size = getCount();
index = 0;
}
public void nextPage() {
if (index == null) index = 0;
index = (index+maxRecordsPerPage);
if (index > size) {
index = size;
}
}
public void prevPage() {
index = (index-maxRecordsPerPage);
if (index < 0) {
index = 0;
}
}
public Boolean getRenderNext() {
if (index == null) {
index = 0;
 }
if (index+maxRecordsPerPage >= size) {
return false;
}
return true;
}
public Boolean getRenderPrev() {       
if (index > 0 ) {
return true;
}
return false;
}
public Boolean getRenderMaxParticipants() {
if (TotalRegistrants != null && TotalRegistrants > 0) {
return true;
}
return false;
}
}
 
Test EventMassAddControllerExt :
Problem lies in this class ..achieved just 62% code coverage .not able to achieve 75%+..plz help!!
 
@isTest
private class TestEventMassAddControllerExt
{   
private EventMassAddControllerExt setupController(SFDC_Special_Event__c va)
{
// Construct the controller that will be returned by this setup method.
ApexPages.StandardController standardcontroller = new ApexPages.StandardController(va) ;
EventMassAddControllerExt controller = new EventMassAddControllerExt(standardcontroller);
// Create a page for use in the test.
PageReference p = Page.EventMassAddPage;
// Set the case ID in the context for use by the controller.
p.getParameters().put('id',va.id);
// Set the case ID in the context for use by the controller.
Test.setCurrentPage(p);
return controller;
}
private SFDC_Special_Event__c setupTestCaseVA()
{
datetime myDateTime = datetime.now();
SFDC_Special_Event__c va1 = new SFDC_Special_Event__c(name='testevent',Type__c='Awareness',
Start_Date__c=myDateTime,ME_Status__c='Planned',Duration__c='1');
insert(va1);
Contact onecon=new Contact(lastname='testcon');
insert onecon;
System.assertEquals('testcon', onecon.lastname);
List<Contact> contacts = new List<Contact>();
for(integer i=0; i<20; i++) {
contacts.add( new Contact(lastname = 'a+i'));
}
insert contacts;
List<SFDC_Attendence__c> attendeeList = new List<SFDC_Attendence__c>();
for (Contact contact : contacts)
{
SFDC_Attendence__c attendees = new SFDC_Attendence__c(Special_Event__c=va1.Id,Attendee__c=contact.Id);
attendeeList.add(attendees);
}
return va1;
}
public static testMethod void massSignUpTest()
{
TestEventMassAddControllerExt testclass = new TestEventMassAddControllerExt();
SFDC_Special_Event__c va = testclass.setupTestCaseVA();
EventMassAddControllerExt controller = testclass.setupController(va);
controller.nextPage();
controller.prevPage();
controller.getRenderNext();
controller.getRenderPrev();
System.debug(Logginglevel.DEBUG, 'Mass sign up res: '+controller.massSignUp());
String[] selectedUsers = new String[1];
controller.setSelUsers(selectedUsers);
System.assertEquals(controller.getSelUsers().size(),1);
controller.fname='m';   
controller.search();
controller.getItems();
controller.getselUsers();
controller.getRenderNext();
controller.getRenderPrev();
controller.lname='a1';
controller.search();
controller.getItems();
controller.getselUsers();
controller.getRenderNext();
controller.getRenderPrev();
controller.fname='g';
controller.lname='r';
controller.search();
controller.getCount();
controller.getItems();
controller.getselUsers();
controller.init();
controller.nextPage();
controller.prevPage();
controller.getRenderNext();
controller.getRenderPrev();
controller.getRenderMaxParticipants();
Test.startTest();
Test.stopTest();    
}
}