Questions tagged [trigger]
A trigger is a feature of the Salesforce platform consisting of Apex code that executes before or after DML operations.
7,920
questions
0
votes
0
answers
9
views
CANNOT UPDATE ACTIVATE ENTITY
I'm using salesforce Bulk API to update the records in salesforce from the GCS bucket . I'm getting the below error . I need to know whether this error is related to saleforce or it is from our side . ...
-2
votes
1
answer
28
views
Trigger to get products records on a long text field in opportunity
Hi i am new to triggers need some help to start the following.
Products is a related object on opportunity and it can have multiple records. I need a trigger to summarize (Product Name, Quantity, Sale ...
0
votes
1
answer
41
views
Need help increasing the code coverage for this trigger
I'm a newly hired Salesforce admin and I've been struggling to deploy this trigger since this code is completely new to me. I've been trying to deploy a new version of a trigger with, at most, 10 ...
-1
votes
1
answer
40
views
In Salesforce, if there are multiple FLOWs active for the same object then does trigger fired only once or will it be fired for each FLOW
In Salesforce, if there are multiple FLOWs active for the same object then does trigger fired only once or will it be fired for each FLOW (assuming each FLOW updates different fields)
Additional ...
-3
votes
0
answers
33
views
Create Trigger for counting Total no of 'Partner cases' and Total no of 'Customer Cases' on account. Partner cases and Customer Cases are record type [closed]
Create two record types named as “Partner Case” and “Customer Case” on Case Object. On creation of Case populate the total number of Partner Case and Customer Case on Account object. Create Custom ...
0
votes
0
answers
24
views
@future(callout=true) AppExchange Package is Deprecated, Details: The AppExchange package has been deprecated and can no longer be installed
I'm experiencing an issue when trying to make an asynchronous HTTP call within an Apex Trigger using the @future(callout=true) annotation. The objective is to trigger a package installation via an ...
0
votes
1
answer
36
views
Querying CampaignMembers based on Lead fields
New to Apex and code in general so I would appreciate any recommendation on how I´m approaching this problem.
My Lead Object has a custom field utm_content__c that will hold as value the Id of the ...
-1
votes
1
answer
46
views
Trigger to calculate Average date of closed opportunity if its closed won?
public class AverageDateOpportunityHandler {
public static void afterUpdateMethod(List<Opportunity> oppList) {
Integer totalDays = 0;
for (Opportunity opp : oppList) {
...
1
vote
2
answers
77
views
Batch Apex Class Invoked From Before Delete Trigger is not deleting Files Attached to accounts
I have written a batch class to delete the files related to an account whenever an account is being deleted. When I have tried the same code and logic without batch class it works fine. But in batch ...
0
votes
0
answers
36
views
Delete in a Apex Test Class
I have this apex test class, the only problem with this is delete isn't being covered when running test. Is there something missing from this?
@isTest(seeAllData=false)
public class ...
0
votes
1
answer
30
views
Syncing data with legacy system
Because of the dreaded SOQL 101 limitation, I have a few flows that run with a delayed path. This is ok, as the processes in the flows do not require to be run instantly. However, in the delayed path ...
0
votes
0
answers
40
views
Record triggered flow not invoking when Event record is created via Lightning sync
Issue:
In our org events are created via lighting sync when outlook meeting is scheduled for user who is part of sync configuration.
When a lead has events associated with it and that event owner is ...
-1
votes
2
answers
48
views
System.DmlException: Insert failed. First exception on row 0; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, execution of AfterInsert
My trigger is given below. Whenever new contacts are inserted, total_salary__c on the account object should increment or decrement
trigger updateAccountSalaryNew on Contact (after insert,after update,...
0
votes
1
answer
48
views
How to edit Parent Record from Related Record
Objects : Lead(Parent record),LeadClientInsurance__c (Related records)
if I change the First_Name__c in LeadClientInsurance__c object I need to change FirstName in Lead Record.
Theoretically,
...
0
votes
1
answer
52
views
Partial commit in before insert trigger - Apex
The Account object has a required field called Test__c to create records in system. I have an apex trigger which updates the field called Copy_Name__c with same details as Account Name. I was trying ...
0
votes
1
answer
37
views
Apex - 0% Code Coverage!
I've developed a trigger that converts a currency field, Amount (i.e. $1,000) into words, Currency_text__c (i.e. One Thousand).
This is achieved via Salesforce a 'FundingAwardTrigger' on the ...
1
vote
1
answer
55
views
I'm trying to bulkify the update of parent field based on child
I've written a trigger that is called when child record is inserted. I want the room(Parent) status to be updated to Occupied when the patient(Child) closure is set to false.
Here's the code that I ...
-2
votes
1
answer
38
views
Getting System.NullPointerException: Attempt to de-reference a null object . Trying to update Account Description field as OpportunityLineItem Desc
trigger OppLineItem on OpportunityLineItem (after insert) {
if(trigger.isAfter && trigger.isInsert)
{
Set<Id> oppIds = new Set<Id>();
Set<Id> ...
1
vote
1
answer
53
views
Conflict Between Triggers on blng__Invoice__c: Billing Package vs. Custom Development
We have the Salesforce CPQ Billing package installed in our organization without any problems.
Since the new Winter '24 release, we have sometimes encountered deployment errors in our org due to the ...
0
votes
2
answers
36
views
If a user can access only the salesforce UI, will there be multiple transaction for that user?
Please correct me if I am wrong. Somewhere I read an article that each account has their own separate transaction. Also, I don't think that customers will be using Developer Console to update or ...
-1
votes
1
answer
34
views
Field is not writeable: Opportunity.PartnerAccountId
I am trying to update the field PartnerAccountId (Partner Account) on Opportunity object when a Lead is converted and a new Opportunity record is created.
I am doing this in Trigger Before Insert ...
0
votes
0
answers
70
views
Work Order Line Items
I'm trying to write a trigger that when a new Work Order Line Item gets added, finds a duplicate Work Order Line Item on the same Work Order, adds the new quantity to the existing record and then ...
0
votes
2
answers
57
views
Can we compare a currency field and number field in system.assertEquals ...If yes ...How?
@isTest
public class HandlerClassTest {
@isTest
public static void InsertTestMethod()
{
List<Account> accList = new List<Account> ();
for(Integer i=0;i<5;i++)
{
...
0
votes
2
answers
79
views
How to get group ID of the public group?
I tried to add User to the Admins public group whenever a new User is created with system admin profile. But I got the following error :
Apex trigger addAdminToPublicGroup caused an unexpected ...
2
votes
1
answer
107
views
The need of database.savepoint vs not using try catch at all
This has been something that has been really bugging me. What is the need of using using a database.setsavepoint along with try catch when you can just do without it?
With try catch and savepoint.
...
0
votes
0
answers
44
views
Test class for @future method called by trigger not working (Methods defined as TestMethod do not support Web service callouts) [duplicate]
I have a trigger on Account that makes a call to an apex class:
trigger AccountAddressTrigger on Account (after insert) {
Id patientAccountRecordTypeId = [SELECT Id, RecordType.DeveloperName FROM ...
-1
votes
1
answer
17
views
Unexpected Tokens on Test Class for Apex Trigger: What am I doing wrong to create a test class for this Trigger trying to deploy to Production?
@isTest
public class LeadRemovalTestClass
{
Static testmethod void updateRecord()
trigger UpdateLeadOnRemoval on ActionCadenceTrackerChangeEvent (after insert) {
...
-1
votes
1
answer
69
views
Why code is not working to avoid duplicate insert/update of Account with same name
trigger Account14 on Account (before insert, before update) {
List<String> AccList = new List<String>();
if(trigger.isbefore && (trigger.isupdate || trigger.isInsert))
...
3
votes
0
answers
67
views
Platform Events - setResumeCheckpoint method is not working as expected after throwing an EventBus.RetryableException
We have a Platform events framework that takes the responsibility of processing a batch of n incoming platform events. This framework was working fine until around one/two months ago when we realized ...
-1
votes
0
answers
43
views
Case Assignment Rule and Case Before Update
I have Case assignment rules in which Case Owner gets assigned to a default queue when a new case is inserted.
After that a specific user from that queue changes the case ownership to a different ...
1
vote
1
answer
61
views
Can you automatically retry a trigger if record validation fails without user intervention?
We have a custom field with the Unique Id attribute. This field represents a randomly generated string that is used as a publicly facing identifier.
This public id field is randomly generated and ...
1
vote
1
answer
60
views
How do you acquire an exclusive lock on an object within an Apex before insert trigger?
Inside an Apex before insert trigger, what is the correct way to get an exclusive lock all records of a particular object for the length of the trigger's transaction?
This trigger needs an exclusive ...
0
votes
0
answers
56
views
@Future method is not getting called. No logs, no exception no errors. When records are inserted through REST API call from an external system
Orders custom object have a lookup on Contact. Each Order will have a corresponding contact. A contact can have multiple orders.
When an order's is inserted through Salesforce or any tools for ...
0
votes
1
answer
53
views
Help with Test Class for on insert Opportunity trigger [duplicate]
A user can create an Opportunity only by converting a Lead. But for some reason the primary contact on the opportunity is not getting populated. I have created an Opportunity trigger that runs on ...
0
votes
1
answer
44
views
Custom Convert Quote to Order with child object
Hello I am new to Salesforce.
I want to custom convert Quote to Order with Packaging Details for Order Item.
Packaging_Details__c is the child object of QuoteLineItem and OrderItem objects, An item ...
0
votes
1
answer
41
views
Fix Record Lock issue or Record Not available
I have a trigger on an Object called SubscriptionProductCharges.
we have another system that are updating SubscriptionProductCharges records in a batch of 1, which means if we update 5 records, then ...
0
votes
2
answers
41
views
AfterInsert caused by: System.FinalException: Record is read-only
I want to update a record that has recently been created.
Trigger:
trigger TTCaseTrigger on Custom_Case__c (after insert) {
if(Trigger.isInsert && Trigger.isAfter){
if(...
3
votes
2
answers
111
views
Is There a Best Practice for Associating Apex Test Classes to Apex Classes?
About a year ago, I developed an Apex project that involved a trigger/handler. It included the trigger, a trigger handler class, several helper classes, and a test class. All went well.
Recently ...
0
votes
0
answers
56
views
Declarative solutions vs APEX programming - recommended way to choose the right tool
Salesforce recommends to use firstly declarative solutions over the programmic ones.
But if there is something it cannot be done declaratively, then there is need to switch/use the programmic way.
But ...
0
votes
1
answer
56
views
Change Data Capture (Async Apex Trigger) vs @future method in Trigger
What is the difference between using the Async Apex trigger and @future methods? Why use Async Apex Trigger when we have @future method to separate the thread from the main Trigger?
The only ...
0
votes
0
answers
44
views
How do I capture the Picklist Selected Event and write the code behind?
To everyone,
I'm new to SFDC, but I'm not new to development.
Here is what I'm trying to do:
1.) Place Picklist on the Lead page with values RDC and Wire - this is done
2.) Capture the Picklist ...
-1
votes
2
answers
34
views
I'm not able to Insert New releted contact with with 'Primary Contact' checkbox checked. help me out there
trigger PrimaryContactTrigger on Contact (before delete, before update, before insert) {
if (Trigger.isBefore) {
if (Trigger.isDelete) {
for (Contact con : Trigger.old) {
...
0
votes
2
answers
53
views
How to update values in related object fields after record is deleted
I have two objects ObjA__c and ObjB__c which are in many-many relation. Now there is a field on ObjA__c which is sum__c and this value is a sum of rank__c field on ObjB__c.
For ex:
If ObjA__c has 3 ...
-2
votes
1
answer
36
views
Setting checkbox fields via trigger
I'm in the process of learning Apex triggers, and I've been attempting to write code that runs before updating a field.
The code should change the Primary Contact field to FALSE if the checkbox field ...
1
vote
3
answers
266
views
Why Trigger.new is a list and not a sObject?
I'd like to understand why Trigger.new is a list and not a sObject.
And if I do:
insert record1;
insert record2;
Will both record1 and record2 be in the same Trigger.new?
-1
votes
1
answer
24
views
Can after trigger be used when there is constant changes in record
Hello so I used after trigger to update a status field in a record thinking its a after process. Will the trigger get invoked even after the status field is updated after the trigger condition is met ...
0
votes
1
answer
57
views
Check if account is updated via Lead conversion
We want to run some logic on Account trigger only if it is created/updated via lead conversion.
So far, we have tried 2 approaches:
Approach 1: We tried creating a checkbox field on Account 'Is Lead ...
0
votes
2
answers
76
views
Updating Account Object in Salesforce with Apex Trigger
I'm new to apex and trying to figure out how I can update a custom field on the Account object when a note is added. This is what I have for a trigger but the field isn't updating. I am not getting ...
-2
votes
1
answer
87
views
Field is not writeable: Account.ShippingAddress
I was coding a trigger for automatically fill up shipping address when a account is created with billing address.
code down below
trigger BillingAdd on Account (before insert) {
List<Account> ...
5
votes
1
answer
369
views
Best approach to make callouts from trigger
I have a requirement in which, for each time an account is inserted, I have to make a callout to an external system sending some data of the record and then the API returns a unique Id that I have to ...