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
foodrunnerfoodrunner 

Compile Error: Expression cannot be assigned at line -1 column -1

In this workflow I have created a new record from the creation of an opportunity product record in a separate trigger. After the creation of the second record, I am needing to update the opportunity product record with the lookup value. With opportunity product records I can unable to use the object in a UI lookup field. I am receiving the following error:

 

Compile Error: Expression cannot be assigned at line -1 column -1  

 

Here is the trigger:

trigger LinkonOLI on Manufacturing_Design_Sheet__c (after insert) {

   Set<Id> mids = new set<Id>();
   for(Manufacturing_Design_Sheet__c m : trigger.new){
   mIds.add(m.OpportunityLineItemID__c);
   
   }
    System.debug('****1 : m Id size '+ mIds.size());

    List<Manufacturing_Design_Sheet__c> mds = [SELECT Id, name, OpportunityLineItemID__c
     FROM Manufacturing_Design_Sheet__c  
        WHERE createddate =: system.now() and createdbyId = :UserInfo.getUserId() limit 1]; 
       
  
    If(OpportunityLineItem.id = Manufacturing_Design_Sheet__c.OpportunityLineItemID__c){
     OpportunityLineItem.spec_sheet__c = Manufacturing_Design_Sheet__c.OpportunityLineItemID__c;
   }
}      

 

How do I solve the error?

 

Thank you,

dmchengdmcheng

I don't understand your WHERE clause:

WHERE createddate =: system.now() and createdbyId = :UserInfo.getUserId() limit 1

 

Aren't you just selecting the record that was just inserted?  And anyway, system.now() returns DateTime including seconds, so it may not match the CreatedDate datetime value.

foodrunnerfoodrunner

Good Point. I was not sure so I included the where clause just to be conservative in the codiing. I have changed the code and have the following error now:

Error: Compile Error: Initial term of field expression must be a concrete SObject: LIST<Manufacturing_Design_Sheet__c> at line 15 column 42

 New version of trigger:

trigger LinkonOLI on Manufacturing_Design_Sheet__c (after insert) {

   Set<Id> mids = new set<Id>();
   for(Manufacturing_Design_Sheet__c m : trigger.new){
   mIds.add(m.OpportunityLineItemID__c);
   
   }
    System.debug('****1 : m Id size '+ mIds.size());

    List<Manufacturing_Design_Sheet__c> mds = [SELECT Id, name, OpportunityLineItemID__c
     FROM Manufacturing_Design_Sheet__c]; 
       
  
    If(OpportunityLineItem.id = mds.OpportunityLineItemI​D__c){
     OpportunityLineItem.spec_sheet__c = mds.OpportunityLineItemI​D__c;
   }
}

 

How to I make the field expression concrete?

 

Thank you

dmchengdmcheng
OpportunityLineItem[] opplineitems = [select from blah blah blah];

 for(Manufacturing_Design_Sheet__c mds : trigger.new){
   for(OpportunityLineItem oli : opplineitems) {
    if(oli.Id = mds_opp_line_item__c) {
      oli.man_design_sheet__c = mds.Id;
    }
   }
}
update opplineitems;

You don't need to select the mds records because you already have them in the Trigger.New.  What you need to retrieve are the OpportunityLineItems based on the set of opplineitem IDs you created. Then you do a double FOR loop so you can match  the OLI to the mds and do your assignment.

 

 

 

Pradeep_NavatarPradeep_Navatar

I feel that there is a problem with your if condition. Try changing the condition as given below :

 

if(OpportunityLineItem.id == Manufacturing_Design_Sheet__c.OpportunityLineItemID__c){OpportunityLineItem.spec_sheet__c = Manufacturing_Design_Sheet__c.OpportunityLineItemID__c;}

 

Hope this helps.