+ Start a Discussion
Saurabh Kumar 284Saurabh Kumar 284 

Write an apex trigger on Account with value "cold" if the rating field is blank.

Write an apex trigger on Account to Populate the Rating field with value as "Cold" if the account record is initially created with a blank Rating value
Best Answer chosen by Saurabh Kumar 284
ANUTEJANUTEJ (Salesforce Developers) 
Hi Saurabh,

Can you try the below trigger once and check if this works:

trigger acctri on account(before insert)
{
if(trigger.isbefore && trigger.isinsert)
{
for(Account a:trigger.new)
{
if(String.isBlank(a.rating__c))
{a.rating='cold';}}}}

I hope this helps and in case if this comes in handy can you please choose this as the best answer so that it can be useful for others in the future.

Regards,
Anutej

All Answers

Andrew GAndrew G
you should really wait for an answer before spamming the forum with the same request over and over.
Saurabh Kumar 284Saurabh Kumar 284
Sorry it's my bad. actually i didn't write the question in a proper manner that's why i had deleted the earlier one. Thanks & Regards, *Saurabh Kumar.* Mob: +91-9910098410
ANUTEJANUTEJ (Salesforce Developers) 
Hi Saurabh,

Can you try the below trigger once and check if this works:

trigger acctri on account(before insert)
{
if(trigger.isbefore && trigger.isinsert)
{
for(Account a:trigger.new)
{
if(String.isBlank(a.rating__c))
{a.rating='cold';}}}}

I hope this helps and in case if this comes in handy can you please choose this as the best answer so that it can be useful for others in the future.

Regards,
Anutej
This was selected as the best answer
Saurabh Kumar 284Saurabh Kumar 284
Thanks, Anutej.
sure I will mark it as the best answer once I have to verify the same.