You need to sign in to do that
Don't have an account?

How to get count of all selected fields in a record?
Let consider an object has 10 fields and one more field called CountField. If I enter a value for field1 and if i save it, Then the CountField value should be updated with 1. Same like that if I enter value for field1 and field2, Then the CountField field value should be updated with 2. Even if i enter a values for field1, field3, field9 and field5, then the CountField should be updated with 4 . Like that i enter values for all fields, then countfield vlaue should be 10. Which means how many fields i entered values, the same value should be updated with CountField.
I have tried alot. but i could not get any logic. Please provide some solution
Note: The value for countfield in image is entered by me manually. I want it automatically updated.
Thanks
KS Kumar
As far as I understood, your requirement is to check how many fields are filled by the user and count them. You can simply check against the NOT NULL fields in a trigger and update the count. Please check below for a smaple trigger. Here I have manually given a list of fields to check. You can dynamically get fields from Schema class as well.
All Answers
If it is custom page then we can use java script or jquery else we need to write the trigger and compare the old and new value.. on the basis of that we can update that field.
Please let me know if this helps you.
Thanks,
You can achive it through trigger ,however i have questions here .Why you want to count this ? If you will updated the record for first time and modified two fields then the count will be updated to 2 .When you wil update second time and updated 3 fields then your count will be 5 or 3 .
Problem is that when you will add any fields in the object you need to modify the trigger .
If you are ok with above problem then let us know what exactly how you want to update the field ,so that we wil help you out .
Thanks
Manoj
Hi Manoj....!
I unsterstood your question. let we take 10 fields only and we can do on that
try like below and modify accordigly .
Thanks
Manoj
As far as I understood, your requirement is to check how many fields are filled by the user and count them. You can simply check against the NOT NULL fields in a trigger and update the count. Please check below for a smaple trigger. Here I have manually given a list of fields to check. You can dynamically get fields from Schema class as well.