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

Questions tagged [trigger]

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

1
vote
3answers
21 views

How many times a trigger is fired when a record is updated?

Could someone explain me how many times a single trigger is fired when a single record is updated? I cannot paste the whole debug log because of it's size this is just a part of it. 12:35:37.830 (...
0
votes
1answer
21 views

Replacing Process builder with an Apex Trigger. Should the process builder be inactive during trigger deployment?

We have an active Process builder which runs in Afterinsert context on CPQ Quote creation. Due to certain inefficiency and enhancements, we have replaced it with Apex Trigger. However, during Trigger ...
1
vote
1answer
15 views

need to throw an error on specific record from list

I have below method and error is coming beacuse of some validation/trigger is on account and need to catch the exception If i am runnning this from Ui for one record this will throw an exception as i ...
1
vote
1answer
15 views

How to use the isUpdate() trigger handler on lookup relationship?

I have a custom object Hire_Form__c that has a contact lookup. It has the following fields: First Name Last name Email Phone Status (In Progress , Completed , Rejected) Candidate (Contact Lookup) ...
1
vote
0answers
20 views

Trigger not updating data before update/insert

We are using the Salesforce State/Country picklist and the integration values used for US States are state codes, e.g. CA, WY, AL, etc The salesforce AppExchange sends the leads to Salesforce and it ...
0
votes
2answers
24 views

Updating Apex failed: DmlException in (unrelated) Test

I am trying to update the code of a Contact Trigger handler using the Force.com IDE. However, deploying does not work because of an error in an unchanged 3rd-party class. Even if I uncomment all ...
0
votes
1answer
27 views

Avoid duplicate lead name creating instead of lead name , update all details using Trigger

This trigger is basically fired on before insert & before update. I am trying to automatically convert lead to Account,Contact & Opportunity. My condition is when an Same Name Lead is inserted ...
0
votes
2answers
57 views

Trigger Exception on data Loader

I have written a trigger to create/update a contact when account is created/updated. Every account will have one contact associated with it. When i try to load the data from data loader in to account ...
-1
votes
1answer
33 views

Help Me Solve A Null Pointer

I am trying to refactor some code. Right now I have a trigger calling lots of methods. And I would like to to have it call on master method. Right now I am getting a null pointer exception. And I don'...
0
votes
1answer
37 views

New to Salesforce - Need a simple Apex trigger to update field based on Select from another custom object [on hold]

Apologies in advance, I have looked at examples and while I understand what I want to do and could do it in SQL, etc. Salesforce is new to me and finding the correct syntax is causing me problems. So ...
-1
votes
0answers
19 views

Whenever account type is changed from any value to 'Customer' need to send an email to account owner

Trigger: trigger accouncustomertype on Account (before insert,after update) { accountcustomer.email_send(Trigger.new); } Error :Method does not exist or incorrect signature: void ...
0
votes
1answer
33 views

What is the best way to schedule calls to external services?

I have a task at hand that I am trying to figure out the best way to get done. In short I need to hit an external API, GotoWebinar to be exact. I need to retrieve a list of Webinar Sessions daily ...
0
votes
1answer
31 views

Copying Standard Object information and line items to custom object with a trigger [on hold]

I am creating a custom invoicing tool. When an Order or Opportunity is closed then an Invoice (invoice__c) is automatically populated with the line items copied to the invoice line items custom ...
1
vote
1answer
28 views

Are trigger limits applied for every flow

I'm checking an integration to a SF org and it seems to be hitting "Apex CPU time limit exceeded" and it is brining up different sources. Sometimes it breaks during a process builder action from a ...
-1
votes
2answers
58 views

i should get error if same product is added on opportunity on what object i should write code [on hold]

trigger duplicatecode on OpportunityLineItem (before insert, before update) { Map<String, OpportunityLineItem > OppLineItemMap = new Map<String, OpportunityLineItem >(); for (...
0
votes
0answers
31 views

How to add digital signature in APEX triggers to verify source? How to arrange this code?

I am not very familiar with salesforce or Apex. I have created a salesforce after update trigger. I intend to add digital signature to data I send from salesforce to my endpoint. My Apex Trigger ...
0
votes
1answer
21 views

After update trigger fires twice, first with no updated info, second with info

I'm writing a trigger that chops up a long-text field on an event activity record and puts it into the appropriate fields on the related contact's record. The problem is, the code seems to be firing ...
0
votes
1answer
26 views

I'm giving access to the children of parents of a newly created account, but i think its not working, or else how to check if this is working

public class ManuallyShareAccount { public static void manualShare(List<Account> newList) { Set<Id> accSet= new Set<Id>(); for(Account acc:[SELECT ParentId ...
-1
votes
1answer
33 views

trigger to get opportunity products [on hold]

When Opportunity stage is set to won Get list of all opportunity products of that opportunity, and search for specific product .. If the product, is found in that opportunity, then perform following ...
-1
votes
1answer
33 views

Trigger to create task if opportunity stage name is Closed Won. But getting error as variable “stagename” not found [on hold]

trigger ClosedOpportunityTrigger on Opportunity (after insert, after update) { List<Task> taskList = new List<Task>(); for (Opportunity o :[SELECT Id,StageName FROM Opportunity ...
2
votes
0answers
73 views

Delete __Sharing object

I'm receiving the following error: TR09_MasterServiceAgreement: execution of AfterInsert caused by: System.DmlException: Delete failed. First exception on row 0 with id 02c1800002Lir2PAAR; ...
0
votes
1answer
24 views

How to catch update exception and what kind of notification to do here?

I have a trigger with helper class and test. But I don't know how to test update there and what kind of notification I need. Thanks for any help. Trigger: trigger ArchivedTrigger on Item__c (after ...
0
votes
1answer
30 views

Ignore validation on before update/insert trigger?

I have a before insert/update validation trigger which I would like to be able to ignore when doing mass updates via data loader. Figured if I just add criteria of "checkbox field = true, ignore ...
-2
votes
0answers
25 views

trigger to update case before insert, update based on domain [on hold]

I am trying to create a trigger that will automatically update contact on case depending on certain criteria. Let me explain more. I have cases that come from different domains and because of that i ...
0
votes
0answers
12 views

Prefill data into FeedItem body

I have a problem, and i dont know how to make it. I need to put data into FeedItem on Case which is sent as Type TextPost. It needs to show first name and last name of the account person which is ...
0
votes
1answer
28 views

How to create OrderItem using trigger

How to create same orderItem(some field are modified) when I create any OrderItem record related to order using trigger?
1
vote
1answer
26 views

I want to create a validation rule which will throw an error if account created date is less than 6 months and type='Active'

i have used below validation rule ,but the issue is, it will check exact 180 days.there might be chances that there are 31 days in month and then days will be more than 180 days.Please suggest how can ...
-1
votes
0answers
29 views

How to create Apex test class for my trigger [closed]

I know nothing about programming and I have an Apex trigger. I can't get coverage using the basic company test class. I am guessing I need a different test class, one specifically for this Apex ...
0
votes
0answers
36 views

Schedule apex class to run every day

I want to make some rollups on a custom objects via a scheduled Apex class. I managed to test the rollup via an Apex trigger, which fired whenever I edited the custom object. Now I want to run it ...
0
votes
2answers
34 views

I have created a apex trigger. What is response code salesforce expecting from my endpoint in case of failure? [closed]

We are returning 200 for success but what should I return for failure?
0
votes
1answer
52 views

Create more than 50000 records with a press of a button in custom object depending on criteria

I am trying to create more than 50000 records with a press of a button inside salesforce for a full month. The records needs to be displayed with a timestamp of 5 minutes apart. Something like this: ...
0
votes
1answer
44 views

Checkbox on Account object needs to be updated when checkbox on all of its contact is checked [on hold]

I have a requirement where checkbox on Account object needs to be updated when checkbox on all of its contact is checked. Suppose that account has a checkbox 'Default__c'. This account is having 3 ...
2
votes
0answers
35 views

HtmlBody of on EmailMessage does not stay as set in before insert trigger

I'm trying to cut off email threading from EmailMessage. I try to do this in BEFORE INSERT trigger. Original email: Hello Tom, We saw your complaint. We are working on it. Gigasoft ...
0
votes
2answers
30 views

Trigger not assigning a value as expected

I have a Student object that has a look up relationship to a Coach object. When a student is created, I need to assign a coach to that student, based on which coach has the least amount of students. ...
5
votes
1answer
212 views

Is it possible to access the email of a Lead's owner directly?

For instance, I am writing some code to send an email using a after insert trigger. I am wanting to get the email address of the lead owner I am currently iterating over, but am running into an error. ...
-3
votes
1answer
45 views

Getting error when saving Trigger [closed]

I'm new to salesforce. I'm trying to make the changes in developer console. We have a requirement to add PDF from external source to Sales Force Community. trigger WriteAttachmentIDToEmissionTest ...
-2
votes
1answer
35 views

Trigger to update other checkboxes if one is checked [closed]

Our companies Salesforce is connected to another system, which pushes updates to Salesforce, when the information is updated there. Is there a way to create a trigger, that updates other checkboxes, ...
0
votes
2answers
18 views

execution of BeforeInsert caused by: System.NullPointerException: Attempt to de-reference a null object in trigger

iam trying to insert the data from dataloader getting error as nullpointerexception in line29 column1. trigger emailmatchdatacontact on ContactRelationship__c (before insert,before update) { ...
0
votes
1answer
42 views

Too Many SOQL queries: 101 Exception

trigger SoM_RequestCancelledOnFeePayment on SoM_Request__c (after update) { if (!SoM_Utilities.gs.Disable_Triggers__c) { List<MUSW__Fee_Payment__c> feePymtsToUpdate = new List<...
0
votes
1answer
15 views

Check a checkbox in parent when the field of child is true

I have a field in Opportunity material which is a related list in opportunity object.That field in opportunity material is a formula field that return value true or false. I need to check a checkbox ...
0
votes
2answers
28 views

Can i refire the trigger

I have a future callout method(calls external server) in a trigger. I am calling external server in future callout method and passing data(Trigger.new) to it. If the external server is down. Is there ...
0
votes
0answers
24 views

I need to Do an insert In the Data Category When there Is Insert In Object [on hold]

I have a Data Category as A B -B.1 -B.2 C Also there is Custom Object B. When ever There is An Insert/Update In Object B . I want to do Similar insert/Update In Data Category . Does any one has ...
1
vote
1answer
27 views

Can the Process builder, count the number of instances and then execute a certain task

Process automator can be used to automate a lot of things within salesforce. For one such scenario can I use it to count the number of instances of a certain object and then set a checkbox value to ...
-3
votes
1answer
33 views

Trigger not working as expected

I'm new to triggers I create a trigger to update lookup field on a custom object but when I use it with a bulk update, insert the records missed up in the list, Kindly find the trigger below and help ...
2
votes
2answers
485 views

FOR Loop NOT being executed w/ NO errors

The trigger is firing, there are no errors, and it is running through all of the code, except the FOR loop w/ the SOQL query. THE QUESTION Why is the trigger not jumping into the FOR loop? THE ...
6
votes
2answers
67 views

Revoke access to delete a specific Account record type

I have this apex trigger that revokes access to users from deleting all Accounts. I was wondering how to improve it to ignore or allow certain record type. The use case is, I want to allow users to ...
0
votes
0answers
23 views

Trigger in working as expected in inline editing , But it is not not working when I click the edit button

Hi Folks I have a requirement to copy the case contact id to the task (WhoId) Field. Logic I implemented. 1: Check the task whatID is not blank and the whatId starts with 500 (Case Prefix Which ...
2
votes
2answers
65 views

Map / Trigger / Governor limits

While studying for my Platform Developer 1 exam, I came across this line. Could someone please explain how this is the case? Question: How can a developer avoid exceeding governor limits when using ...
1
vote
2answers
129 views

How prevent deletion in Event delete trigger and update a field instead

Our Salesforce users are deleting Events from Salesforce due to our integration with Outlook. When a Meeting from Outlook is deleted, we want the corresponding Event record in Salesforce to be not ...
2
votes
1answer
46 views

SOQL in Apex trigger returns [Name Set by Trigger]

Have 2 managed packages. One package contains Recurring object. Another package contains Receipt object. Opportunity has lookup fields to Recurring object and to Receipt. Created text field '...