You need to sign in to do that
Don't have an account?
Arash Teimoupoor
Prevent Rollup Summary filds changes from firing the trigger
Hi Everyone, I have a trigger that updates the child records if there is a change on the parent record. my problem is if I change certain fields on the child records, it changes the value of the rollup summaty fields on the parent and fires the trigger. So I added the conditon like this to prevent that:
if ((c.TCR_Total_Charts__c != oldProj.TCR_Total_Charts__c) || (c.TCR_Total_Delivered__c != oldProj.TCR_Total_Delivered__c) ||
(c.TCR_Total_Scheduled__c != oldProj.TCR_Total_Scheduled__c)) {
isExecute = TRUE;
}
}
if(isExecute = false){
but now even if I change other fields on the parent , it does not fire the trigger. Please help me if you know a solution for this. below is the whole trigger. thanks
trigger ProjectSettings_ChartsTrigger on Project_Setting__c (After Insert,After Update){
List<id> ProjectIds = new list<id>();
List<Project_Setting__c > prj = [select Id, Total_Charts__c from Project_Setting__c where Id In : ProjectIds];
boolean isfalse = false;
String userName = UserInfo.getUserName();
string Profile = UserInfo.getprofileId();
Boolean isExecute = false;
for (Project_Setting__c c : Trigger.new) {
Project_Setting__c oldProj = Trigger.oldMap.get(c.ID);
if ((c.TCR_Total_Charts__c != oldProj.TCR_Total_Charts__c) || (c.TCR_Total_Delivered__c != oldProj.TCR_Total_Delivered__c) ||
(c.TCR_Total_Scheduled__c != oldProj.TCR_Total_Scheduled__c)) {
isExecute = TRUE;
}
}
if(isExecute = false){
if(userName != 'arash' && profile != 'xxxxx' && profile != 'xxxxx' && profile != 'xxxx'){
for(Project_Setting__c PS : Trigger.new){
if (PS.Total_Charts__c < 2000) {
ProjectIds.add(PS.id);
isfalse = true;
}
else{
ProjectSettings_ChartsBatchClass pro = new ProjectSettings_ChartsBatchClass();
database.executebatch(pro,2000);
}
}
if ( isfalse ){
projectSettingsChartClass.ProjectMethods(ProjectIds);
}
}
}
}
if ((c.TCR_Total_Charts__c != oldProj.TCR_Total_Charts__c) || (c.TCR_Total_Delivered__c != oldProj.TCR_Total_Delivered__c) ||
(c.TCR_Total_Scheduled__c != oldProj.TCR_Total_Scheduled__c)) {
isExecute = TRUE;
}
}
if(isExecute = false){
but now even if I change other fields on the parent , it does not fire the trigger. Please help me if you know a solution for this. below is the whole trigger. thanks
trigger ProjectSettings_ChartsTrigger on Project_Setting__c (After Insert,After Update){
List<id> ProjectIds = new list<id>();
List<Project_Setting__c > prj = [select Id, Total_Charts__c from Project_Setting__c where Id In : ProjectIds];
boolean isfalse = false;
String userName = UserInfo.getUserName();
string Profile = UserInfo.getprofileId();
Boolean isExecute = false;
for (Project_Setting__c c : Trigger.new) {
Project_Setting__c oldProj = Trigger.oldMap.get(c.ID);
if ((c.TCR_Total_Charts__c != oldProj.TCR_Total_Charts__c) || (c.TCR_Total_Delivered__c != oldProj.TCR_Total_Delivered__c) ||
(c.TCR_Total_Scheduled__c != oldProj.TCR_Total_Scheduled__c)) {
isExecute = TRUE;
}
}
if(isExecute = false){
if(userName != 'arash' && profile != 'xxxxx' && profile != 'xxxxx' && profile != 'xxxx'){
for(Project_Setting__c PS : Trigger.new){
if (PS.Total_Charts__c < 2000) {
ProjectIds.add(PS.id);
isfalse = true;
}
else{
ProjectSettings_ChartsBatchClass pro = new ProjectSettings_ChartsBatchClass();
database.executebatch(pro,2000);
}
}
if ( isfalse ){
projectSettingsChartClass.ProjectMethods(ProjectIds);
}
}
}
}
if(isExecute = false){
There is a single '=' . you should be using '==' to compare. I don't think, it will go inside if statement
All Answers
DId you put debug statements to verify?
if(isExecute = false){
There is a single '=' . you should be using '==' to compare. I don't think, it will go inside if statement