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

Display the account count
Hi everyone,
I created one custom filed accountcount and when ever new account created, count is reflected in that filed.
now requirement is like " need to display the message when the record is created and need to display the message like this the 48th record".
below is the code for account count, and i want to display the message.could anyone please sugggest me how to achieve this?
public class CountAccount {
public static void accountscount(List<Account> accs)
{
Decimal CountOfAccount=[Select COUNT() From Account];
for(Account a:accs)
{
a.AccountCount__c=CountOfAccount+1;
CountOfAccount=a.AccountCount__c;
}
}
}
I created one custom filed accountcount and when ever new account created, count is reflected in that filed.
now requirement is like " need to display the message when the record is created and need to display the message like this the 48th record".
below is the code for account count, and i want to display the message.could anyone please sugggest me how to achieve this?
public class CountAccount {
public static void accountscount(List<Account> accs)
{
Decimal CountOfAccount=[Select COUNT() From Account];
for(Account a:accs)
{
a.AccountCount__c=CountOfAccount+1;
CountOfAccount=a.AccountCount__c;
}
}
}
https://salesforce.stackexchange.com/questions/41787/how-can-i-format-a-day-from-a-date-as-2nd-intead-of-2-or-3rd-instead-of-3
You can create a after trigger on account object. From there you can call your apex method. Inside the apex method, query to get the count of total account record. Get the no of recods in apex method by passing the parameter Trigger.New from trigger to apex method. Add the no of newly added account to current count of record.
Query all account. Update the custom field Count__c with the new value for all the records.
Hope this helps.
thanks for the logic
the code above I posted is perfectly working.. what i want to know is like when the new account record is created i just want to display the message " this is the account number 56".
Abdul- i will look in to that, thanks for help
Please check once sample code :
Hope this helps you!
If my answer helps resolve your query, please mark it as the 'Best Answer' & upvote it to benefit others.
Thanks
Varaprasad
@For Support: varaprasad4sfdc@gmail.com
Were you able to get this resolved?