Stack Exchange Network

Stack Exchange network consists of 174 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange
Make your voice heard. Take the 2019 Developer Survey now

Questions tagged [triggercontext]

The tag has no usage guidance.

2
votes
1answer
28 views

MailingCountry contact field in before insert trigger

I have to populate a Contact field programmatically according to the MailingCountry field in the before insert trigger so the contact is created properly. But I noticed that the field MailingCountry ...
2
votes
3answers
530 views

Why does Salesforce has Trigger.isInsert or Trigger.isUpdate when Trigger.old !=Null would have worked?

Salesforce has context variables like Trigger.IsInsert just to understand if trigger is running for Insert scenarios. However, we could always have got this information by doing the NULL check on ...
1
vote
0answers
34 views

Soql in apex trigger returns different result depending on user who causes the trigger.

In Communities we have an ideas component where users can post/comment/vote on different ideas. We are trying to create a trigger which will send an email to the idea creator whenever someone ...
0
votes
1answer
26 views

Same Logic for after insert and after update trigger?

I have to implement same logic x=y+z for after insert and after update trigger on an object. Unfortunately I cannot make use of context variables as our prototype for trigger handler is defined long ...
0
votes
1answer
36 views

Creating queueable classes for trigger-like processing, hitting a 'de-reference' glitch

I have two queueable classes for handing off trigger-like processing; one Case-specific, one generic. The first implementation of the generic version also involves Cases, and editing a Case works in ...
0
votes
1answer
279 views

Trigger: Catch duplicate and update existing record

I'm trying to write a trigger that can not only detect a duplicate but can update the existing record (similar to an upsert operation). For several reasons, we are unable to actually use upsert. ...
4
votes
2answers
202 views

Methods to Check if Sobjects are Equal

Use Case: Need to allow changes to only one specific field on an opportunity when at a certain stage. Problem: How to efficiently determine within a trigger context that a only the specific field ...
1
vote
1answer
473 views

Casting Trigger.New to List<Case> in Trigger Framwork

We are using a trigger framework by Kevin O'Hara and I have a basic question about it. Why when I use Trigger.New inside one of the methods I have to cast it to a List of cases in order to use it? ...
0
votes
1answer
194 views

how to bypass lookup filter criteria on trigger?

I have 3 objects: vacancy schedule, candidate availability and closing report schedule. I have a field common in all the three objects: workshift location. However, i have a lookup filter criteria ...
4
votes
0answers
266 views

Execute some code after all trigger batches complete?

Suppose I update 1000 records and I have an after update trigger. That trigger will run 5 times for each batch of 200. Is there any possible way to collect data over the course of the 5 executions and ...
0
votes
2answers
135 views

IS there any standard order of execution for insert and update for the upsert DML

Upsert on the apex controller and it has both insert and update records. Trigger on before update, before insert A trigger has a recursion check in the starting. Question: Trigger will fire first for ...
3
votes
1answer
201 views

Trigger.new List During a Transaction

This is a question I have always wondered. I have a series of classes and methods that modify the Trigger.new case list records as the list is handed off to each class and method. Apex goes down the ...
0
votes
1answer
100 views

SOQL limits in andFinally TriggerHandler

1)Is it a good idea to keep a list or map of ids of the affected records and passing to gateway class method called in andFinally which runs a SOQL if necessary (like for child records)? 2)If this is ...
1
vote
4answers
562 views

I need a trigger to update all child object records of parent object

I have a custom object called child_object__c with a lookup into Parent_Object__c records. When Parent_Object__c Type field value Primary to Secondary is changed, I need to field update all the ...
1
vote
0answers
127 views

CloseComment: execution of BeforeInsert caused by: System.NullPointerException: Attempt to de-reference a null object: ()

I am facing the below issue. Could anyone please help. I have written a trigger on the Case Object. I am calling this trigger at the time of creating web to case from the HTML Generator code. Error: ...
1
vote
2answers
30 views

AfterDelete on Delete

I have a custom object related to Opportunity via not master-detail lookup. I want to delete the custom object record when the Opportunity record is deleted. Thus, I wrote this method into my trigger: ...
0
votes
1answer
84 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 ...
0
votes
1answer
45 views

Non-Read-Only field giving error with trigger that it is read-only

I'm getting an error on my trigger that it cannot change the value of a field because it is read-only. The problem is, it is not Read-Only. Is there a setting somewhere or some information about the ...
0
votes
1answer
294 views

prevent the deletion of account records if they have oppurtunity

trigger preventAccountDeletionifopp on Account (before delete) { for(account accdel:trigger.old){ Opportunity oppprevent =[select Name,(select Name,Owner from Opportunitys)from ACCOUNT =: ...
0
votes
0answers
22 views

Regarding Auto Email sending trigger

Salesforce is integrated to Ipad app, when creating the order online in Ipad auto email sending trigger is working, if I create the order in offline in Ipad auto email trigger is not working, after ...
-3
votes
1answer
64 views

Trigger code in salesforce [closed]

How to write a trigger code to make the field as required and Not Required for a Object ,is it possible in trigger code to make the field as not Required and Required field in salesforce,Please Anyone ...
0
votes
1answer
85 views

Updating the trigger from child to parent issue [closed]

Here i have a requirement and i am facing the issue in the trigger Fill Parent object (Parent Amount field) with Child Amount value when a child is created for the first time. Fill/Check Parent ...
1
vote
1answer
81 views

Solving a challenging case using an Apex trigger - Advices please [duplicate]

I have a custom object called employees__c. Employees__c has fields- person_id__c(external and unique id) , employee_status__c(which can have value active or inactive). I have an object called log ...
2
votes
1answer
95 views

Retrieving grandparent relationship from Trigger.Old in AfterDelete context

I have a trigger on an object ('item'), which is a child of 'parent', which is in turn a child of 'grandparent'. So a SOQL query involving item.parent__r.grandparent__c normally returns the ID of the ...
14
votes
2answers
4k views

Dynamically Determine Calling Context?

We have various ways of invoking apex. Triggers, Inbound Webservices, @InvocableMethod,@RemoteAction and what not. Often we call some or other utility methods from these execution contexts. I have ...
0
votes
1answer
287 views

Trigger to make Same changes in child object

I have a requirement in which when I create a record in parent object(subject__c) that same record should be created in child(sub_Subject__c).Also when subject__c is updated, all the changes that have ...
1
vote
3answers
59 views

Question about Trigger

I have a custom object in which i have two triggers. Trigger 1( before insert and after update) Trigger 2(After Insert) Currently whenever i insert a record, trigger 1 fires before i insert the ...
0
votes
1answer
53 views

Trigger to Pull related contact designation on Task page when tesk create or edit

I have a requirement. Contact related to Task, I need to pull his functional role ( custom field) on Activity page layout. So whenever I create or edit an activity and relate with ant contact so his/...
1
vote
0answers
80 views

Trigger to update parent's field

I have a requirement: 1) Match field(number) is created on name 2) Opportunity Match(number) is created on vehicle. 3) Develop a trigger :: 1) on Insert - The value in "Opportunity Match" field ...
1
vote
2answers
388 views

Trigger On Opportunity Stage based on Opplineitem

I have custom field Invoice Date in OpportunityLineitem when this is left blank it should show error using trigger when trying to update Opportunity with Opportunity stagename as closed won. I tried ...
3
votes
1answer
548 views

Explicitly change the context of User while scheduling a batch

I have a requirement where I schedule a batch to run via trigger on insert and update event. However, the batch schedules in the context of the User who makes the changes. Because of which the ...
1
vote
1answer
140 views

Add contact to Account if Account doesnt have any contact

I need to write a trigger in which If I have an Account named 'Smith' and it doesnt have any related contacts when It is edited, its contact is created. I am doing this way but I am getting an error. ...
1
vote
3answers
3k views

Trigger to get Names of all contacts on Account field

I need to write a trigger in which all the related contacts names should be shown on Account field. If I have 3 contacts of an Account, they should come like this: Smith, John, Brutus. I am doing this ...
2
votes
2answers
101 views

More than 100 opportunities should not be created by a user

A user can not create more than 100 opportunities in a day..if the user tries to insert more than 100 opportunities error should come... I am trying this way... Trigger NotMoreThan1000Opportunities ...
0
votes
1answer
381 views

Trigger to update grandParent(Opportunity) field

I need to write a Trigger in which relationship goes like this... opportunity is the grandparent it has a child Invoice and further Invoice has a child Invoice Line which is grandChild.. what I need ...
2
votes
2answers
1k views

I need to calculate the sum of amount of all related opportunities of an account and change the status of rating accordingly [duplicate]

I have an account xyz and I need to calculate the sum of all related opporunities of this account and if the amount is less than 2000 rating should come '1' , if its less than 3000 rating should be '2'...
6
votes
4answers
1k views

best way to handler trigger Recursive call

Below is my code snippet that I have used. And also I used static Boolean to handle the recursive call. But when I update more than 200 records then trigger only process first 200 record not all the ...
0
votes
3answers
340 views

trigger is not executing successfully

If I use the below code then it throws an error: Review all error messages below to correct your data. Apex trigger abc caused an unexpected exception, contact your administrator: abc : ...
16
votes
2answers
735 views

Can triggers tell if a Workflow invoked them?

Is there anything available to us in Apex that can be used to determine if a trigger was fired by Workflow/Process Builder?
3
votes
1answer
200 views

Data Loader and after update triggers running twice

I have a scenario. I am updating some Opportunity records through Data loader which causes after update trigger to run twice and cause issues. It shows that some WF Field update runs again and then ...
1
vote
5answers
15k views

Difference between trigger.new and trigger.newmap

I am really confused between these two.i knows the theoretical differences between these like if u have id then only you can use trigger.newmap and trigger.newmap returns a unordered list.. Leaving ...
0
votes
0answers
327 views

Updated Value from Informatica Cloud Sync Task not available during execution of after update Trigger

I have an "after update" trigger that will look at certain fields in the Contact object and perform some task based on the value of those fields. The trigger fires, but it doesn't perform its task ...
0
votes
1answer
252 views

Creating Contacts from Custom Objects

Attempting to create an Apex trigger that will create a new contact when a custom object record (Location) is created or updated. I believe I'm not referencing the custom object correctly and the ...
0
votes
1answer
96 views

Updating related record in update trigger

I'm stuck in the following issue: there is a DB with Reference__c custom object with fields: AccountId, ContactId, IsPrimary(Boolean). There can be only one Reference with isPrimary=true for a one ...
5
votes
1answer
48 views

Map size different in before update and after update triggers

I've come across a null pointer exception. After I started diggin in, I realized that before update contains 163 records where as after update contains only 161 records. I have never encountered such ...
1
vote
2answers
272 views

Find successful DML records in a trigger

In an insert or update trigger, the records are processed in a batch of 200. We have the trigger.new and trigger.old for the new and old values respectively. Now the trigger code is designed to block ...
0
votes
3answers
750 views

Test Class Coverage Issue with Trigger.newMap != Trigger.oldMap

I'm hoping I am missing something obvious. I have a Lead Trigger & Handler class. The Handler forces Assignment Rules to fire if a Lead Checkbox field IS CHANGED to True. After Update. It is ...
0
votes
1answer
34 views

Retreive the current record id in IsBefore context on IsInsert

Can we get the current record Id on IsBefore context on IsInsert trigger? I'm trying to create a Child record to a Parent record on its IsBefore context when its inserting? Is that possible? Or else ...
0
votes
2answers
53 views

Internal coding or implementation of Trigger.New

I want to know internal implementation like API or method or internal coding for Trigger.new.How it works.How the API trigger.new works.Anyone having any details for trigger.new
1
vote
1answer
24 views

Time base email aleart on open task

Can anyone help.... I am trying to create a workflow action in Salesforce under the object 'Task'. I want a workflow to be in place that if a task is not complete by the due date then an email is ...