You need to sign in to do that
Don't have an account?
It just me!
Cannot save a trigger during parse and save class call
So my goal is to be able to have a primary record for one for my related object. I'm currently getting an error.
Space__c is my main object
Lease__c is my related object
current_lease__c is the check box.
Here's my error:
Error: Compile Error: Cannot save a trigger during a parse and save class call at line -1 column -1
Any idea?
Space__c is my main object
Lease__c is my related object
current_lease__c is the check box.
Here's my error:
Error: Compile Error: Cannot save a trigger during a parse and save class call at line -1 column -1
trigger CurrentLease on Lease__c (Before Insert, Before Update, After Insert, After Update, After Delete, After UnDelete) { Set <Id> filesId = new Set <Id> (); set <Id> objectsID = new Set <Id> (); for (Lease__c files : Trigger.new) { //Check if trigger.new Primary_file__c is TRUE System.debug('files.Current_Lease__c: '+files.Current_Lease__c); if (files.Current_Lease__c){ //Add the Id to a list of ids filesId.add(files.Id); objectsID.add(files.Space__c); } } System.debug('Object: ' + objectsID); //Query the ids from object where Primary_file__c is TRUE and is not new List <Lease__c> filesList = new List <Lease__c> ( [select id, Current_Lease__c from Lease__c where Current_Lease__c = true and id not in :filesID and Space__c in :objectsID] ); //System.debug('filesList: '+ filesList); System.debug('filesList.size(): ' + filesList.size()); for (Lease__c files : Trigger.new) { if (filesList.size() > 0){ files.Id.AddError('You cannot have more than one Current Lease'); } } }
Any idea?
Please check your trigger extension, it should be .trigger not .cls .
Also remember if you are creating in vs code then it should be in under trigger folder instead of class folder.
Please check and revert if any concern.
If it is correct answer then please marked as correct answer.
Good Luck..