Error: Compile Error: Variable does not exist: contactIds at line 5 column 39, It also doesn't like this line either Where e.AccountId in :acctIds And e.EndDate >= Today
Do I have to enable something to get this code to work? I am trying to figure out what I missed.
trigger DefaultEntitlement on Case (Before Insert, Before Update) { List <EntitlementContact> entlContacts = [Select e.EntitlementId,e.ContactId,e.Entitlement.AssetId From EntitlementContact e Where e.ContactId in :contactIds And e.Entitlement.EndDate >= Today And e.Entitlement.StartDate <= Today]; if(entlContacts.isEmpty()==false){ for(Case c : Trigger.new){ if(c.EntitlementId == null && c.ContactId != null){ for(EntitlementContact ec:entlContacts){ if(ec.ContactId==c.ContactId){ c.EntitlementId = ec.EntitlementId; if(c.AssetId==null && ec.Entitlement.AssetId!=null) c.AssetId=ec.Entitlement.AssetId; break; } } } } } else{ List <Entitlement> entls = [Select e.StartDate, e.Id, e.EndDate, e.AccountId, e.AssetId From Entitlement e Where e.AccountId in :acctIds And e.EndDate >= Today And e.StartDate <= Today]; if(entls.isEmpty()==false){ for(Case c : Trigger.new){ if(c.EntitlementId == null && c.AccountId != null){ for(Entitlement e:entls){ if(e.AccountId==c.AccountId){ c.EntitlementId = e.Id; if(c.AssetId==null && e.AssetId!=null) c.AssetId=e.AssetId; break; } } } } } } }
1 respuesta
Hi Eric,
This community is focused on help with declarative configuration changes and non-programmatic solutions. You have a better chance of getting this issue resolved if you post it on one of the following forums [lots of talented developers out there who must have worked on similar problems before]:
StackExchange [http://salesforce.stackexchange.com]
Official Developer Forum [https://developer.salesforce.com/forums]
For any configuration changes and point and click design solutions, feel free to post in this community and we will be glad to help you out.
Cheers,
Till