• ccMark
  • NEWBIE
  • 25 Points
  • Member since 2009

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

Here is the situation which I find myself in.  My group has setup and object which will accept input via an email service which we have created.  From this object I want to create three contacts and two relationships.  My trigger is as follows, but I have been unable to create a test class that will get more than 0% coverage.  I'm starting to go crazy so I'm hoping someone will be able to point me in the right direction.

 

trigger parseStudentApplication on Student_Application__c (after insert) {

for (Student_Application__c sa : Trigger.new) {

Contact student = new Contact();

Contact father = new Contact();

Contact mother = new Contact();

npe4__Relationship__c studentToFather = new npe4__Relationship__c();

npe4__Relationship__c studentToMother = new npe4__Relationship__c();

student.FirstName = sa.Student_First_Name__c;

student.LastName = sa.Student_Last_Name__c;

student.MailingStreet = sa.Student_Address__c;

student.MailingCity = sa.Student_City__c;

student.MailingState = sa.Student_State__c;

student.MailingPostalCode = sa.Student_Zip__c;

student.Email = sa.Student_Email_Address__c;

student.Phone = sa.Student_Phone__c;

student.Birthdate = sa.Student_Date_of_Birth__c;

father.FirstName = sa.Father_First_Name__c;

father.LastName = sa.Father_Last_Name__c;

if(sa.Father_Address__c == null){

father.MailingStreet = sa.Student_Address__c;

father.MailingCity = sa.Student_City__c;

father.MailingState = sa.Student_State__c;

father.MailingPostalCode = sa.Student_Zip__c;

}

else{

father.MailingStreet = sa.Father_Address__c;

father.MailingCity = sa.Father_City_Text__c;

father.MailingState = sa.Father_State_Text__c;

father.MailingPostalCode = sa.Father_Zip__c;

}

 

if(sa.Mother_Address__c == null){

mother.MailingStreet = sa.Student_Address__c;

mother.MailingCity = sa.Student_City__c;

mother.MailingState = sa.Student_State__c;

mother.MailingPostalCode = sa.Student_Zip__c;

}

else{

mother.MailingStreet = sa.Mother_Address__c;

mother.MailingCity = sa.Mother_City__c;

mother.MailingState = sa.Mother_State__c;

mother.MailingPostalCode = sa.Mother_Zip__c;

}

studentToFather.npe4__Contact__c = student.Id;

studentToFather.npe4__RelatedContact__c = father.Id;

studentToFather.npe4__Description__c = 'Father';

studentToMother.npe4__Contact__c = student.Id;

studentToMother.npe4__RelatedContact__c = mother.Id;

studentToMother.npe4__Description__c = 'Mother';

insert student;

insert father;

insert mother;

insert studentToFather;

insert studentToMother;

}

} 

  • November 24, 2009
  • Like
  • 0

I have a VF page with a number of questions in the outputLabel and they are wrapping.  Also, my page is heavily weighted to the left and I'd like to find a way to center up the content.  Is there a way to control the width of the output labels and also to get better centering on the page?

 

                <apex:pageBlockSectionItem>
                    <apex:outputLabel value="Have you been engaged with this client before?" for="q2"/> 
                    <apex:outputPanel>
                        <apex:selectList id="q2" value="{!q2}" size="1">
                            <apex:selectOption itemValue="yes" itemLabel="Yes"/>
                            <apex:selectOption itemValue="no" itemLabel="No"/>
                        </apex:selectList>
                    </apex:outputPanel>
                </apex:pageBlockSectionItem>

TIA, Mark

  • December 15, 2009
  • Like
  • 0

I'm having an issue logging in to view content on the wiki using my developer force account.  I keep getting the following error message and I think it's because I had a developer account in a previous job and can't log in using that account.  Anyone know who to contact for assistance with this?

 

Database error

A database query syntax error has occurred. This may indicate a bug in the software. The last attempted database query was:
(SQL query hidden)
from within function "User::addToDatabase". MySQL returned error "1062: Duplicate entry 'Mark Boyer (Mark Boyer)' for key 'user_name' (localhost)".
  • November 23, 2009
  • Like
  • 0

I have a section of code like this that I need to get working.   Basically, I have an autocomplete component that pulls data from a SOQL query on page load and I need to allow my user to pick a item from this list then push the data into {!currentRequestItem} on the controller.  When I debug, the value that's entered into the input text box never makes it to the controller in the commandButton action.  I can't use an <apex:inputText> control because it won't work with the autocomplete js I'm using.  Any ideas?

 

                <apex:outputpanel id="counter">                  
                    <input type="text" id="tb" value="{!currentRequestItem}">
                    <script>
                        var obj = actb(document.getElementById('tb'),customarray );
                    </script>
                    <apex:inputText value="{!currentQuantity}" />
                    <apex:commandButton value="Add Row" action="{!AddRow}"/>
                </apex:outputpanel>

Here is the situation which I find myself in.  My group has setup and object which will accept input via an email service which we have created.  From this object I want to create three contacts and two relationships.  My trigger is as follows, but I have been unable to create a test class that will get more than 0% coverage.  I'm starting to go crazy so I'm hoping someone will be able to point me in the right direction.

 

trigger parseStudentApplication on Student_Application__c (after insert) {

for (Student_Application__c sa : Trigger.new) {

Contact student = new Contact();

Contact father = new Contact();

Contact mother = new Contact();

npe4__Relationship__c studentToFather = new npe4__Relationship__c();

npe4__Relationship__c studentToMother = new npe4__Relationship__c();

student.FirstName = sa.Student_First_Name__c;

student.LastName = sa.Student_Last_Name__c;

student.MailingStreet = sa.Student_Address__c;

student.MailingCity = sa.Student_City__c;

student.MailingState = sa.Student_State__c;

student.MailingPostalCode = sa.Student_Zip__c;

student.Email = sa.Student_Email_Address__c;

student.Phone = sa.Student_Phone__c;

student.Birthdate = sa.Student_Date_of_Birth__c;

father.FirstName = sa.Father_First_Name__c;

father.LastName = sa.Father_Last_Name__c;

if(sa.Father_Address__c == null){

father.MailingStreet = sa.Student_Address__c;

father.MailingCity = sa.Student_City__c;

father.MailingState = sa.Student_State__c;

father.MailingPostalCode = sa.Student_Zip__c;

}

else{

father.MailingStreet = sa.Father_Address__c;

father.MailingCity = sa.Father_City_Text__c;

father.MailingState = sa.Father_State_Text__c;

father.MailingPostalCode = sa.Father_Zip__c;

}

 

if(sa.Mother_Address__c == null){

mother.MailingStreet = sa.Student_Address__c;

mother.MailingCity = sa.Student_City__c;

mother.MailingState = sa.Student_State__c;

mother.MailingPostalCode = sa.Student_Zip__c;

}

else{

mother.MailingStreet = sa.Mother_Address__c;

mother.MailingCity = sa.Mother_City__c;

mother.MailingState = sa.Mother_State__c;

mother.MailingPostalCode = sa.Mother_Zip__c;

}

studentToFather.npe4__Contact__c = student.Id;

studentToFather.npe4__RelatedContact__c = father.Id;

studentToFather.npe4__Description__c = 'Father';

studentToMother.npe4__Contact__c = student.Id;

studentToMother.npe4__RelatedContact__c = mother.Id;

studentToMother.npe4__Description__c = 'Mother';

insert student;

insert father;

insert mother;

insert studentToFather;

insert studentToMother;

}

} 

  • November 24, 2009
  • Like
  • 0

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();    
}
}

I'm having an issue logging in to view content on the wiki using my developer force account.  I keep getting the following error message and I think it's because I had a developer account in a previous job and can't log in using that account.  Anyone know who to contact for assistance with this?

 

Database error

A database query syntax error has occurred. This may indicate a bug in the software. The last attempted database query was:
(SQL query hidden)
from within function "User::addToDatabase". MySQL returned error "1062: Duplicate entry 'Mark Boyer (Mark Boyer)' for key 'user_name' (localhost)".
  • November 23, 2009
  • Like
  • 0

Is it posible for me to display on an Account, a field from an Opportunity product.

 

Reson being is that in our salesforce setup with have it so that whenever a product is added to an opportunity it creates an individual tracking number for that product. this helps us track the renewal date the following year.

 

Would it be posilbe to display these tracking numbers in a long box or collum on the account itself, saving time going into all opportunitys one by one on an account!

 

Hope someone can help

 

Thanks

 

Jake 

Hi All,

 

 Is there any way to display default value in look up field?

 

Thanks.

 

 KSR

I have a section of code like this that I need to get working.   Basically, I have an autocomplete component that pulls data from a SOQL query on page load and I need to allow my user to pick a item from this list then push the data into {!currentRequestItem} on the controller.  When I debug, the value that's entered into the input text box never makes it to the controller in the commandButton action.  I can't use an <apex:inputText> control because it won't work with the autocomplete js I'm using.  Any ideas?

 

                <apex:outputpanel id="counter">                  
                    <input type="text" id="tb" value="{!currentRequestItem}">
                    <script>
                        var obj = actb(document.getElementById('tb'),customarray );
                    </script>
                    <apex:inputText value="{!currentQuantity}" />
                    <apex:commandButton value="Add Row" action="{!AddRow}"/>
                </apex:outputpanel>