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

Facing errors while excuting the code. Please help what should I do so that I can get Code excuted.
List<Account> lstAccrecords = new list<Account>();
for (integer counter = 1; counter <= 200; counter++)
{
Account Acc = new Account();
Acc.name = 'Testing for bulkification';
Acc.AnnualRevenue = '2000'+counter;
Acc.BillingAddress = 'Delhi';
Acc.Phone= '898231851'+counter;
}
if(!lstAccrecords.isempty())
{
insert lstAccrecords;
}
for (integer counter = 1; counter <= 200; counter++)
{
Account Acc = new Account();
Acc.name = 'Testing for bulkification';
Acc.AnnualRevenue = '2000'+counter;
Acc.BillingAddress = 'Delhi';
Acc.Phone= '898231851'+counter;
}
if(!lstAccrecords.isempty())
{
insert lstAccrecords;
}
All Answers
Address is the composilt field in salesforce. To learn more about it, refer this Link (https://developer.salesforce.com/docs/atlas.en-us.236.0.object_reference.meta/object_reference/compound_fields_address.htm)
Also refer this similar type of issue has been explained :-
https://salesforce.stackexchange.com/questions/84288/address-field-set-address-via-apex
Kindly mark it as the best answer if it works for you.
Thanks & Regards,
Priya Ranjan
In your case AnnualRevenue field is "Integer type".So, you have to remove quotes for 2000 as below.
The below logic will be helpful for you to resolve your issue.
List<Account> lstAccrecords = new list<Account>();
for (integer counter = 1; counter <= 200; counter++)
{
Account Acc = new Account();
Acc.name = 'Testing for bulkification';
Acc.AnnualRevenue = 2000+counter;
Acc.BillingAddress = 'Delhi';
Acc.Phone= '898231851'+counter;
}
if(!lstAccrecords.isempty())
{
insert lstAccrecords;
}
Please mark as best answer,If its helped you on code execution.
Regards
Prabhakar.T
for (integer counter = 1; counter <= 200; counter++)
{
Account Acc = new Account();
Acc.name = 'Testing for bulkification';
Acc.AnnualRevenue = 2000+counter;
Acc.BillingAddress = 'Delhi';
Acc.Phone= '898231851'+counter;
lstAccrecords.add(Acc);
}
if(!lstAccrecords.isempty())
{
insert lstAccrecords;
}