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
Pankaj Chauhan 11Pankaj Chauhan 11 

count number of records created(lookup) in a field


Hi guys,

I have 2 custom objects (Management and ReportsandDashboards)
I have a field name flat section in management .So i have to count total no. of flat records created in management  by creating a field in 
ReportsandDashboards

I've tried creating a formula field, but not it's not clear to me what the formula should be.
I also tried creating an Apex trigger. However, I couldn't get the select statement to work.

I want a field in ReportsandDashboards that is readonly and counts the number of time the field flat is used in the Management .

Please advice the correct way to approach this :)
ANUTEJANUTEJ (Salesforce Developers) 
Hi Pankaj,

To my knowledge, I think you would be able to give read access to that particular field and you should be able to use process builder or flows to implement the usecase, for reference please find the below link to implement using a trigger,

>> https://developer.salesforce.com/forums/?id=906F0000000BYzFIAW


>> https://salesforce.stackexchange.com/questions/132853/visual-flow-count-number-of-child-records

I hope this helps in your use case.

Regards,
Anutej
shaik murthujavalishaik murthujavali
Hi,
Use the below query.
Integer totalnoofrecords = [select count(Id) From management__c];
Hope above will work for your requirement.
Otherwise please provide enough details here to give you best sollution. like relation b/w those two objects, etc.

Thanks.