• naclee01
  • 0 Points
  • Member since 2009

  • Chatter
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
  • 0

Hi, I just have a quick question.


I am trying to created a VF page to have tabs at the top of the object and put information from the object into the correct tab so it's only displayed when you click on that tab. I got the tabs working correctly, but right now I'm using HTML to display the data under the correct tab and it looks terrible. I was wondering, since all my data is in the same object and I have it all separated into sections in the detail section in the page layout, is it possible to use a specific section of that detail section under a certain tab? Will I have to make a custom controller?


Thanks for the help 

So I'm kind of new to using Apex and lately I've been trying to build a trigger to replicate the default functionality of the NPSP that automatically creates an organization for a contact that is not associated with an organization at creation for a custom object I have called staff member. I'm trying to work with the developer book provided by SalesForce but I'm having trouble finding useful examples so I've started looking for code bits I think might work and using trial and error methods to test them. So far no luck. I was hoping someone here could point me in the right direction as I have no idea if what I'm trying is close or if I'm way off. 


Basically, I have three objects: a staff member, an organization, and an affiliation. Using an Apex trigger I want to be able to create an organization object and an affiliation object after an insert to staff member. The organization object will hold information from the staff member object and the affiliation object will link the staff member and organization objects with their IDs.  


Here's the code I have right now:



trigger CreateNewOrg on Staff_Member__c (after insert) { List<Organization__c> newOrgs = new List<Organization__c>(); // build list in memory List<Affiliation__c> newAffs = new List<Affiliation__c>(); for (Staff_Member__c member : Trigger.new) { Organization__c newOrg = new Organization__c(); newOrg.Organization_Name__c = member.Last_Name__c; newOrgs.add(neworg); Affiliation__c newAff = new Affiliation__c(); newAff.Staff_Member__c = member.ID; newAff.Organization__c = newOrg.ID; newAffs.add(newAff); } Database.SaveResult[] orgs = Database.insert(newOrgs, false); Database.SaveResult[] affs = Database.insert(newAffs, false);}


Just to explain how I think this code should be working, it starts off by creating two lists, one of type object and the other of type affiliation. Then for each staff member, create a new organization, set the organization name to the value of the staff member's last name and then add it to the list of organizations. Then create a new affiliation object, set the staff member field to the current staff member's ID and the organization field to the organization's ID, then add the affiliation to the list of affiliations. After going through all the new staff members, write the new lists of organization and affiliation objects to the database.  


I really appreciate any help and advice anyone can give me on this topic.