+ Start a Discussion
Steve_WSteve_W 

Trying to retrieve a field value from a related record for validation

I am trying to get a value from a picklist field on an object that has a lookup field to the objet that my trigger is running on. The purpose of the trigger is to prevent updates or deletion to a Quote Line Item record based on certain picklist values on the Trial__c object.

 

trigger QuoteLineItemStopDelete on QuoteLineItem (before delete, before update) {

if(Trigger.isDelete){
  for(QuoteLineItem qli : Trigger.old){
      List <Trial__c> Tr = [Select id, Quote__c, Trial_Sub_Status__c from Trial where Quote__c = qli.QuoteId ];

 

I am getting an unexpected token error relating to the qli.QuoteId field, can anyone explain what i am doing wrong? I want to get the id of Trial__c record where the QuoteId from the QuoteLineItem equals the Quote__c id from the Trial__c object.

 

Thanks