You need to sign in to do that
Don't have an account?

Compile error- don't understand the issue here?
I'm getting an error that doesn't seem like an error...Maybe there's something I'm not seeing. Relationship is a custom object, and it's API name is Relationship__c. Can anyone help? I'm fairly new to coding. Thank you!
trigger RelationshipReverseRecord on Relationship__c (before insert, before update, before delete)
{
Set<string> rIDs = new Set<string>();
if(Trigger.isInsert)
{
for(Relationship r : Trigger.New)
{
String uID = r.parentID + r.childID;
String rID = r.childID + r.parentID;
r.UniqueID__c = uID;
r.ReverseID__c = rID;
rIDs.add(rID);
}
}
List<Relationship__c> existingReverseRecords = [SELECT UniqueID__c, Reverse_Record__c FROM Relationship__c WHERE ID IN : rIDs];
List<Relationship__c> newReverseRecords = new List<Relationship__c>();
for(Relationship__c newR : Trigger.New)
{
if(newR.ReverseID__c == existingR.UniqueID__c)
{
found = true;
break;
}
}
if(found==false && newR.ReverseRecords)
{
Relationship__c newReverse = new Relationship__c(ReverseRecord__c = true, Parent__c = newR.Child__c);
newReverse.Child__c = newR.Parent__c;
newReverseRecords.add (newReverse);
}
insert newReverseRecords;
}
Error: Compile Error: Invalid type: Relationship at line 7 column 13
for(Relationship__c r : Trigger.New)
Regards
Amrender
Ah. Duh! Thank you, I can't believe I missed that. I have one more issue that I can't seem to figure out.
Error: Compile Error: Variable does not exist: found at line 22 column 13 (It's referring to the line that says found = true).
found is a custom field on the Relationship object. I tried editing the line to found__c = true and that didn't work either. It says:
Error: Compile Error: Variable does not exist: found__c at line 22 column 13.
Any idea what I'm doing wrong here? I appreciate the help! Thank you again.
If found is a custom field use newR.found__c
Regards
Amrender