Stack Exchange Network

Stack Exchange network consists of 175 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.

0
votes
0answers
5 views

Identify Last Created Email Related to Case (Received or Sent)

I am trying to identify the last (most recently created) email related to a specific case. My purpose is run queries on cases and then for related emails and only show the last created email related ...
1
vote
0answers
18 views

Need to reconfigure Process builder formula

Person Accounts is enabled Have multiple record types on Accounts (a few for 'Accounts' and a few for 'Person Accounts' They have an old process that was implemented, but we re-architected the ...
0
votes
1answer
18 views

Trigger is only updating one record per batch

I have a trigger that creates an AccountTeamMember object every time there is an update to an Account_Ownership__c object (this is a custom object that we've created in house to act more in line with ...
0
votes
2answers
40 views

How to get the response data in @future(Callout=true)

I need to catch the response of a callout method and insert it into a database. But what the problem is, the callout method called from a trigger. Therefore, I have to add the annotation @future(...
1
vote
4answers
270 views

Multiple OR (||) Conditions in If Statement

Can anyone explain why the following If statement does not work with multiple OR conditions. The goal is when this trigger runs, if the user's Id who is updating the record is not equal to a specific ...
0
votes
0answers
16 views

Updating List won't go to Before Update Trigger

I am trying to update a list of custom object, I tried putting a System.debug on the Before Update to know if my DML really went there. If I update only one single record it shows me the System.debug ...
0
votes
0answers
26 views

On creation of ContractLineItem getting FIELD_INTEGRITY_EXCEPTION

I am creating a ContractLineItem record on the creation of ServiceContract by using a trigger. Below is the error I am getting Error: Invalid Data. Review all error messages below to correct ...
0
votes
1answer
17 views

Single Email limit per execution using Apex Trigger

How many emails will be send using trigger per execution?
-4
votes
0answers
29 views

I have a trigger with handler, and done test class as below,please let me know any further modifications required [duplicate]

Trigger: trigger SetExpenseManagerAndFinanceManager on DA_Expenso_App_Expense_c (after insert, after update, before insert, before update) { if(Trigger.isBefore && Trigger.isInsert){ ...
1
vote
1answer
36 views

Apex code coverage and static boolean recursion flags

I've written two Apex Triggers, one on the Opportunity object, and one on a custom object. These two triggers keep the two objects' checkboxes in sync; setting a value on one object's value sets the ...
0
votes
1answer
32 views

How to move a SOQL query that contains a loop variable, out side of for loop?

I'm new to Apex and need to assign a User to a Contact via lookup field on the contact record based off of the user with the least amount of assignments and matching endpoints (account name custom ...
-1
votes
1answer
58 views

Assigning a Set<String> to a string value

I tried separating the trigger and class, but now I am unable to populate the account field, ProductsOwned__C with the set of string elements, mapTemp. I am looking to make edits on the asset(s), take ...
0
votes
0answers
26 views

best practice to find the duplicate contact using apex trigger (not using duplicate rules)

I am using the below handler class in contact trigger to find the duplicate contacts, it checks only the lastName now if I want to check more than 2 or 3 filed then the only option I have is to create ...
0
votes
2answers
37 views

make other record checkbox inactive when a recod is having active on insert/update

trigger CM_season_Indicator on CM_Season__c (before insert, before update) { List<CM_Season__c> SeasonObjList = new List<CM_Season__c>(); Set<Id> SeasonObjIds = new Set<Id>();...
1
vote
3answers
65 views

Contact trigger to limit an account to not have more than 2 contacts

Yesterday I got rejected from a job interview because the interviewer asked me to write a trigger to limit the number of contacts per account and I wrote exactly the below but he said this won't work ...
-3
votes
0answers
32 views

Can we write a trigger on object which are not related? [on hold]

Can we write a trigger for unrelated object like i have a object A and Object B which are not related, when fields in object A is updated or inserted consequently object B fields will be populated ...
0
votes
1answer
33 views

can we used soql query in triggers

I just want to ask you all of you. can we use soql query in triggers? when I was searching in google and found that in one article "SOSL is not used in Triggers". while soql is used in triggers.
1
vote
1answer
23 views

Real time synch with external application on insert and update of frequently changing records

In order to synch very large amount of frequently changing data to an external system, what will be best way to do it ? We can't use trigger or schedule batches as these will fire so many times that ...
0
votes
1answer
33 views

Null reference error in trigger on required field

I have this trigger that changes the Name of a record based on a custom title__c field: trigger assignDegreeName on Degree__c (before insert) { /** Variables **/ integer maxSize = 80; ...
0
votes
1answer
32 views

Retrieving Values from Custom Settings based on 2 field combination and how to retrieve in trigger

I have 4 fields on my custom setting record type name, record type id status send email notification type Now i have to create a new record based on the case status and status combination like
0
votes
1answer
32 views

Accounts and Orders

I'm trying to build a trigger between Accounts and Orders. I've already built the trigger and made it to work but wanted to confirm my understanding. Requirement: The Sum of Order Amounts should be ...
0
votes
0answers
9 views

Reference a table and return a result in Salesforce [closed]

I'm looking for some help with the design of a discount process in Salesforce. Based on the combination of two variables (number of employees and discount percentage), one of three outputs (green, ...
0
votes
2answers
18 views

Trigger on Email message related to an opportunity optimization problem

I actually have some confusion with my code . i'm trying to create a trigger that fires when an emailMessage related to an opportunity is inserted. My code is fine but i was thinking that if my ...
0
votes
0answers
26 views

Trigger not firing when field updated via Process Builder [closed]

I have a trigger that fires correctly when I manually update a field. However, when the same field is updated via Process Builder the trigger is not firing. Thoughts?
0
votes
0answers
25 views

Trigger Rollup Assets to Account

I am trying to rollup the values of the assets on a particular account to that Account's active products field. I receive an error when try updating an asset that the string is too long (my code seems ...
0
votes
1answer
19 views

Issue with constructor when calling class from a Trigger

I have written a very simple trigger, but when I am trying to call the class I get 2 errors: BenchmarkProgressTriggerHandler Line 11 Expecting '}' but was: 'for'; BenchmarkProgressTriger Line 3 ...
-2
votes
2answers
27 views

Method does not exist or incorrect signature: void CreateUse(List<Ent_Req__c>) from the type Usrcreation_controller

I am trying to create a user record based on other record getting created, I added all the code in apex class and I am trying to call apex code method in my trigger. I am getting incorrect signature ...
0
votes
0answers
15 views

Update case record when Email Message Status changes

want to update a checkbox whenever related email message status gets updated From "New" to "Read". I tried with workflow and trigger, neither worked. Somewhere on Stackoverflow, I found Email ...
0
votes
2answers
25 views

Trigger on Sending Attachments in Related List not finding the attachments

I have cobbled together this code in an attempt attach the files in the attachment related list to the email on the change of a field in the Expense record (custom object). The code saves but i get a ...
1
vote
1answer
13 views

How to update Lead Status pick value field based on time

I have a Lead and two fields: "Lead status" (datatype: pick value, two values "test1" and "test2") "Event Date" (datatype: date) E.g. Current date is 4/6/2019. A lead has "Lead status" set to "test1"...
1
vote
2answers
61 views

Messaging.sendEmail(emailList) in Trigger is getting invoked, but the email is not going out when addError is being called

I am trying to send emails from trigger. Below is my code. I can see in the debug log that the email is sent out but I am not receiving any emails. When I ran the same code for sending out emails from ...
0
votes
1answer
24 views

Debug logs on triggers

I have a requirement to capture logs related Account and Opportunity triggers. I have configured 'Traced Entity Type' to 'Apex Trigger' , 'Traced Entity Name' to 'Account Trigger' and 'Debug Level' to ...
0
votes
2answers
22 views

Use trigger to prevent the System Administrator from editing a field, but still allow Apex code to edit it

My goal: to have a field on Account that is read-only for everyone (including System Administrator) but the field can still be edited by Apex code. For example, when an Opportunity is closed as won, ...
0
votes
1answer
21 views

MISSING_ARGUMENT, Id not specified in an update call: []: [closed]

I am getting an error : User can create a task from account or contact, on a task contact is a required field, but when a user tries to create a task from contact it fails. public with sharing ...
0
votes
0answers
24 views

Future call firing twice on leadconversion trigger

Here is a brief of what i am doing on my trigger Before update and Before insert updates a Account lookup field After update and after insert converts the lead if the lookup field is filled in ...
0
votes
0answers
14 views

Auto approve record after it were submitted for approval

I try to approve record automatically after it was send for approval by standard functionality. How can it be done through apex? Here is my code: trigger ITAssetTrigger on IT_Asset__c (after update) {...
0
votes
1answer
27 views

Journey Builder as a part of trigger mail [closed]

I want to start a journey with an entry event in journey to fire first mail as soon as the user registers. I know that we can use trigger send to trigger mail. But i want to use journey builder. I ...
0
votes
1answer
19 views

How to modify Contacts/Lead related to a Task with a TaskRelation upon Task Creation

We have some APEX code that relates Contacts and possibly a Lead to a Task using one or more TaskRelation objects. Therefore the pseudocode is: Database.SaveResult[] srList = Database.insert(newTasks,...
0
votes
0answers
39 views

Inserting record on Junction object with formula fields

I have Junction object called Agreement Scope which has two Master Detail relationships with Account and Agreement. We are assigning Account and Agreement in the lightning components Apex Controller ...
1
vote
1answer
80 views

Method Does Not Exist error message

My class subtracts the values of child account number fields from the current values of it's parent account number fields in a hierarchy. I need this class to run everytime a child account changes its ...
0
votes
0answers
10 views

VF Email template not including child records when sent from trigger

Below is my VF email template which includes all child records when I use preview functionality in salesforce, but doesn't include child records value when sending it through trigger. <messaging:...
0
votes
1answer
26 views

how to query for the participants in an event in salesforce?

Events are being created in salesforce from some external application. I need to get the participants from them in a trigger. I am looping over the newly inserted Events and then trying to query, but ...
0
votes
3answers
50 views

System.AsyncException: Maximum stack depth has been reached. while writing in test class

I've got a requirement to perform queueable apex in a trigger my class working fine, but while writing a test class for queueable apex I'm getting an exception. Could anybody can help me. Trigger ...
0
votes
0answers
17 views

Is it possible to reference custom field names of a child object in a text field to be used like a merge field on the child object?

I am trying to create a way to use templates and merge fields on custom objects just like you can use merge fields on email templates using text fields and a field updates. For example: I have 2 ...
0
votes
0answers
20 views

I have 2 lookup fields in Lead for 2 different custom objects. I want to map both of them to 2 Opportunity custom fields upon Lead conversion

Brands__c , Corporate__c are two custom object. I have two look-up fields in Lead form to set Lead's Brand and Corporate Just as Account and Contact. Now I want to move both fields to opportunity upon ...
0
votes
0answers
26 views

Test class - code coverage help [duplicate]

I need help on test class, this is my class: When creating a task of type (Phone Call or Last Face to Face) then update the account fields I have a trigger: trigger TaskTrigger on Task (after ...
0
votes
1answer
62 views

Trigger workflow rule on formula value change

I am doing some mockup exams for the certification. There is a question saying: An sObject named Application__c has a lookup relationship to another sObject named Position__c. Both Application__c ...
0
votes
1answer
23 views

not able send apex email alert

don't know why I'm getting null when I query in query editor all the values are coming! my trigger handle code public static void afterUpdate(List<Opportunity> newOpportunitiesList, Map<Id,...
0
votes
1answer
20 views

I am getting an issue in opportunity for stage where I put trigger

I got this message. " You encountered some errors when trying to save this record There's a problem saving this record. You might not have permission to edit it, or it might have been deleted or ...
0
votes
0answers
10 views

Update Opp Stage from cross-object DocuSign Status (related to opp)

I need to update my Opp Stage based on a related object DocuSign Status. When the Envelope Status = 'Completed' on the DocuSign Status object, I need my Opp Stage to update to 'SOW Received'. This ...