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
Roopa S 1Roopa S 1 

whenevr the account is inserted i nned to populate accounts description field as " account is inserted"and if its updated should populate description field as " account updated"

Sai PraveenSai Praveen (Salesforce Developers) 
Hi Roopa,

There could be scenerios where the user is inserting an account and after that there may be some automation by which the account may get updated. Then what should be Description field.

Thanks,
 
Roopa S 1Roopa S 1
@Sai Praveen
then also it should be "account is updated" 
Sai PraveenSai Praveen (Salesforce Developers) 
Hi Roopa,

Can you try the below code.
 
trigger AccountTrigger on Account (before insert,before update) {
    If(Trigger.isinsert && Trigger.isBefore){
        for (Account acc:Trigger.new){
            acc.Description='account is inserted';
        }
    }
    If(Trigger.isupdate && Trigger.isBefore){
        for (Account acc:Trigger.new){
            acc.Description='account is Updated';
        }
    }
}

If this solution helps, Please mark it as best answer.

Thanks,
​​​​​​​