Questions tagged [trigger]

A trigger is a feature of the Salesforce platform consisting of Apex code that executes before or after DML operations.

Filter by
Sorted by
Tagged with
0 votes
0 answers
10 views

Email Messages - Issue changing ToAddress/BCCAddress before its sendout

I need to send the outgoing emails from a sandbox to a group mailbox. when I implement it in a before trigger SF reset the values again. also after trigger doesn't work. Do you have any suggestions? ...
user avatar
  • 1
1 vote
1 answer
37 views

Hello everyone, I need some help with triggers

So basically, I'm struggle in this trigger. What I have to do is: get the max Commission Amount value of the contacts from an Account, check which is the largest and trigger a check box field called &...
user avatar
0 votes
0 answers
12 views

dlrs_CommSubscriptionConsentTrigger: execution of AfterInsert

I got this error after installing the DLRS open source app to make a roll up summary from a lookup relationship... I'm trying to create a consentement for a specific contact and when saving, I got ...
user avatar
-2 votes
0 answers
24 views

I want this trigger to only run when the record type is = 'SOT Record' [closed]

trigger RollUpMaster_line_item on Master_Line_Item__c (after insert, after update, after delete, after undelete) { Set<Id> masterIds = new Set<Id>(); if(Trigger.isInsert || Trigger....
user avatar
0 votes
0 answers
25 views

Lock an approval process for a particular profiles users and system admin

I have created an approval process and provided field update such that each time I submit a record for approval,the pick list value changes to 'Approval Pending'. On continuation to this, I have added ...
user avatar
  • 47
0 votes
1 answer
30 views

Convert workflow rules with Evaluation criteria to Apex code

I have criteria in the workflow which need to convert to apex code. Here is the WF rule and criteria to convert. Rule Criteria: Opportunity: Status EQUALS Service Evaluation Criteria: Evaluate the ...
user avatar
  • 233
0 votes
1 answer
41 views

How to assign the lead owner data to contact in a trigger?

I'm trying to create a trigger that creates an account and contact when the lead status is changed to a given value. The contact value needs to come from the Lead Owner User. How can I achieve that? ...
user avatar
1 vote
2 answers
39 views

Prepopulating company name in Lead object

I want to prepopulate the Company field in the Lead object. The idea here is that I don't want a Company Name in my Leads ie the Account object is not necessary for me. Now, as you know the company ...
user avatar
  • 109
-2 votes
0 answers
29 views

Constructor not defined: [GenerateGLpostingBatch].<Constructor>()

I'm trying to delete a trigger (a simple task) but for some reason, I keep receiving the following error no matter how I delete/amend the trigger. Constructor not defined: [GenerateGLpostingBatch].<...
user avatar
0 votes
1 answer
14 views

Run Trigger handler class in execute anonymous with old map newmap

Trigger createCbQuoteTriggerHandler.getOpps(Trigger.new,Trigger.oldMap); Handler class public static void CreateOpportunity(Map<Id,Opportunity> oldData, List<Opportunity> newData){ ...
user avatar
0 votes
0 answers
22 views

a method in contentversion trigger return "List index out of bounds: 0"

i am making a content release trigger with a method to update the mobile business app for my work. The objective of all this is to send the data stored by the SNOTES and store it in the backend of the ...
user avatar
  • 21
-1 votes
0 answers
34 views

Write the following apex trigger [closed]

Anyone can help me to write following trigger: Find the first 2 contacts with the highest salary and update the name in a custom field separated by a “,”. Create a new custom text field on account ...
user avatar
0 votes
1 answer
25 views

Tdtm Trigger framework

I checked the Npsp and Eda packages, and both have its own flavor of Tdtm framework. So I checked the Tdtm classes in Eda package. But looks like these files are dependent on Eda package. I can look ...
user avatar
  • 1,242
-1 votes
0 answers
22 views

Execute trigger event if data is came from authorized app [duplicate]

I have created an apex trigger on behalf of client using rest API for an update event on case object. I want to execute this trigger only when the case is created using rest api through my connected ...
user avatar
-2 votes
0 answers
27 views

test class this batch with Trigger [duplicate]

Sorry how can i create a test class for these related classes? batch code : global class CreateRicontatto implements Database.Batchable<sObject> { String campaignId; global ...
user avatar
  • 1
1 vote
2 answers
42 views

Deployed code to production without code coverage

My teammates have deployed a code to production without getting the class getting covered. and now I have added a small functionality and trying to push the code but deployment is failing is class ...
user avatar
-2 votes
2 answers
49 views

I have an error.Where am I going Wrong?The question is that all child cases should be closed then and only then parent can change status

Status: execution of BeforeUpdate caused by: System.SObjectException: SObject row was retrieved via SOQL without querying the requested field: Case.ParentId Class.StatusTriggerHandler.StatusHandler: ...
user avatar
-1 votes
1 answer
29 views

Trigger error- System.StringException: Starting position out of bounds:

There are some lead gen profiles in our salesforce which I want them to create opportunity for any appointment created and Stage to be selected as "MQL" which is newly introduced in our ...
user avatar
0 votes
1 answer
42 views

Getting content from within triggers is currently not supported

I am sending a pdf in an email when the opportunity is created on updated which works fine. Now when the opportunity is created through batch so its throws the error future method can not call future ...
user avatar
  • 3
-1 votes
0 answers
21 views

Lead Conversion to display error message

How to display a error message in lead conversion popup page, while converting a existing account, in that lead conversion page will show error Eg.I have a revenue field in lead object while ...
user avatar
0 votes
1 answer
48 views

Trigger to allow only one field to update

I need to write an trigger to allow only update one field on a lead object, not any other fields. Condition I written is like - if(leadobj.test__c == oldlead.test__c){ leadobj.adderror('can't update ...
user avatar
0 votes
1 answer
43 views

Static Approach in recursive trigger

When we can avoid recursion conditionally using oldMap and NewMap in trigger to restrict what change fires the triggers, why do you have to go for static approach?
user avatar
  • 13
0 votes
2 answers
49 views

Avoid Nested for loop

Background: When inserting a contact I have to check if there are any other contacts associated to the same account and its a primary contact to that account is yes, then the new contact cannot be ...
user avatar
0 votes
1 answer
44 views

Trigger not updating records - DML not being called(?)

I created a Trigger on Contact to update the associated Account each time a Contact is added or edited; the Trigger checks that each Contact in the Account has a valid credit card associated with it, ...
user avatar
  • 1
1 vote
0 answers
51 views

Prevent creating new file while uploading new file from Salesforce standard upload button

Whenever a user uploads a new file under a particular record, I need to check for an existing file with the same name. If there is an existing file, then it should not create a new document; instead ...
user avatar
0 votes
0 answers
14 views

Hi i have to write test class for following trigger handler class? can anyone help me in same. Code is mentioned below [duplicate]

public class ActionsToBeTakenTriggerHandler { public static void handleAfterUpdate(List<Actions_To_Be_Taken__c> atbtList, Map<Id, Actions_To_Be_Taken__c> oldMap){ if(atbtList !=...
user avatar
2 votes
1 answer
139 views

Hitting governor limits and getting the "Apex CPU time limit exceeded"

I had to write a trigger to manage a lead deduplication process designed by someone else. In a nutshell: A lead gets inserted Checks on name and email of existing leads and contacts (person accounts) ...
user avatar
  • 305
0 votes
0 answers
19 views

Cannot change Status of FeedItem in trigger

I have a simply spam classification logic in trigger which runs when a community user posts a post (FeedItem) in experience cloud sites (community sites). trigger FeedItem_Operation_Trigger on ...
user avatar
0 votes
0 answers
26 views

Double OptIn list option inserts contact as "Active" automatically

Ive been trying to make a classic list with the Double OptIn function following these steps, and the part about sending the email works perfectly. But, each time a new contact is added to it through ...
user avatar
3 votes
1 answer
216 views

Salesforce Flow Limitations - Loop vs Batch Records

I have recently been digging into salesforce flows. I created quite a large flow (basically a series of subflows). It all worked as expected, and was based on when one of my objects was created or ...
user avatar
-1 votes
2 answers
40 views

Trigger to update an Account everytime a related Opportunity's stage changes

I need to add a description on my Account every time an Opportunity's stage is changed. I tried the following and getting NULL pointer exception. public class opportunityTriggerHandler { public ...
user avatar
-1 votes
2 answers
45 views

How to Assign Custom Metadata value in Apex trigger

I have a requirement whenever Opportunity Stage is moved to "closed won" I need to create a Task and assign it to Queue. I am getting regular requirement from users to create a Task with ...
user avatar
  • 55
-1 votes
0 answers
11 views

Attachment will work when uploading via Mobile [closed]

I have made a trigger which will update a check box field when a attachment is inserted and its working but when someone uploads attachment from mobile its not updating that checkbox field...Please ...
user avatar
0 votes
1 answer
26 views

Test class for covering running user current application info

I have a class where I am using a method that returns the application label of the current logged in user. I am using that class method in another class method and based on the returned app name, I am ...
user avatar
-1 votes
1 answer
41 views

Fetch all the accounts from large account hierarchy

I'm trying to fetch all the accounts from account hierarchy from all the levels, code should work for any number of levels. for example : If there is a account hierarchy then using any of the account ...
user avatar
2 votes
1 answer
45 views

How do I run the default Lead assignment rules on a Lead trigger

Here's my code stripped of the usual professional infrastructure for illustration: trigger LeadTrigger on Lead (after insert, after update, before insert, before update) { if ( ! Util....
user avatar
0 votes
1 answer
24 views

Get value from Map in trigger

I am trying to get values from map and assign the value in trigger. Below is the code so far - I need to get ID based on a value from a Map which I have created. public class AccountTriggerHandler ...
user avatar
0 votes
2 answers
21 views

Are processes triggered if a field is set to the same value as it held before?

An Apex method is called and updates the StageName field from 'Approved' to 'Documentation.' It completes. A different Apex method is called and 'updates' the StageName field on the same record from '...
user avatar
0 votes
0 answers
16 views

ContentDistributionTrigger after insert ContentDownloadUrl null

I have a ContentDistributionTrigger trigger after insert & update which when fired has a null value for ContentDownloadUrl. The ContentDistribution is created in a ContentDocumentLinkTrigger as ...
user avatar
0 votes
1 answer
25 views

why Created Date fields is also update on merge records?

I'm merging the old existing lead with a new lead. but the problem is in the new lead all Created Date and other information is also getting updated in the new lead. which I don't want can anyone ...
user avatar
-3 votes
2 answers
38 views

System.LimitException: Too many query rows: 50001 in apex trigger [closed]

I have a simple trigger on account object. In which i am querying the account records. When I am trying to insert 5000 account records in bulk the System.LimitException: Too many query rows: 50001 ...
user avatar
-1 votes
0 answers
17 views

Auto Response Emails, date time format change

can anyone please explain me about the scenarios mentioned down below: I am trying to trigger the auto response emails between 12-4pm on a particular day. Date & time format needs to change from ...
user avatar
0 votes
1 answer
22 views

Evalution criteria in record-triggered flows vs apex trigger

Due to some performance issues, I plan to migrate the Record-Triggered flows to the Apex trigger code. I wrote all the criteria logic and updated the records in the Before Insert and BeforeUpdate ...
user avatar
  • 233
-1 votes
0 answers
39 views

too many soql queries: 101 error

I am trying to complete the Understand Execution Context trailhead and getting the too many soql queries: 101 error, it works fine when the test limit is 100, but doesn't work when it is 200. below is ...
user avatar
0 votes
0 answers
37 views

How to get 100% test coverage for an apex trigger associated with an asynchronous callout?

I am looking for assistance on why 'zipCodeTimeZone.makeCallout(objLead.Id)' in both places on the trigger is not being covered/triggered by my test method while it is providing 100% coverage for the ...
user avatar
  • 1
0 votes
1 answer
41 views

Unable to update my contact records

I have written a trigger to update the contact's individual balance field depending on the number of contacts associated with the account but I am unable to view it on the UI trigger ContactTrigger on ...
user avatar
  • 53
0 votes
2 answers
59 views

Trigger for Case's Subject but change of Owner To Queue Not happening

At a conceptual level, below is what Trigger code is doing Query for Salesforce queue name Prepaid Iterate over the Email 2 Case records for Record Type as "Executive Response " I get (...
user avatar
0 votes
1 answer
29 views

Add Opportunity Contact role from account contacts

I have a requirement to creates an opportunity contact role record whenever an opportunity is created. The records should be created from the account's related contacts. I have written the following ...
user avatar
  • 53
0 votes
1 answer
52 views

Is Apex Code Consolidated per object the best way?

Our vendor has consolidated apex per object, however, when they added new apex code for us under a specific object - it is now throwing an error (exceeded CPU limit). When looking at this code, is ...
user avatar
0 votes
0 answers
20 views

Hide action (custom button) after use it

Hi everybody I have a detail page of X custom object that has a custom button (Action that display a Flow that has a LWC form). This button creates a record of Y custom object. I want that after the ...
user avatar

1
2 3 4 5
152