Questions tagged [after-trigger]

After triggers are used to access field values that are set by the system (such as a record's Id or LastModifiedDate field), and to affect changes in other records.

Filter by
Sorted by
Tagged with
1 vote
1 answer
44 views

How to rearrange the priorities of the records using Apex?

I have a requirement to auto update priorities based on the input from the user. On Object Requests__c I have 2 fields Priority__c(Number) and Board__c (Picklist values A, B, C and D). Suppose if I ...
Praveen's user avatar
  • 13
-1 votes
0 answers
49 views

Execution of AfterUpdate caused by: System.licenseException: Inactive User

For more context, i'm doing cleanup of our previous integration user which was not actual integration user but normal user. And there are bunch of Apex Triggers created by this user and when it was ...
B.G's user avatar
  • 11
0 votes
0 answers
35 views

Unable to fetch the most up-to-date value from Trigger

I've encountered an issue with retrieving the latest BillingLatitude value through a trigger. It consistently retrieves the old value in an 'After Update' Trigger, even when the entire address is ...
MnZ's user avatar
  • 3,152
-1 votes
0 answers
31 views

FATAL_ERROR|System.LimitException: Too many SOQL queries across namespaces: 1101

public class LeadConversionTriggerHandler { public static void handleAfterInsert(List<Lead> newLeads) { List<Lead> leadsToConvert = new List<Lead>(); Map<...
user131546's user avatar
0 votes
1 answer
27 views

How can I convert normal triggerHandler Method to Future method?

Im learning about Future methods so wanted to covert my triggerHandler method to Future method...where Im trying to insert contact on every user insert. but im getting an issue called "Future ...
Sajid's user avatar
  • 13
-2 votes
3 answers
32 views

caused by: System.SObjectException: Opportunity.AccountId does not belong to SObject type AggregateResult

I simply wanted to update inserted line item count on Account field Name Line_Item_Counts but ended up with this issue. code is errorless but at the UI I am unable to insert Quoteline Items Here is ...
Sajid's user avatar
  • 13
0 votes
0 answers
60 views

Question on beforeUpdate or afterUpdate trigger in Salesforce

I have some doubts on whether I should be using a beforeUpdate or an afterTrigger for the scenario enlisted below. Any pointers would be very helpful. Thanks in advance. I have a custom object ABC ...
Bharath Sridhar's user avatar
0 votes
0 answers
23 views

Unable to get full code coverage for a SF trigger after update [duplicate]

I have a simple Apex trigger, written for an object called Application__c, and it fires after the "Shipping_City__c" field changes: 1.trigger MyTrigger on Application__c (after update) { ...
Rose Mirzaei's user avatar
-2 votes
1 answer
39 views

Need to bypass this validation Rule which is causing while creating the b2b records, for the live chat, Can any one please help me how should i bypass

FATAL_ERROR|System.DmlException: Insert failed. First exception on row 0; first error: FIELD_CUSTOM_VALIDATION_EXCEPTION, must populate atleast contact : téléphone / e-mail.: [] Class....
Khulas Khulas's user avatar
2 votes
1 answer
65 views

Trigger IF statement will not fire

I have a trigger that has an If statement in it, that if statement should pick up any new lead assigned to the Pre Qual queue. This Queue is set when I manually create a new lead and click the use ...
Sgrove 's user avatar
0 votes
1 answer
69 views

Querying History Object in update trigger, not showing the new History Object record?

I have a custom object (TestObject1__c) wherein I am tracking some field changes. I also have related list under this object (TestObject1__History). The problem is the trigger I created isn't querying ...
ratRiot01's user avatar
-1 votes
2 answers
234 views

List index out of bounds: 0 in IF condition

There is an error on line 36: List index out of bounds: 0 Why am I getting this error when I'm not actually using the value, instead I'm just checking if it's null?
JRachelle's user avatar
1 vote
1 answer
40 views

Updated triggering record with value from related record

I have a Flow that gets triggered when a User Lookup field (Support Specialist User) is changed/set. In an After-Update Record element two fields on the same record should be updated with the user.id ...
wp78de's user avatar
  • 191
0 votes
1 answer
89 views

How to get the Lead Record using ConvertedContactId field in after Insert Trigger on Contact?

Scenario: I have a Lead record and it's single child record. On this child record of Lead I have a look up of Contact and Account also. Whenever a Lead is converted to Account and Contact, I want to ...
Prashant Kumbhar's user avatar
0 votes
0 answers
61 views

EmailMessage Trigger causes missing EmailStatus records

An apparent problem we have found using an Apex Trigger on the standard 'EmailMessage' object is as follows: The trigger handles the 'after insert' event and when an email is sent (e.g. from an Apex ...
John Lewis's user avatar
0 votes
2 answers
44 views

Adding a local variable into a trigger gives error

I'm working on creating a trigger that uses one of the methods from the URL class and has a local variable. When I don't use a local variable it works but when I try to introduce a string it give me ...
James's user avatar
  • 319
0 votes
1 answer
106 views

when converting lead i want to check lead email is equal to existing account email if it is then i want to create opportunity under existing account

i have 2 methods in trigger ,one is if the lead have initial and final fields values then i want to create opportunity line items and subscription and this is working fine. second is when converting ...
Deena Vicky's user avatar
0 votes
1 answer
75 views

TriggerHandler Question about New/ Old Values

I am trying to compare the 'old' value with the 'new' value on a record after it is updated using a TriggerHandler. Below is my code for the TriggerHandler class and also the Trigger. Specifically, I ...
sp2's user avatar
  • 57
0 votes
1 answer
135 views

Primary user Checkbox ticked for Contact with highest Commission

I'm new to Salesforce and Apex. I need help setting a trigger which checks Contacts under a specific Account. The Contact with the highest Total Commission value is marked as Primary user by ticking ...
Rad's user avatar
  • 3
1 vote
1 answer
341 views

Apex Trigger that whenever account owner gets changed, send an email to previous account owner

Hello Everyone I wanted to write trigger that whenever account owner gets changed, send an email to previous account owner. and I wrote this trigger but working. trigger SendEmail on Account (after ...
Sajid's user avatar
  • 13
0 votes
0 answers
33 views

Custom code not implementing functionality

I am writing a trigger on Account when Account Active field is updated from ‘Yes’ to ‘No’ then check all opportunities associated with the account. Update all Opportunities Stage to close lost if ...
sourav guha's user avatar
0 votes
1 answer
114 views

After delete trigger is not firing< but code in anonymous works properly

I have Active_Contacts__c Decimal field in Account and Active__c checkbox in Contact, also created ContactTrigger and ContactTrigger handler. I have already created logic for after update event and it ...
RandomNickname23's user avatar
-1 votes
1 answer
232 views

SonKitapTarihi: execution of AfterInsert caused by: System.DmlException: Update failed. First exception on row 0; first error: MISSING_ARGUMENT, Id no

fail is:SonKitapTarihi: execution of AfterInsert caused by: System.DmlException: Update failed. First exception on row 0; first error: MISSING_ARGUMENT, Id not specified in an update call: [] Trigger....
Fatih çelik's user avatar
0 votes
1 answer
331 views

Trigger to update field on master object based on detail object field

I'm working with Opportunity object and OpportunityDetails object that have a master-detail relationship with one another. The master's api name is Opportunity and the detail's api name is ...
Tency Serah's user avatar
-1 votes
1 answer
52 views

How to convert trigger into handler of after insert, after update, before delete

trigger DPRLineItemsTrigger on DPR_Line_Items__c (after insert, after update, before delete) { if(Trigger.isDelete && Trigger.isBefore) {Map<String, DPR_Line_Items__c> ...
apz's user avatar
  • 5
0 votes
2 answers
209 views

Do I need to merge assignments in a flow on the same record or not?

I am running an after record flow Within the flow, both 'Update record' update the same record. My question: should I 'merge' both updates to reduce DML ? or the flow engine does that for me? Is it ...
Saariko's user avatar
  • 5,541
-1 votes
1 answer
121 views

How can I create custom addError message in ContentVersion trigger?

I have a trigger that will prevent the user to upload file but the error message in ContentVersion is being overridden by Lightning. How can I create a custom error message? trigger CDTrigger on ...
ratRiot01's user avatar
0 votes
1 answer
470 views

Issue with Trigger on after update and after delete

I have use case which i'm trying to wrap my head around for best approach. I have a vfp showing list of records where user can add/edit/remove records and do a final SAVE (which includes a dml->...
SMorse's user avatar
  • 47
0 votes
0 answers
59 views

How does After Trigger works when using addError in ContentVersion object? Is the file successfully uploaded or not?

I have a custom object with related files in a page layout. Now if user click the 'Upload files', I want to prevent user to upload a file. Seems like I cannot use 'before trigger' because I cannot ...
ratRiot01's user avatar
0 votes
1 answer
134 views

Issue updating record from future callout

Im having some issues updating an account after a future callout. It is worth noting that the POST from Salesforce to the ERP is successful. The issue is regarding the update after the callout. Errors:...
TOSB's user avatar
  • 3
0 votes
2 answers
137 views

ParentRecordType field on ServiceAppointment

I have this code and I was trying to get the ParentRecordType field in System Debug but I got strange issue. As you can see by getSObjectType I can check if parent record type equals WorkOrder but ...
Антон Олег's user avatar
0 votes
1 answer
1k views

Skipping exception code in test class

I have an OnInsert trigger is firing a queueable apex that makes a REST API callout. The entire code is in a try/catch block. In the catch block, the code is sending an email, updating an exception ...
Balaji Pooruli's user avatar
-1 votes
1 answer
43 views

What is logic build in When we want to Status should not blank [closed]

What I use when the Picklist value should not blank in trigger?
user125126's user avatar
0 votes
0 answers
221 views

when i restore a deleted account why its related contacts wont get restored in apex?

I know that Account and Contact has a Cascade Lookup relationship, When i delete a certain account, the contacts associated/related will also get deleted but those contacts wont be visible in recycle ...
Naveen's user avatar
  • 65
0 votes
1 answer
160 views

Write field update logic in before or after trigger

I have to perform below logic to update opportunity status based on opportunity's Account's trial__c field on insert of opportunity. For(Opportunity opp : trigger.new) { If(opp.Account....
Return0's user avatar
  • 297
0 votes
2 answers
290 views

How to use aggregate function?

I am creating a trigger on Opportunity, whenever new Opportunity is inserted the value of Amount field get summed up for all other Opportunity of the same parent Account and display the sum on the ...
PARAG TALUKA's user avatar
-1 votes
2 answers
285 views

what happens when multiple instances of a single trigger is initiated?

Lets say in this instance, you have 50 users that are on salesforce. There's a after insert trigger created on the Account object. What happens when all 50 of those users insert a new Account record? ...
leed38's user avatar
  • 123
2 votes
1 answer
119 views

Why am I getting an error about recursive update in my trigger when I add a rollup summary field?

I have a trigger on a parent object that manages master detail child records. This trigger needs to check a given flag field on the parent record to determine whether it needs to process the child ...
Phil W's user avatar
  • 33.4k
0 votes
0 answers
21 views

Hi am new for Salesforce Please help with write test class for My trigger handler Class [duplicate]

Trigger trigger AuditRecCreationFromBilling on Billing__c (after insert , after update) { if(trigger.isAfter && trigger.isInsert){ AuditRecCreationFromBillingHandler....
Krish Vins's user avatar
0 votes
1 answer
422 views

I am getting null values for all opportunity fields

I have used a Map to get the Id of the opportunity, but I am not able to access other fields of that opportunity as I am getting null value. Also, getting an error 'Attemp to de-reference a null ...
Grace's user avatar
  • 5
-2 votes
2 answers
61 views

Is my solution right logically?

Problem statement : delete all related oppertunity when user change the account status active to inactive Trigger DeleteOpportunity on Account (after update){ Set <Id> accset = new Set<id&...
Karan Bilakhiya's user avatar
0 votes
1 answer
281 views

UpdateAsync(sobject) Method to update records in a (spawn) new transaction

The documentation says that data on the external system. Asynchronous operation is used to process\update these records Query Does this mean I can update Sobjects (custom and\or standard) using this ...
IHaveAQuestion's user avatar
-1 votes
1 answer
101 views

Apex: How to Put Map of strings inside a List

Simple task but I am stuck - Trying to put Map of string inside List. Need help please. List<Map<string,string>> ss = new List<Map<string,string>>(); ss.add(new Map<string,...
Praveen Behera's user avatar
1 vote
0 answers
195 views

System.debug line hitting CPU Time Limit

I am facing weird challenge, when I use these debug statements in my AFTER UPDATE Trigger am hitting CPU Time Limit,if I comment them out am not facing that, any inputs on this will be appreciated ...
Purushothama Puru's user avatar
0 votes
1 answer
661 views

System.DmlException: Insert failed. CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, INVALID_FIELD_FOR_INSERT_UPDATE, cannot specify Id in an insert call: [Id]

I have written a triggers on object Job__c as well as Employee__c, so that when an Job record is created an Employee record would be created an vice-verce createEmp: execution of AfterInsert caused ...
Nishmitha's user avatar
0 votes
1 answer
667 views

“Best Practice” way to get value from child record saved to parent record

I get similar business requirements that ask: Get the latest child record where field X is not null, and copy field X's value to its parent's field Y The solution must work with bother master-detail ...
Tyler Zika's user avatar
  • 2,808
1 vote
0 answers
137 views

Issue while capturing the approval comments of an approval process using a trigger

I have two approval processes in my org for an object Grant Contract Modification first one being Grant Contract Mod Approval process and the second one being FinanceApprovalProcessGrantContractMod. ...
JK123's user avatar
  • 69
0 votes
0 answers
128 views

ContactTriggerHandler not triggered

I would like to create an Trigger Handler on the contacts that every time a contact is created it will trigger this and do some manipulation on the contact. For some reason the trigger is not ...
Ben2pop's user avatar
  • 395
0 votes
1 answer
137 views

Trigger: Delete Child Cloned Opportunities If Parent Opportunity is deleted

I have to implement a functionality to delete all child cloned opportunity if parent opportunity is deleted. Details: There is a self lookup on Opportunity. Cloned opportunity is clone of opportunity ...
Rose 's user avatar
  • 101
0 votes
2 answers
73 views

Trigger to generate contract numbers for each record type

I am working on a trigger which should generate grant contract numbers according to a particular format. For each RT: RT starting Number Ending Number WF 2300021 2301999 SAT 2304020 2306999 ...
PJ98's user avatar
  • 25

1
2 3 4 5
9