Skip to main content
formatting
Source Link
Mark Pond
  • 23.1k
  • 2
  • 60
  • 104

I am new in developing apex.

Here is my trigger. When I try to update an account record, I get the error: "
Error:Apex trigger pfUpdate caused an unexpected exception, contact your administrator: pfUpdate: execution of BeforeUpdate caused by: System.FinalException: Record is read-only: ()"

Error:Apex trigger pfUpdate caused an unexpected exception, contact your administrator: pfUpdate: execution of BeforeUpdate caused by: System.FinalException: Record is read-only: ()"

I want the account to be updated only if the CR_Parent_Fax__cCR_Parent_Fax__c was false before and needs to be updated to TRUE. I do not want the trigger would get stuck in recursion. I also want to note that I have tried to change before trigger to after trigger, but did not do any better. Could someone help me to figure out what is wrong with my trigger? Any help would be appreciated.

trigger pfUpdate on Account (before update) { for (Account acc : Trigger.new) { // Access the "old" record by its ID in Trigger.oldMap Account oldacc = Trigger.oldMap.get(acc.Id);

trigger pfUpdate on Account (before update) {
    for (Account acc : Trigger.new) {
    // Access the "old" record by its ID in Trigger.oldMap
    Account oldacc = Trigger.oldMap.get(acc.Id);

    // Trigger.new records are conveniently the "new" versions!
    Boolean oldAccWpf = oldAcc.CR_Parent_Fax__c = true;
    Boolean newAccWOpf = acc.CR_Parent_Fax__c = true;
    
    // Check that the field was changed to the correct value
    if (!oldAccWpf && newAccWOpf) {
      acc.In_Active_Account__c  = true;
    }
  }
}

} }

I am new in developing apex.

Here is my trigger. When I try to update an account record, I get the error: "
Error:Apex trigger pfUpdate caused an unexpected exception, contact your administrator: pfUpdate: execution of BeforeUpdate caused by: System.FinalException: Record is read-only: ()"

I want the account to be updated only if the CR_Parent_Fax__c was false before and needs to be updated to TRUE. I do not want the trigger would get stuck in recursion. I also want to note that I have tried to change before trigger to after trigger, but did not do any better. Could someone help me to figure out what is wrong with my trigger? Any help would be appreciated.

trigger pfUpdate on Account (before update) { for (Account acc : Trigger.new) { // Access the "old" record by its ID in Trigger.oldMap Account oldacc = Trigger.oldMap.get(acc.Id);

// Trigger.new records are conveniently the "new" versions!
Boolean oldAccWpf = oldAcc.CR_Parent_Fax__c = true;
Boolean newAccWOpf = acc.CR_Parent_Fax__c = true;

// Check that the field was changed to the correct value
if (!oldAccWpf && newAccWOpf) {
  acc.In_Active_Account__c  = true;
}

} }

I am new in developing apex.

Here is my trigger. When I try to update an account record, I get the error: "

Error:Apex trigger pfUpdate caused an unexpected exception, contact your administrator: pfUpdate: execution of BeforeUpdate caused by: System.FinalException: Record is read-only: ()"

I want the account to be updated only if the CR_Parent_Fax__c was false before and needs to be updated to TRUE. I do not want the trigger would get stuck in recursion. I also want to note that I have tried to change before trigger to after trigger, but did not do any better. Could someone help me to figure out what is wrong with my trigger? Any help would be appreciated.

trigger pfUpdate on Account (before update) {
    for (Account acc : Trigger.new) {
    // Access the "old" record by its ID in Trigger.oldMap
    Account oldacc = Trigger.oldMap.get(acc.Id);

    // Trigger.new records are conveniently the "new" versions!
    Boolean oldAccWpf = oldAcc.CR_Parent_Fax__c = true;
    Boolean newAccWOpf = acc.CR_Parent_Fax__c = true;
    
    // Check that the field was changed to the correct value
    if (!oldAccWpf && newAccWOpf) {
      acc.In_Active_Account__c  = true;
    }
  }
}
added 110 characters in body
Source Link

I am new in developing apex.

Here is my trigger. When I try to update an account record, I get the error: "
Error:Apex trigger pfUpdate caused an unexpected exception, contact your administrator: pfUpdate: execution of BeforeUpdate caused by: System.FinalException: Record is read-only: ()"

Error:Apex trigger pfUpdate caused an unexpected exception, contact your administrator: pfUpdate: execution of BeforeUpdate caused by: System.FinalException: Record is read-only: ()"

I want the account to be updated only if the CR_Parent_Fax__cCR_Parent_Fax__c was false before and needs to be updated to TRUE. I do not want the trigger would get stuck in recursion.

Could I also want to note that I have tried to change before trigger to after trigger, but did not do any better. Could someone help me to figure out what is wrong with my trigger? Any help would be appreciated.

trigger pfUpdate on Account (before update) { for (Account acc : Trigger.new) { // Access the "old" record by its ID in Trigger.oldMap Account oldacc = Trigger.oldMap.get(acc.Id);

trigger pfUpdate on Account (before update) {
    for (Account acc : Trigger.new) {
    // Access the "old" record by its ID in Trigger.oldMap
    Account oldacc = Trigger.oldMap.get(acc.Id);

    // Trigger.new records are conveniently the "new" versions!
    Boolean oldAccWpf = oldAcc.CR_Parent_Fax__c = true;
    Boolean newAccWOpf = acc.CR_Parent_Fax__c = true;
    
    // Check that the field was changed to the correct value
    if (!oldAccWpf && newAccWOpf) {
      acc.In_Active_Account__c  = true;
    }
  }
}

} }

I am new in developing apex.

Here is my trigger. When I try to update an account record, I get the error:

Error:Apex trigger pfUpdate caused an unexpected exception, contact your administrator: pfUpdate: execution of BeforeUpdate caused by: System.FinalException: Record is read-only: ()"

I want the account to be updated only if the CR_Parent_Fax__c was false before and needs to be updated to TRUE. I do not want the trigger would get stuck in recursion.

Could someone help me to figure out what is wrong with my trigger? Any help would be appreciated.

trigger pfUpdate on Account (before update) {
    for (Account acc : Trigger.new) {
    // Access the "old" record by its ID in Trigger.oldMap
    Account oldacc = Trigger.oldMap.get(acc.Id);

    // Trigger.new records are conveniently the "new" versions!
    Boolean oldAccWpf = oldAcc.CR_Parent_Fax__c = true;
    Boolean newAccWOpf = acc.CR_Parent_Fax__c = true;
    
    // Check that the field was changed to the correct value
    if (!oldAccWpf && newAccWOpf) {
      acc.In_Active_Account__c  = true;
    }
  }
}

I am new in developing apex.

Here is my trigger. When I try to update an account record, I get the error: "
Error:Apex trigger pfUpdate caused an unexpected exception, contact your administrator: pfUpdate: execution of BeforeUpdate caused by: System.FinalException: Record is read-only: ()"

I want the account to be updated only if the CR_Parent_Fax__c was false before and needs to be updated to TRUE. I do not want the trigger would get stuck in recursion. I also want to note that I have tried to change before trigger to after trigger, but did not do any better. Could someone help me to figure out what is wrong with my trigger? Any help would be appreciated.

trigger pfUpdate on Account (before update) { for (Account acc : Trigger.new) { // Access the "old" record by its ID in Trigger.oldMap Account oldacc = Trigger.oldMap.get(acc.Id);

// Trigger.new records are conveniently the "new" versions!
Boolean oldAccWpf = oldAcc.CR_Parent_Fax__c = true;
Boolean newAccWOpf = acc.CR_Parent_Fax__c = true;

// Check that the field was changed to the correct value
if (!oldAccWpf && newAccWOpf) {
  acc.In_Active_Account__c  = true;
}

} }

added 62 characters in body
Source Link
sfdcfox
  • 501.7k
  • 21
  • 473
  • 828

I am new in developing apex.

Here is my trigger. When I try to update an account record, I get the error: "
Error:Apex trigger pfUpdate caused an unexpected exception, contact your administrator: pfUpdate: execution of BeforeUpdate caused by: System.FinalException: Record is read-only: ()"

Error:Apex trigger pfUpdate caused an unexpected exception, contact your administrator: pfUpdate: execution of BeforeUpdate caused by: System.FinalException: Record is read-only: ()"

I want the account to be updated only if the CR_Parent_Fax__cCR_Parent_Fax__c was false before and needs to be updated to TRUE. I do not want the trigger would get stuck in recursion. Could

Could someone help me to figure out what is wrong with my trigger? Any help would be appreciated.

trigger pfUpdate on Account (before update) { for (Account acc : Trigger.new) { // Access the "old" record by its ID in Trigger.oldMap Account oldacc = Trigger.oldMap.get(acc.Id);

trigger pfUpdate on Account (before update) {
    for (Account acc : Trigger.new) {
    // Access the "old" record by its ID in Trigger.oldMap
    Account oldacc = Trigger.oldMap.get(acc.Id);

    // Trigger.new records are conveniently the "new" versions!
    Boolean oldAccWpf = oldAcc.CR_Parent_Fax__c = true;
    Boolean newAccWOpf = acc.CR_Parent_Fax__c = true;
    
    // Check that the field was changed to the correct value
    if (!oldAccWpf && newAccWOpf) {
      acc.In_Active_Account__c  = true;
    }
  }
}

} }

I am new in developing apex.

Here is my trigger. When I try to update an account record, I get the error: "
Error:Apex trigger pfUpdate caused an unexpected exception, contact your administrator: pfUpdate: execution of BeforeUpdate caused by: System.FinalException: Record is read-only: ()"

I want the account to be updated only if the CR_Parent_Fax__c was false before and needs to be updated to TRUE. I do not want the trigger would get stuck in recursion. Could someone help me to figure out what is wrong with my trigger? Any help would be appreciated.

trigger pfUpdate on Account (before update) { for (Account acc : Trigger.new) { // Access the "old" record by its ID in Trigger.oldMap Account oldacc = Trigger.oldMap.get(acc.Id);

// Trigger.new records are conveniently the "new" versions!
Boolean oldAccWpf = oldAcc.CR_Parent_Fax__c = true;
Boolean newAccWOpf = acc.CR_Parent_Fax__c = true;

// Check that the field was changed to the correct value
if (!oldAccWpf && newAccWOpf) {
  acc.In_Active_Account__c  = true;
}

} }

I am new in developing apex.

Here is my trigger. When I try to update an account record, I get the error:

Error:Apex trigger pfUpdate caused an unexpected exception, contact your administrator: pfUpdate: execution of BeforeUpdate caused by: System.FinalException: Record is read-only: ()"

I want the account to be updated only if the CR_Parent_Fax__c was false before and needs to be updated to TRUE. I do not want the trigger would get stuck in recursion.

Could someone help me to figure out what is wrong with my trigger? Any help would be appreciated.

trigger pfUpdate on Account (before update) {
    for (Account acc : Trigger.new) {
    // Access the "old" record by its ID in Trigger.oldMap
    Account oldacc = Trigger.oldMap.get(acc.Id);

    // Trigger.new records are conveniently the "new" versions!
    Boolean oldAccWpf = oldAcc.CR_Parent_Fax__c = true;
    Boolean newAccWOpf = acc.CR_Parent_Fax__c = true;
    
    // Check that the field was changed to the correct value
    if (!oldAccWpf && newAccWOpf) {
      acc.In_Active_Account__c  = true;
    }
  }
}
Source Link
Loading