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 

System.DmlException: Insert failed. ,: [Stage, Close Date]: [Stage, Close Date]

Can anyone please let me know why it is not taking the stage and close date in the trigger.

 

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);
}
*/
// after update
if(Trigger.IsUpdate && ca.Status__c!=Trigger.oldMap.get(ca.Id).Status__c && ca.Status__c=='converted'&&ca.Converted_to_Opportunity__c==false)
{
opportunity o=new Opportunity();
O.Name=ca.Name;
o.Accountid = ca.Account__c;
o.Product_Id__c=ca.Product__c;
o.StageName = 'New';
o.Probability = 10;
o.CloseDate= System.today();
o.LeadSource = 'Abandon List';
o.Secondary_Owner__c = ca.Ownerid;
o.Ownerid = '00GQ0000001wKES';
opps.add(o);
o.Converted_to_Opportunity__c=true;

}
}

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

MaxPowerForceMaxPowerForce

Does it work if you change:

 

if(Trigger.IsUpdate && ca.Status__c!=Trigger.oldMap.get(ca.Id).Status__c && ca.Status__c=='converted'&&ca.Converted_to_Opportu

nity__c==false)

 

to

 

if(true)

 

If so, remove the conditions one by one until you find the problem.

sambasamba

If you still have not solved this issue. You can send your develope account to my email. I will help you to check it if i have some time.

 

 

Thanks,

Samba

K_devK_dev
Yes Samba,

? ? I figured out it is because of ownerid assigning to queue.Now i just need test class for it.can u helpme.


?
Thanks,

Kiran A.
201-888-3735.
sambasamba

Yes, you need to tell me sandbox username and password. Thanks.

 

 

Thanks,

Samba

K_devK_dev
yes samba,

Please check my dev org.There is one create opp and another create oli please complete the test class.

kamada@stansberryresearch.com.dev1
SAIbaba99
?
Thanks,

Kiran A.
201-888-3735.
sambasamba

Hi Kiran, can you send verification code to my email?

K_devK_dev
81600
?
Thanks,

Kiran A.
201-888-3735.