• Jeffro
  • NEWBIE
  • 0 Points
  • Member since 2008

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

I would like to build a Visualforce page where my users can go and insert multiple Contacts in one shot. It would basically act like an Excel sheet with columns like First Name, Last Name, Email, etc. Once they enter all of their Contacts, they would click a button, all Contacts would be inserted.

 

A good scenario would be collecting 20 business cards from a fair. When you get back from the fair you can enter the information from the 20 cards at once, without clicking 'New' 20 individual times. After the data is entered, click 'Insert' and you just created 20 Contacts.

 

Does anyone know if creating repeating records/fields is possible?

 

Thanks,

Jeff

I am somewhat of a newbie to Apex and VF, so I will explain my issue in pseudo code.

I have three custom objects (Applications, Enrollments, Tests) that are children of the Contact object. I would like to create a Visual Force page that displays information for all Applications that have a Status of 'Incomplete'. All custom objects have a Contact__c field associated to them so I can reference the Contact object from any of them.

Here is the issue: Not all Enrollments and Tests are associated with the Application object, but all are associated with the Contact object. So I need to query for all 'Incomplete' Applications in my custom controller and use the Contact__c reference to query Enrollments and Tests. Then display the information in a table on the VF page.

So I have two trains of thought:

 

This does not work... 

  1.  Select FirstName, LastName,(Select <application_fields> from Application),(Select <enrollment_fields> from Enrollments),(Select <test_fields> from Tests) From Contact Where Application__r.Status = 'Incomplete';    OR
  2. Select Contact__c from Application Where Application.Status = 'Incomplete';

for (incomplete_apps)

{

     contact_id = incomplete_apps.Contact__c;

     Select Name from Enrollments where Contact__c = :contact_id;

     Select Name from Tests where Contact__c = :contact_id;

}

 

If I do #2, how do I reference the Enrollments and Tests on the VF page since the page is calling the getMethod for the Application?

 

Hope this makes sense????

Thanks,

Jeff

  • April 03, 2009
  • Like
  • 0

I created a query(controller) that retrieves Contact records based on certain 'where' conditions. Once I retrieve those records, I need to use the id to retrieve information from child objects. I am getting confused on the concept of how to "nest" these queries.

So, if the results of the Contact query are 50 Contacts, I need to loop through each of those records to attain information from a couple of other child objects.

 

Psuedo code:

Select Id, FirstName, LastName from Contact where Status = 'Applicant';

Loop:

Select X, Y, Z from child_object where Contact_Id = Contact.Id (from first query)

 Select X, Y, Z from child_object2 where Contact_Id2 = Contact.Id (from first query)

End Loop;

 

Then I can take the information and display it on a Visualforce page. Any ideas? I am just having problems associating the Contact results to a variable so I can use it against other objects.

 

Thanks,

Jeff

  • March 30, 2009
  • Like
  • 0

I currently have a trigger that updates contact information based on the Zip Code on the contact record. I also built a test method, but I am only getting to 72% instead of 75% testing coverage. Here is the trigger and testmethod...

 

Trigger:

trigger ZipData on Contact (before insert, before update) 
{
List<String> zips = new List<String>();
List<Contact> updContact = new List<Contact>();

// Loop through Contacts and create list of zip codes
for (Contact c : Trigger.new)
{
if (c.MailingPostalCode != NULL)
{
zips.add(c.MailingPostalCode);
updContact.add(c);
}
}

//query zip code table for related data
Map<String, Zip_Table__c> ContactToUpdate = new Map<String, Zip_Table__c>();

//to make sure the Map is getting set up correctly
for(Zip_Table__c z :[select Name, XCity__c, XCounty__c, XState__c, XEPS_Code__c from Zip_Table__c where Name in :zips]){
ContactToUpdate.put(z.name,z);
}



// If there is at least one match, bulk update
if (ContactToUpdate.size() > 0)
{
for (Contact c : updContact)
{
//populate the contact fields
Zip_Table__c updzip = ContactToUpdate.get(c.MailingPostalCode);
if(updzip!=null){
c.MailingCity = updzip.XCity__c;
c.MailingState = updzip.XState__c;
c.XCounty__c = updzip.XCounty__c;
c.XEPS_Code__c = updzip.XEPS_Code__c;
}
}
}else{
for (Contact c : updContact)
{
c.MailingCity = NULL;
c.MailingState = NULL;
c.XCounty__c = NULL;
c.XEPS_Code__c = NULL;
}
}
}

 testMethod:

Public class TestZipData {
static testMethod void testZip() {

Contact[] contact = new Contact[]
{new Contact(LastName = 'ZipData', MailingPostalCode = '14513'),
new Contact(LastName = 'Smith', MailingPostalCode = '12208')};

insert contact;

Contact upcontact = [select MailingPostalCode from Contact where Id = '003R000000Biw5t'];
upcontact.MailingPostalCode = '12208';

update upcontact;
}
}

 It looks as though the test is not getting to the

if (ContactToUpdate.size() > 0)

 code and below....any ideas???

 

Jeff

 

  • March 13, 2009
  • Like
  • 0

I am using Salesforce's email services to populate a Contact record with information submitted through a web form. A user fills out the web form, all of the information from the form is sent as an email, the Apex class parses the email, and populates the Contact record.

The problem I have is that I have picklist values on the form that have an apostrophe(') in them. They are "Bachelor's" and "Master's" . When the email class parses the information, the field on the Salesforce side is populated with"Bachelor&#039;s" or"Master&#039;s". Here is the Apex code that parses that line:

 

contact.Highest_Degree_Earned__c = getFieldValue(myPlainText,'Education:');

 

How can I account for a value returned with an apostrophe? This seemed to just started happening when we were upgraded to Spring 09 release.

Thanks

  • February 18, 2009
  • Like
  • 0

Is there a way to delete multiple picklist values without having to click the del link next to each value? We have @50 values in our Source field on the Contact object and I would like to clean it out and start over. Is there a way to due this as a batch delete?

Thanks

  • February 18, 2009
  • Like
  • 0

I would like to build a Visualforce page where my users can go and insert multiple Contacts in one shot. It would basically act like an Excel sheet with columns like First Name, Last Name, Email, etc. Once they enter all of their Contacts, they would click a button, all Contacts would be inserted.

 

A good scenario would be collecting 20 business cards from a fair. When you get back from the fair you can enter the information from the 20 cards at once, without clicking 'New' 20 individual times. After the data is entered, click 'Insert' and you just created 20 Contacts.

 

Does anyone know if creating repeating records/fields is possible?

 

Thanks,

Jeff

I created a query(controller) that retrieves Contact records based on certain 'where' conditions. Once I retrieve those records, I need to use the id to retrieve information from child objects. I am getting confused on the concept of how to "nest" these queries.

So, if the results of the Contact query are 50 Contacts, I need to loop through each of those records to attain information from a couple of other child objects.

 

Psuedo code:

Select Id, FirstName, LastName from Contact where Status = 'Applicant';

Loop:

Select X, Y, Z from child_object where Contact_Id = Contact.Id (from first query)

 Select X, Y, Z from child_object2 where Contact_Id2 = Contact.Id (from first query)

End Loop;

 

Then I can take the information and display it on a Visualforce page. Any ideas? I am just having problems associating the Contact results to a variable so I can use it against other objects.

 

Thanks,

Jeff

  • March 30, 2009
  • Like
  • 0

Hello,

 

Is it possible to write an APEX trigger or S-Control that would merge duplicate records based on certain duplicate rule.

 

For example, is it possible to automatically merge records upon insert or update if a lead's full name and website match that of a contact's full name and contact's account website?

 

-Thanks

I currently have a trigger that updates contact information based on the Zip Code on the contact record. I also built a test method, but I am only getting to 72% instead of 75% testing coverage. Here is the trigger and testmethod...

 

Trigger:

trigger ZipData on Contact (before insert, before update) 
{
List<String> zips = new List<String>();
List<Contact> updContact = new List<Contact>();

// Loop through Contacts and create list of zip codes
for (Contact c : Trigger.new)
{
if (c.MailingPostalCode != NULL)
{
zips.add(c.MailingPostalCode);
updContact.add(c);
}
}

//query zip code table for related data
Map<String, Zip_Table__c> ContactToUpdate = new Map<String, Zip_Table__c>();

//to make sure the Map is getting set up correctly
for(Zip_Table__c z :[select Name, XCity__c, XCounty__c, XState__c, XEPS_Code__c from Zip_Table__c where Name in :zips]){
ContactToUpdate.put(z.name,z);
}



// If there is at least one match, bulk update
if (ContactToUpdate.size() > 0)
{
for (Contact c : updContact)
{
//populate the contact fields
Zip_Table__c updzip = ContactToUpdate.get(c.MailingPostalCode);
if(updzip!=null){
c.MailingCity = updzip.XCity__c;
c.MailingState = updzip.XState__c;
c.XCounty__c = updzip.XCounty__c;
c.XEPS_Code__c = updzip.XEPS_Code__c;
}
}
}else{
for (Contact c : updContact)
{
c.MailingCity = NULL;
c.MailingState = NULL;
c.XCounty__c = NULL;
c.XEPS_Code__c = NULL;
}
}
}

 testMethod:

Public class TestZipData {
static testMethod void testZip() {

Contact[] contact = new Contact[]
{new Contact(LastName = 'ZipData', MailingPostalCode = '14513'),
new Contact(LastName = 'Smith', MailingPostalCode = '12208')};

insert contact;

Contact upcontact = [select MailingPostalCode from Contact where Id = '003R000000Biw5t'];
upcontact.MailingPostalCode = '12208';

update upcontact;
}
}

 It looks as though the test is not getting to the

if (ContactToUpdate.size() > 0)

 code and below....any ideas???

 

Jeff

 

  • March 13, 2009
  • Like
  • 0

I am using Salesforce's email services to populate a Contact record with information submitted through a web form. A user fills out the web form, all of the information from the form is sent as an email, the Apex class parses the email, and populates the Contact record.

The problem I have is that I have picklist values on the form that have an apostrophe(') in them. They are "Bachelor's" and "Master's" . When the email class parses the information, the field on the Salesforce side is populated with"Bachelor&#039;s" or"Master&#039;s". Here is the Apex code that parses that line:

 

contact.Highest_Degree_Earned__c = getFieldValue(myPlainText,'Education:');

 

How can I account for a value returned with an apostrophe? This seemed to just started happening when we were upgraded to Spring 09 release.

Thanks

  • February 18, 2009
  • Like
  • 0

Is there a way to delete multiple picklist values without having to click the del link next to each value? We have @50 values in our Source field on the Contact object and I would like to clean it out and start over. Is there a way to due this as a batch delete?

Thanks

  • February 18, 2009
  • Like
  • 0
Currently I use an override for my opportunity clone, this line being a subset of it.
 
var redirectURL = "{!UrlFor($Action.Opportunity.Clone,Opportunity.Id,[retURL = $Request.retURL],true)}";
Is there any way I can set it to clone with OpportunityLineItems as well?