We’re rewarding the question askers & reputations are being recalculated! Read more.

Questions tagged [trigger-oldmap]

A map of IDs to the old versions of the sObject records. Note that this map is only available in update and delete triggers.

Filter by
Sorted by
Tagged with
0
votes
1answer
117 views

After update trigger getting same old and new values in trigger.old and trigger.new

I have custom objects called Asset__c and Site__c. Asset__c has a lookup field to the object Site__c, which is called Asset_site__c. There is a formula field in Asset__c called Asset_Site_Name__c ...
0
votes
1answer
58 views

I want to update Checkbox(Custom Field) on Contact whenever a new Opportunity is created based on Contact in (Primary_Contact__c)

I want to update Custom Field(Checkbox) on Contact whenever a new Opp is created and Opp has Primary Contact from Contact trigger PrimaryConOnAccOfOppHandler on Opportunity (after insert, after ...
2
votes
2answers
45 views

trigger to update Custom field on Account record whenever a new opportunity record (Whose Title contains 'CEO') is inserted or deleted

Trigger to update Custom field(Count_Of_Title_in_Opp__c) on Account record whenever a new opportunity record (Whose Title contains 'CEO') is inserted or deleted Trigger trigger OppSizeOnAccount on ...
0
votes
1answer
30 views

is it possible to get the parents old value in trigger update on junction object

i have a issue in retrieving the old value of parents record onthe junction object update scenario, do anyone have come across this scenario, please throw lights. Junction__c oldlrj = [SELECT Id, ...
0
votes
2answers
54 views

Field of new records not updated by trigger

I'm new to apex and trigger and have an issue. I need to update a field on a record when 2 other fields are updated. This field is supposed to calculate the time between 2 dates based on the business ...
0
votes
2answers
48 views

Need to Understand Apex trigger soql execution on each events

I have a trigger handler as shown below (Please Ignore any Syntax errors) trigger AccountTrigger on Account (after delete, after insert, after undelete, after update, before delete, before insert, ...
0
votes
1answer
118 views

How to cover trigger.oldmap.get () in test class

public void updateAccessLevelsOnUpdate(final List<Opportunity> newOppList, Map<Id, Opportunity> oldOppMap){ if(Istrue == true){ try{ Map<Id, Id> ...
0
votes
2answers
33 views

Can I avoid a code duplication here?

I have a code duplication here. How can I fix it? I want to make my code better. Helper: public with sharing class JobHelper { List<Task> taskList = new List<Task>(); public void ...
0
votes
1answer
131 views

Custom History Tracking on Opportunity with trigger

Trigger:   Custom Opportunity History Tracking Create Custom Object : OpportunityHistory Fields : Field Name(Text), Old Value(Text) and New Value(Text) Trigger Logic:    • When new opportunity ...
0
votes
1answer
107 views

Does OldMap Change During Recursion?

I wrote some code on Opportunity that compares new values to OldMap values and should execute a record clone only if the record was JUST Closed Lost. I'm not sure if my interpretation of OldMap is ...
1
vote
1answer
455 views

Test coverage for comparing old versus new value on Opportunity

I am attempting to cover for apex code that compares if a particular value on the Opportunity object has increased since the Opportunity was updated. This is a before update trigger, which may be a ...
0
votes
1answer
39 views

How to get PermissionSet oldMap value and compare with new one in after update trigger

I need to figure out if values in PermissionSet for current user are changed in trigger, i'm thinking about using oldMap but i can't figure it out. Maybe this code will explain what i'm trying to do: ...
0
votes
1answer
173 views

after update Trigger using oldMap not working

This Trigger is being created to update a lookup field on Contact if the Contacts Community account is disabled. I have a field on Contact called Support_Community_User__c that is a lookup to User ...
0
votes
2answers
30 views

Getting error when trying to compare between old and new values

I'm trying to see if the Priority value on Case changed but I get the error below and I can't figure out why. for(Case c: (List<Case>)Trigger.New) { if(setRecordTypeIds.contains(...
0
votes
1answer
371 views

Trigger to fire when a checkbox is updated/inserted to read true

I have a trigger that i want to fire when a checkbox is set as true: The conditions of my If statement are as follows: c.DetailsConfirmed__c == true && trigger.oldmap.get(c.id)....
0
votes
1answer
212 views

Trigger looping and Trigger.oldMap data changing

I have an issue with a trigger on opportunity. I have a method X in my opp_Handler that when opp.stageName changes to 'Closed Won' to execute code... the problem is, I have many methods my trigger is ...
1
vote
2answers
155 views

test class error - attempt to de-reference a null object Trigger using oldmap

I am receiving an Error in my Test class, but am unsure of the reason why. Here is the Error: Exception: Update failed. First exception on row 0 with id a0i4C000000HfieQAC; first error: ...
1
vote
1answer
5k views

Issue with APEX Trigger.OldMap. OldMap is giving new value of the field(Stage) instead of the Old Value

trigger MasterOpportunityTrigger on Opportunity(before insert, after insert, before update, after update, before delete, after delete,after undelete) { if (Trigger.IsAfter) { else if (Trigger....
4
votes
1answer
356 views

Is there a way to retrieve the oldMap of a trigger in a future method?

This could be quite a dumb question though, I would like to ask is there a way to retrieve the oldMap of a trigger in a @future method? In the below code please refer the collection "oldReportsMap", ...