You need to sign in to do that
Don't have an account?
Visithra
Kindly help in trigger, am getting this error for if rating is hot and Annual revenue is blank i need to set as 20k, where did i made mistake
Here is my code,
When BEFORE_INSERT
{
for(Account accRecord: Trigger.new){
if(accRecord.Rating=='Hot')
{
if(String.isBlank(accRecord.AnnualRevenue))
{
accRecord.AnnualRevenue=20000;
}
}
}
}
Getting error as:
Method does not exist or incorrect signature: void isBlank(Decimal) from the type String
When BEFORE_INSERT
{
for(Account accRecord: Trigger.new){
if(accRecord.Rating=='Hot')
{
if(String.isBlank(accRecord.AnnualRevenue))
{
accRecord.AnnualRevenue=20000;
}
}
}
}
Getting error as:
Method does not exist or incorrect signature: void isBlank(Decimal) from the type String
The error occurs because the isBlank method in the String class does not accept a Decimal argument. The isBlank method is used to check if a String is empty or contains only whitespace.
In your code, the AnnualRevenue field is of type Decimal, so you need to use a different approach to check if it is blank or has a value.
Here's the updated code for your trigger: In the updated code:
The trigger operates on the Account object before the records are inserted (before insert).
The loop iterates over the Trigger.new collection, which contains the records being inserted.
For each Account record, it checks if the Rating field is 'Hot' and if the AnnualRevenue field is null (blank).
If both conditions are true, it sets the AnnualRevenue field to 20000.
Hope this helps !
Thank you.
Hi visi,
The error you're encountering indicates that the isBlank() method is not available for the Decimal data type. The isBlank() method is specifically designed for String data types. To check if a Decimal field is blank or empty, you can use a different approach.
Here's an updated version of your trigger code that performs the desired check for AnnualRevenue:
In this code, the isBlank() method is replaced with a null check (accRecord.AnnualRevenue == null) to determine if the AnnualRevenue field is empty. If it is empty, the code sets the AnnualRevenue to the desired value of 20000.
Make sure to save and deploy the updated trigger code to your Salesforce org to apply the changes.
Hope this will be helpful.
Thanks!