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
K_devK_dev 

Error: Compile Error: Illegal assignment from String to SOBJECT:Account at line 18 column 13

 

can anyone help about this error

 

trigger createopp on Call_Abandon_List__c (after insert,after update)
{
List<opportunity> opps=new List<opportunity>();
for(Call_Abandon_List__c ca:Trigger.New)
{
if(Trigger.IsInsert && ca.Status__c=='converted')
{
opportunity O=new Opportunity();
O.Name='ca.Name';
O.Product_Id__c=ca.Product__c;

opps.add(O);
}
if(Trigger.IsUpdate && ca.Status__c!=Trigger.oldMap.get(ca.Id).Status__c && ca.Status__c=='converted')
{
opportunity o=new Opportunity();
O.Name=ca.Name;
o.Account = 'ca.Account__c';
o.Product_Id__c=ca.Product__c;
o.StageName = 'New';
o.CloseDate=Date.today();
o.LeadSource = 'Abandon List';
o.Secondary_Owner__c = ca.Owner.Name;
o.Converted_to_Opportunity__c=true;
opps.add(o);

}
}

if(!opps.IsEmpty())
{
try
{
insert opps;
}
catch(Exception e){system.debug(e);}
}
}

ReidCReidC

You have single quotes around the ca.Account__c statement.  That makes it a string.

K_devK_dev

REMOVING SINGLE QUOTES STILL CAUSING THE SAME ERROR

ReidCReidC
What value do you have in ca.Account__c? Is it a string?
K_devK_dev

IT IS A LOOKUP TO ACCOUNT

K_devK_dev

i WANT TO INSERT OPPORTUNITY WITH REQUIRED FIELDS ACCOUNT NAME MUST BE MAPPED TO ACCOUNT LOOKUP ON CALL LIST OBJECT

ReidCReidC
DID YOU TRY

o.AccountId = ca.Account__c;

THE

o.Account

ISN'T A FIELD THAT WILL ACCEPT AN ID.
TO SEE THE FIELD NAMES YOU SHOULD OPEN THE OPPORTUNITY OBJECT IN DEVELOPER
CONSOLE.
IT SHOWS YOU EVERYTHING.

PS WHY ARE WE YELLING AT EACH OTHER IN ALL CAPS?
K_devK_dev

Yes thanks !! it worked

K_devK_dev

o.Owner = '00GQ0000001wKES';

how to assign queue for the opportunity owner while inserting?

ReidCReidC
you need o.OwnerId.

>From the docs about the OwnerId field, which when I read them leads me to
believe Oppties can't be owned by queues.

OwnerIdTypereferencePropertiesCreate, Defaulted on create, Filter, Group,
Sort, UpdateDescriptionID of the User who has been assigned to work this
opportunity.

If you update this field, the previous owner's access becomes Read Only or
the access specified in your organization-wide default for opportunities,
whichever is greater.

If you have set up opportunity teams in your organization, updating this
field has different consequences depending on your version of the API:

- For API version 12.0 and later, sharing records are kept, as they are
for all objects.
- For API version before 12.0, sharing records are deleted.
- For API version 16.0 and later, users must have the ?Transfer Record?
permission in order to update (transfer) account ownership using this field.
K_devK_dev

There is only one queue available and can we extract by soql and assign it

ReidCReidC
When you assign it, does it work? I haven't tried, only looking at the
docs.
K_devK_dev

o.StageName = 'New';
o.CloseDate=Date.today();

 

is showing that insert failed because of these fields?how to make opportunity stage = new and closedate = today

K_devK_dev
System.DmlException: Insert failed. First exception on row 0; first error: REQUIRED_FIELD_MISSING, Required fields are missing: [Stage, Close Date]: [Stage, Close Date]
ReidCReidC

If I were you I'd back up and make sure you can get the simplest possible insert to work.

I'm not sure why your insert isn't working.

However, in the Developer Console's Execute Anonymous windo on a standard Developer Edition, this code works very easily:

 

Opportunity o = new Opportunity();
o.Name = 'Sample Oppty';
o.StageName = 'Prospecting';
o.CloseDate = Date.today();
insert o;

 Once you have the minimum possible insert working, start adding additional code around it.