You need to sign in to do that
Don't have an account?
Ramanjot Sidhu
Compile Error: Loop with query must provide a statement at line 4 column 12
I am trying to update parent stage(Opportunity: StageName) with child stage (Line_item__c : Stage__C) and get the error:
Compile Error: Loop with query must provide a statement at line 4 column 12
trigger ControlOpportunityStage on Line_Item__c (after update) {
List<Opportunity> parentlist = new List<Opportunity>();
List<Opportunity> opportunityId = new list<Opportunity>();
for(Line_item__c lirecord : [SELECT Opportunity__r.id, Opportunity__r.StageName from Line_item__c
where Line_item__c.Opportunity__c <> null]);{
for(Opportunity opt : parentlist)
if(Opportunity.StageName != Line_item__c.Stage__c){
Opportunity.StageName = Line_item__c.Stage__c;
optId.add(opt);
}
}
if(opportunityId != null & opportunityId.Size()>0)
upsert opportunityId;
}
Compile Error: Loop with query must provide a statement at line 4 column 12
trigger ControlOpportunityStage on Line_Item__c (after update) {
List<Opportunity> parentlist = new List<Opportunity>();
List<Opportunity> opportunityId = new list<Opportunity>();
for(Line_item__c lirecord : [SELECT Opportunity__r.id, Opportunity__r.StageName from Line_item__c
where Line_item__c.Opportunity__c <> null]);{
for(Opportunity opt : parentlist)
if(Opportunity.StageName != Line_item__c.Stage__c){
Opportunity.StageName = Line_item__c.Stage__c;
optId.add(opt);
}
}
if(opportunityId != null & opportunityId.Size()>0)
upsert opportunityId;
}
Try this and let me know.
Best Regards,
-Vivek
All Answers
Try this and let me know.
Best Regards,
-Vivek
Hi, I tried the new trigger, but now i get the following error:
Error: Compile Error: Expression cannot be assigned at line -1 column -1
paste your code and let me check
Best Regards,
-Vivek
Hi Vivek, I used the same code but removed the semi colon,
trigger ControlOpportunityStage on Line_Item__c (after update) {
List<Opportunity> parentlist = new List<Opportunity>();
List<Opportunity> opportunityId = new list<Opportunity>();
for(Line_item__c lirecord : [SELECT Opportunity__r.id, Opportunity__r.StageName from Line_item__c
where Line_item__c.Opportunity__c <> null]){
for(Opportunity opt : parentlist)
if(Opportunity.StageName != Line_item__c.Stage__c){
Opportunity.StageName = Line_item__c.Stage__c;
optId.add(opt);
}
}
if(opportunityId != null & opportunityId.Size()>0)
upsert opportunityId;
}
I am trying to update the picklist field on the parent object (Opportunity), using the child object picklist field
Opportunity - StageName
Line_item__c - Stage__c
Picklist values:
Engagement Intended
Engagement - Not Commited
Verbal Commitment
Signed Commitment
Closed Won
Closed Lost
When I update the stage field on my custom object (child object), I want to create at rigger to automatically update the stage field on the opportunity object.
Error: Compile Error: Expression cannot be assigned at line -1 column -1
trigger ControlOpportunityStage on Line_Item__c (after update) {
List<Opportunity> parentlist = new List<Opportunity>();
List<Opportunity> opportunityId = new list<Opportunity>();
for(Line_item__c lirecord : [SELECT Opportunity__r.id, Opportunity__r.StageName from Line_item__c
where Line_item__c.Opportunity__c <> null]){
for(Opportunity opt : parentlist)
if(Opportunity.StageName != Line_item__c.Stage__c)
Opportunity.StageName = Line_item__c.Stage__c;
opportunityId.add(opportunity.Id);
{
if(opportunityId != null & opportunityId.Size()>0)
update opportunityId;
}
}
}
For me it's wokring fine . please let me know what steps you following.
Regards,
-Vivek
Please mark the Best Answer.
Regards,
-Vivek