function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Nickname7Nickname7 

Ability to use a Text field as ID referring to different objects

I'm trying to record activity on several different objects for reporting purposes. In order to do this, I can probably have an activity object for each object that needs to be associated with, and also add a relationship between the activity object and the target object. However, this means that I will need to have many objects and many different reports.

 

Instead, can I have a generic "activity" object that will have a generic "objectId" field that is not a relational field but it can refer to object A, object B etc. ?At the same time, I will also have to store a "type" field on my activity to store if the activity is for object A or object B, etc.

 

I can build custom apex classes and visualforce stuff to properly populate these activity objects, however, can I use the standard reporting features of SFDC? Am I cornering myself with this approach?

 

Any input will be appreciated!

Shashikant SharmaShashikant Sharma

If you will use text field for storing id, it will be ok for you to make SOQL in apex but you will not see activity in related list, if you want refer to any field of your object using salesforce's any antive facilities like validation rule, formula ( report as well i think). You will not be able to refer to related objects fields.

Cory CowgillCory Cowgill

No you will not be able to perform Standard Salesforce Reporting with your approach of posting an ID into a Text Field.

 

If you do not have a relationship field (Lookup or Master Detail) than Salesforce cannot tell this is a foreign key field. This is what Shashikant was saying when he mentions you will not get a related list.

 

If you are willing to recreate all the functionality using Visualforce Pages than you may be ok, but anything you want to do with that field will require custom coding development.

 

1. You won't get the Lookup Seach Box (Magnifying Glass) on screens - You'd need to recreate in a VF Page.

2. You can't use Salesforce Reports to report on relationships with that field - You'd need to create custom VF Pages to simluate Reports.

3. You won't get Related Lists on records - You would need to recreate custom VF Pages with DataTables to recreate related lists

4. You won't be able to do nested SOQL queries in your Apex. You'll need seperate queries to pull in the related objects.

 

Basically I wouldn't advise recreateing this functionality as your losing so much core functioanlity in Salesforce unless there is absolutely no way you can get around it.

 

 

SAPOCSAPOC

whenever you create custom object who have option to Allow Activities(checkbox) on that object.you can Check this for the objects who are working on. Reporting also is easy as you are using salesforce Activities Object.