1

I am helping a local non-profit organization that does leadership training. They need to create a roster that will pull a list of contacts for the roster, and also store few topics that they worked on. There is a custom field in the contacts already that stores the class type and year. So far I created a custom object for Roster, with 3 fields for Roster name, Class Year and Class type. Now I need the roster to pull all contacts that have the same type and year in a list. Is there a way to have a custom field for a list of objects? Any suggestions on how should I approach this? I'm very new to SalesForce so any help is appreciated. Thanks!

Update: So I got it to work with the junction object and it's great! I can create a new Roster and pick Contacts with Lookup to add, one by one. My Sandbox is also ready. Now if I can get this the contacts to be added automatically, it would be perfect! There are about 100 contacts for each year, so doing it manually it is tedious/unreasonable. I've never written Apex code before so where do I start with the trigger? Thanks in advance!

5

For the above problem, I would suggest creating new Custom object, that will act as a Junction object between Roaster and Contacts. It will have look-up fields to Contact object and Roaster object. Now you need to write trigger on Roaster object, which will capture the Class Year and Class type details.Based on this, query on the Contact records and the matching records. Finally iterate over the list of Contacts retrieved and create records of Junction Object, with different look-up to Contacts and same look-up to Roaster record being created.

This would be helpful for viewing the list of Contacts for particular Roaster via Junction object, as related list.

For more details related to Junction object, refer : Junction Object

| improve this answer | |
  • I created a junction object called ContactRosterAssociations, with two Master-Detail Relationship fields, one for Contact and one for Roster. Then I looked at the Trigger part and I have no clue there. Also getting "Cannot create trigger on active organization" Any help with that? Thanks! – user1781482 Mar 29 '15 at 12:54
  • Triggers cannot be created directly in Unlimited/Enterprise editions. Please refer : help.salesforce.com/apex/… for more details. – Kshitij Shah Mar 29 '15 at 13:26
  • I was able to get it work with this approach. Thanks! – user1781482 Mar 31 '15 at 18:03
0

I'm going to provide a very low tech and more manual solution that might be suitable (and a lot less complicated then worrying custom code, test coverage, deployments and such).

  1. Create the Junction object as suggested by user178148 adding the custom fields for the items worked on.
  2. Start off with your Roster Object as you have constructed it.
  3. Create a Contact report which filters on the selected criteria (i.e. Class Name, Class Type).
  4. Set the filters to the desired criteria and then run the report
  5. Export the report to Excel. Make sure that you are exporting the ContactId as part of the report.
  6. Add a column to the excel spreadsheet called RosterId
  7. Go to the roster page that represents the contacts that were exported (i.e. Class of 99)
  8. On the URL will be a 15 (or 18) digit ID. Select and Copy that ID
  9. Paste it into the RosterId column and set it for all of the rows
  10. Perform an Insert to your junction object using the DataLoader or Import functions within Salesforce
  11. Make sure to map the RosterId amd ContactID to the appropriate fields in your junction object

The end result should be a roster in Salesforce.

There are a few problems with my approach that may be deal breakers:

1) This is not real time (i.e. has no trigger) so you have to run the report and import after the roster is final and any further changes would need to be manually updated. 2) If there are a lot of variations of the roster then it would be time prohibitive.

However if the roster is more or less finalized and not subject to change often and if there are only a few rosters per year then this may be easier than having to maintain code etc...

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.