You need to sign in to do that
Don't have an account?
Anju Alexander 5
Trigger
Hi All,
I have written a trigger on case. The trigger was to populate the entitlement field(which is a lookup to entitlement) with the entitlements of the Accounts .Here entitlements are child objects of accounts. If I am creating a case from the console the entitlement field is getting populated with the value. But if I am creating a case from web to case form the entitlement field is not getting populated with the value,..even if a match is found between the contacts and accounts.
Please help.
Thanks.
I have written a trigger on case. The trigger was to populate the entitlement field(which is a lookup to entitlement) with the entitlements of the Accounts .Here entitlements are child objects of accounts. If I am creating a case from the console the entitlement field is getting populated with the value. But if I am creating a case from web to case form the entitlement field is not getting populated with the value,..even if a match is found between the contacts and accounts.
Please help.
Thanks.
This is my trigger code:
trigger EntitlementTrigger on Case (before insert) {
Map<id,Account> accountMap=new Map<id,Account>();
Map<id,Entitlement> entMap=new Map<id,Entitlement>();
Set<id> caseSet=new Set<id>();
List<Case> caseList=new List<Case>();
if((Trigger.isInsert) && (Trigger.isBefore)){
for(Case c:trigger.new)
{
caseMap.add(c.accountId);
}
for(Account c:[select id,name from Account where Id in :caseSet])
{
accountMap.put(c.id,c);
System.debug('.......'+accountMap);
}
for(Entitlement e:[select id,name,AccountId from Entitlement where accountId in :accountMap.keySet()])
{
entMap.put(e.accountId,e);
System.debug('.......'+entMap);
}
for(Case c: Trigger.new)
{
if(c.EntitlementId==null && c.accountId!=null && c.accountId==accountMap.get(c.accountID).ID)
{
if(entMap.containsKey(c.accountId))
{
c.EntitlementId=entMap.get(c.accountId).id;
caseList.add(c);
}
}
}
}
}
Thanks.
Please help me to find the solution for this....I am still not getting it..
Thanks