function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Cory PayneCory Payne 

Add filter to Apex Trigger

I have a simple Apex Trigger to pass data to an external system, and I'm wondering if it is possible to add a filter criteria to exclude updates made by a specific user account?

Trigger eOne_SC_RTDS_Opportunity_U on Opportunity (after update) {
set<ID> ids = Trigger.newMap.keyset(); 
eOne_SC_RTDS.Process('Opportunity','update',ids); 
}
Best Answer chosen by Cory Payne
Raj VakatiRaj Vakati
Yes you can do it like this .. here i am taking owner profile example .. 
 
Trigger eOne_SC_RTDS_Opportunity_U on Opportunity (after update) {

set<ID> ids = new Set<Id>();

for(Opportunity op :Trigger.new){
	// add what ever conditions you want
	if(op.Owner.ProfileId == 'xxx'){
		ids.add(op.Id);
	}
	
}

if(ids.size()>0){
eOne_SC_RTDS.Process('Opportunity','update',ids); 
}
}

 

All Answers

Raj VakatiRaj Vakati
Yes you can do it like this .. here i am taking owner profile example .. 
 
Trigger eOne_SC_RTDS_Opportunity_U on Opportunity (after update) {

set<ID> ids = new Set<Id>();

for(Opportunity op :Trigger.new){
	// add what ever conditions you want
	if(op.Owner.ProfileId == 'xxx'){
		ids.add(op.Id);
	}
	
}

if(ids.size()>0){
eOne_SC_RTDS.Process('Opportunity','update',ids); 
}
}

 
This was selected as the best answer
Cory PayneCory Payne
Thank you Raj!
hariharan S 11hariharan S 11

Hi Everyone,

I have a one public group  and queue 
I want to access Queues using public group 
I like to enable Queue is editalble using public group 

how can i do this? please guide me

Thank you
Hariharan S