Creating Predefined Case Teams and Assigning Case Teams to Cases using APEX
Trigger to Create Case Team Member Role:
Trigger CreateMemberRole on
user (before insert,before update)
{
caseteamrole cr=new caseteamrole();
cr.accesslevel='edit';
cr.name='test';
cr. PreferencesVisibleInCSP=true;
insert(cr);
}
Trigger to Create Predefined Case Team:
trigger CreateCaseTeam on User (before insert,before update)
{
caseteamtemplate ct;
caseteamrole cr;
caseteamtemplate c;
try{
cr=[select id from caseteamrole where name=:'test'];
ct=[select id,name from caseteamtemplate where name=:'test'];
c=ct;
}
catch(Exception e)
{
if(ct==null)
{
//create case team template
c=new caseteamtemplate();
c.Description='test';
c.Name='test';
insert(c);
}
}
//add case team member to pre defined case team
caseteamtemplatemember cm=new caseteamtemplatemember();
cm.memberid=trigger.new[0].id;
cm.teamroleid=cr.id;
cm.teamtemplateid=c.id;
insert(cm);
}
caseteamtemplaterecord cttr=new caseteamtemplaterecord();
cttr.parentid=trigger.new[0].id;
caseteamtemplate ct=[select id from caseteamtemplate where name=:'test'];
cttr.teamtemplateid=ct.id;
}
Assigning Case Team to a Case:
Trigger AssignToCase on user (before insert,before update)
{
caseteamrole cr=new caseteamrole();
cr.accesslevel='edit';
cr.name='test';
cr. PreferencesVisibleInCSP=true;
insert(cr);
}
No comments:
Post a Comment