Trigger
trigger LiveChatTranscriptEventTrigger on LiveChatTranscriptEvent (before delete) {
/**
* trigger runs
*
*/
ClsTriggerFactory.createHandler(LiveChatTranscriptEvent.sObjectType);
}
Apex Class
@name ClsTriggerLiveChatTranscriptEventHandler
public without sharing class ClsTriggerLiveChatTranscriptEventHandler extends ClsTriggerVirtual {
/**
* @see IntHelper.beforeTrigger
*/
public override void beforeTrigger(ClsWrappers.TriggerContext trgCtx) {
if (trgCtx.IsInsert){
}
if(trgCtx.isUpdate){
}
if(trgCtx.isDelete){
blockDelete(trgCtx);
}
}
/**
* @see IntHelper.afterTrigger
*/
public override void afterTrigger(ClsWrappers.TriggerContext trgCtx) {
}
/**
* Block Usere to Delete LiveChatTranscriptEvent record if his profile not in Validation_Override__c.Exclude__c
*/
@TestVisible
private void blockDelete(ClsWrappers.TriggerContext trgCtx) {
Validation_Override__c mc = Validation_Override__c.getInstance(UserInfo.getProfileId());
system.debug('mc= '+mc.Exclude__c);
if (!mc.Exclude__c){
for(sobject so : trgCtx.oldList){
LiveChatTranscriptEvent liveEvent = (LiveChatTranscriptEvent)so;
liveEvent.addError('Live Chat Transcript Event can not be deleted');
}
}
}
}
Test Class
@isTest(seeAllData = false)
public class ClsTriLiveChatTransEvtHandlr_Test{
static testMethod void getevent(){
/*
insert Live Chat Visitor
*/
LiveChatVisitor lcv = new LiveChatVisitor();
try{
insert lcv;
}catch(Exception e){}
/*
insert Live Chat Transcript
*/
LiveChatTranscript lct = new LiveChatTranscript();
lct.LiveChatVisitorid = lcv.id;
try{
insert lct;
}catch(Exception e){}
system.debug('lct' + lct);
/*
insert Live Chat Transcript Event
*/
LiveChatTranscriptEvent le = new LiveChatTranscriptEvent();
le.LiveChatTranscriptId = lct.id;
le.type = 'ChatRequest';
le.time = system.now();
try{
insert le;
}
catch(Exception e){}
try{
delete le;
}
catch(Exception e){}
}
}
trigger LiveChatTranscriptEventTrigger on LiveChatTranscriptEvent (before delete) {
/**
* trigger runs
*
*/
ClsTriggerFactory.createHandler(LiveChatTranscriptEvent.sObjectType);
}
Apex Class
@name ClsTriggerLiveChatTranscriptEventHandler
public without sharing class ClsTriggerLiveChatTranscriptEventHandler extends ClsTriggerVirtual {
/**
* @see IntHelper.beforeTrigger
*/
public override void beforeTrigger(ClsWrappers.TriggerContext trgCtx) {
if (trgCtx.IsInsert){
}
if(trgCtx.isUpdate){
}
if(trgCtx.isDelete){
blockDelete(trgCtx);
}
}
/**
* @see IntHelper.afterTrigger
*/
public override void afterTrigger(ClsWrappers.TriggerContext trgCtx) {
}
/**
* Block Usere to Delete LiveChatTranscriptEvent record if his profile not in Validation_Override__c.Exclude__c
*/
@TestVisible
private void blockDelete(ClsWrappers.TriggerContext trgCtx) {
Validation_Override__c mc = Validation_Override__c.getInstance(UserInfo.getProfileId());
system.debug('mc= '+mc.Exclude__c);
if (!mc.Exclude__c){
for(sobject so : trgCtx.oldList){
LiveChatTranscriptEvent liveEvent = (LiveChatTranscriptEvent)so;
liveEvent.addError('Live Chat Transcript Event can not be deleted');
}
}
}
}
Test Class
@isTest(seeAllData = false)
public class ClsTriLiveChatTransEvtHandlr_Test{
static testMethod void getevent(){
/*
insert Live Chat Visitor
*/
LiveChatVisitor lcv = new LiveChatVisitor();
try{
insert lcv;
}catch(Exception e){}
/*
insert Live Chat Transcript
*/
LiveChatTranscript lct = new LiveChatTranscript();
lct.LiveChatVisitorid = lcv.id;
try{
insert lct;
}catch(Exception e){}
system.debug('lct' + lct);
/*
insert Live Chat Transcript Event
*/
LiveChatTranscriptEvent le = new LiveChatTranscriptEvent();
le.LiveChatTranscriptId = lct.id;
le.type = 'ChatRequest';
le.time = system.now();
try{
insert le;
}
catch(Exception e){}
try{
delete le;
}
catch(Exception e){}
}
}
I read your articles very excellent and i agree our all points because all is very good information provided this through in the post.
ReplyDeleteVisitor Management System
Visitor Management System Dubai
Visitor Management Software Dubai
Visitor Management System UAE
Visitor Management Software
Visitor Management App
This is a great article thanks for sharing this informative information. I will visit your blog regularly for some latest post. I will visit your blog regularly for Some latest post. free online chat rooms
ReplyDeleteI enjoy every one of the post, My spouse and i liked, I might like additional data using this type of, since it can be pretty nice., Regards created for supplying. live chat support service provider
ReplyDeleteWe believe in customer satisfaction. Our Leather Jackets are delicately and uniquely tailored, and the comfort of our customers is always prioritizing. We guarantee the quality of our product and take full responsibility to satisfy our customer’s needs. Guess Bags For Women
ReplyDeleteWe guarantee to bring you the grand quality material and leather that includes Sheepskin, Lambskin, Faux leather, Suede leather, and Distressed Leather. Mens Biker Jacket
ReplyDeleteIt is the easiest element in the world, but overall the notion is quite sound. freechat
ReplyDeletethis is the best information i will implement this
ReplyDeletevisitor management system
visitor management software
multi tenant visitor management system
labour management system
contract labour management system
contract labour management software
labour management system registration
Labour management system
labour management