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
15 views

updating field from parent object to child object and it's not working

I have been working with this code for updating field from parent object to child object and it does not work. Can you help me with this. Thanks. public void tcUpdate(Map<Id, SObject> newMap, ...
0
votes
1answer
88 views

Test Class Coverage for Trigger with oldMap

I have an Apex Trigger and Handler class on the Business Process object. When a lookup field (Financial_Planner__c) is updated on the Business Process, the system should query all Tasks associated to ...
-3
votes
1answer
51 views

Test class trigger.NewMap trigger.oldMap on opportunity [duplicate]

I need to write a test class on my OpportunityTriggerHandler and I'm having some difficulties to define how to construct the logic & scenarios in my test to test and the data to build in my test ...
0
votes
1answer
68 views

Trigger to update a Lookup Record when status field is updated

I am trying to solve a simple problem. I have an object Service_Expansion_Tracker__C, there is a lookup field NHC_Tracker__c on the object (The relation between NHC tracker and Service Expansion ...
0
votes
2answers
83 views

Trigger.oldMap return error "Variable does not exist"

I am writing a class using Trigger.oldmap to find old account ownerId but it does not recognize what OwnerId is. (Trigger.oldMap.get(acc.Id)).OwnerId The script is trying to create a custom "...
0
votes
1answer
54 views

Unable to insert and update for trigger.oldmap and Trigger.newmap in apex trigger

I have an object called log__c in that fields have Description__c, Action__c(label name :Title) Lookup with Contact object, when I change the phone field of contact the object then in log__c object ...
0
votes
0answers
37 views

Apex trigger not step in isUpdate

In the following apex trigger it does not step in isUpdate. It works properly in case of new insertion or deletion, but in case of update it does not removes the old ID from the list. As per the debug ...
2
votes
2answers
304 views

Comparing old and new field value from Map<Id,Sobject>

I am pretty new to development and I am trying to user Chris Aldridge's Lightweight Trigger Framework http://chrisaldridge.com/triggers/lightweight-apex-trigger-framework/. I am looking to create a ...
2
votes
1answer
163 views

Do trigger.newMap and trigger.oldMap have the same keySet() in apex after update triggers?

My potential use case by knowing the answer to this question would be, if I'm working with a legacy code and I can't make modification to the method signature and I only have access to trigger.new and ...
0
votes
2answers
973 views

How to compare fields of oldMap and newMap?

I have a trigger helper with this method: public void changeObjects(Map<Id, Cleaning__c> oldObjectsMap, Map<Id, Cleaning__c> newObjectsMap) But it should make changes only if ...
0
votes
2answers
249 views

Trigger.OldMap returns new Value

When a contact is updated, i want to know the old value of the owner. This is how I am testing --- Changed Owner on Account, as a result, owner on Contact changed to be the same as Account Owner. The ...
0
votes
1answer
165 views

Trigger Compare Old and New AccountOwner of a Contact

I am having trouble comparing the old and new owner of the Account associated with the contact to achieve #6 of the requirement. Can someone please suggest how I satisfy condition #6 in the logic. ...
0
votes
1answer
127 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
721 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
79 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
63 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
144 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, ...
1
vote
1answer
2k 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
594 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
244 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
1k 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
45 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
408 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
34 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
640 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
682 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
330 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
8k 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
660 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 "...