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
1
vote
2answers
53 views

What is the difference between before delete and after delete?

For Apex triggers, the before and after contexts for insert and update operations makes sense in that the records can be modified during before and not during after. In the case of delete operations, ...
0
votes
2answers
35 views

Connect an apex trigger to an authorized user's account

I'm authorizing users through oAuth (Connected app) via a PHP app. I then want to enable an Apex trigger on every user's account; in short, I want to send all contacts to my app as they're added. I ...
0
votes
1answer
26 views

How Do i Design a trigger where QuoteLineItem Products needs to be synced with the opportunity, when sync checkbox is checked

i am working on a force.com platform, My requirement is that when i click on custom button Sync__c), QuoteLineItem products needs to sync with opportunity product related list, i have referred the ...
9
votes
4answers
455 views

Should trigger handlers be static or non-static?

For a generic trigger, are there circumstances where one of the following patterns is better than the other? trigger ObjectTrigger on Object (after event) { ObjectTriggerHandler oth = new ...
0
votes
2answers
38 views

How can I get my class to pull the exact record that made the trigger run?

Trigger: trigger UpdateLastActivitySubject_trigger on Lead (before update) { List<Lead> lead = Trigger.new; for (Lead ld : lead) { if (ld.Last_Activity_Date__c != trigger.oldMap.get(ld.Id) ...
0
votes
0answers
26 views

How to mass refresh records

Is there any way to mass refresh an object with records over 1 million? Based on the values of this object, the related parent records will be updated I tried using formula field but that didnt work ...
-2
votes
0answers
30 views

Need help in passing parametere to test class from request body [closed]

Request body : { "StartDate": "2019-08-01", "EndDate": "2019-12-03" } Method : Post Need to pass these parameters in my test class not sure how i cna do this Test class : static ...
0
votes
0answers
23 views

Bulkifying a trigger or send everything in a Future method (with a callout inside)

I would like to anticipate a "mass update" of my accounts. I need to bulkify my code which contains a Callout. What happens when a mass update is done ? Like importing a list of account. Is the ...
0
votes
0answers
18 views

Trigger on List of Objects

I need an approach to get notified whenever a Objekt changes. The Objects i want to be notified is configured within a custom Setting. Conditions: No changes on the object itself. Generic approach ...
-2
votes
1answer
35 views

Want to update a lookup field in related object

We have case object and another custom object Clans__c, the custom object(Clan__c) is having a lookup field(Case_Number__c) to case. Here I am trying to update Case_Number__c with the case related to ...
0
votes
0answers
34 views

trigger not inserting records

I have two object MP_Claims__c(custom object) and Case, having lookup relationship from MP_Claims__c to Case and Case to MP_Claims__c. Trying to insert(create a case) a record after insert/create ...
-3
votes
0answers
25 views

Auto update parent account status when all child records are status is set to completed? [closed]

hello everyone i am new to salesforce And i am to trying implement a logic where status of parent object will be auto set to complete when all its child is status is completed.?here salesforce ...
-1
votes
0answers
31 views

Update field in a relationship(lookup) [closed]

i have two objects Account(Standard object)---House(Custom Object) update the price of all Houses of the same type, with The following logic: when the price of a house is changed, the price all the ...
0
votes
2answers
35 views

Benefit of actually excluding records with logic directly in Trigger vs. TriggerHandler

Is there any performance benefit of excluding records in logic directly in the trigger to avoid instantiating another class (TriggerHandler) that would essentially do the same thing? I know best ...
-3
votes
1answer
20 views

How we write trigger on campaignMember, When we added any contact A into the campaignMember [closed]

How we write a trigger on campaignMember. When we added any contact A into the campaign member. I need to add all contact into the campaign member who is associated with the account of contact A. ...
1
vote
2answers
57 views

Before/After Trigger

Question When a Billing Address is modified, get the new Postal Code. Then check which Contacts on the Account are outside that Postal Code. If 1 or more Contacts are outside of the Postal Code, mark ...
-3
votes
0answers
19 views

Insert/Update the Salesforce Records from the SQL Server [closed]

I am new Salesforce and I am trying to understand what is the best way to Insert/update the records from the SQL server DB in to Salesforce. There is a DB view, can we directly call the DB view from ...
9
votes
4answers
73 views

Run more than one async jobs from Future/Quable context

We have created a process which must work asynchronously (limits and architecture reasons) and it was working fine. Some time later we have started to work with BigObject. And as long as writing to ...
0
votes
0answers
27 views

Unit Test is Providing 0% Coverage for Apex Trigger - Test class for trigger [duplicate]

trigger Splittrigger_newclass on Indexing__c (before delete,after insert) { list<C_Voyage__c> lstvoyage=new list<C_Voyage__c>(); list<string> q = new list<string>(); ...
0
votes
1answer
47 views

Trigger fires multiple times recursively

I have a trigger with a trigger handler class on Opportunity. I am writing a batch class to update the stage in Opportunity which should call the trigger to create a record in "Order" object. In the ...
0
votes
1answer
29 views

I have written a trigger and class to first create an account and then 10 identical opportunities. It is working but only creating 1 opportunity

trigger IdenticalopportunityAccount on Account (after insert) { List<opportunity> oppt = new List<opportunity>(); for(Account acctOpp1 : Trigger.new) { if(acctOpp1....
0
votes
2answers
68 views

Disable the Apex Trigger for Perticular user login

Is it possible to disable the Apex trigger when a particular user logged in? Or Is any possibility to restrict the Apex trigger execution depends on user. Ex. My trigger should execute with User 1 and ...
0
votes
0answers
15 views

Before update trigger not updating the second Contact record [closed]

Guys my before update trigger is as follows.The parent Account has only 2 Child Contact. Whenever boolean field is checked on the first contact it should update the second contact. Set<Id> ...
0
votes
1answer
26 views

reason: Apex CPU time limit exceeded (refine the codes)

Im struggling to fix this CPU time problem, I have tried to refine my code as good as possible by implementing maps and as can be seen below; public class dailyUpdates2{ /// used for converting ...
-1
votes
0answers
16 views

Update trigger to allow the new record type [closed]

please help me. I have to Update current below trigger to allow the new case record type (compliance) with origin as Manual. suggestions pls? trigger CaseTrigger on Case (before insert, after insert, ...
0
votes
2answers
41 views

Trigger on ContentDocument/ContentVersion Firing before “After Insert”

So I've seen related questions to this about triggers not firing on ContentDocument, however my trigger is firing - just before the record is saved. I am trying to make an After Insert Trigger on ...
0
votes
2answers
51 views

Before Insert Trigger SOQL Limits

I am building a before insert trigger on hed__Program_Enrollment__c. What I am trying to do is delete everything in the hed__Program_Enrollment__c table based on a certain condition and this seems to ...
1
vote
1answer
41 views

Debugging Apex Triggers

I am attempting the Apex Superbadge trigger and have bugs in my code. In the past, I have only written Apex controllers attached to a LWC. So, when I open a page/use the LWC, I can then see my debug ...
1
vote
0answers
23 views

Bulk testing being restricted by limitation with Database.batchExecute() - How to overcome?

I was getting an occasional UNABLE_TO_LOCK_ROW error when two records were saved very close to each other. Related records were getting locked by one trigger invocation, and a second trigger ...
-2
votes
0answers
11 views

Send email and show error when duplicate record is created [closed]

I want to write a trigger, when duplicate record will create ,is should error message and send email to record which has duplicate email
0
votes
1answer
28 views

only root queries support aggregate expressions

I was working on one trigger and using sum in query but I am getting the following error when I tried to save record. only root queries support aggregate expressions Can anyone helps me out in this ...
2
votes
0answers
20 views

Surprising compilation error: “A non foreign key field cannot be referenced in a path expression: ChangeEventHeader”

Why is it that this will not compile: trigger AccountChangeTrigger on AccountChangeEvent (after insert) { String dmlType = Trigger.new[0].ChangeEventHeader.changetype; ... A non foreign ...
0
votes
0answers
12 views

How to retrive invalid phone format data from salesforce [closed]

Basically the phone format data are available in 0-9 but in my org there are lot of phone data for account object is in invalid format. I need to extract those data from org. Is there any apex code so ...
0
votes
1answer
15 views

How do I send an email based on a date difference?

For example, I have some DateTimeField__c, and if DateTimeField__c - NOW() = 11 (hours), I should send an email. Trigger is not a variant, because I can't check with it a formula field. A Scheduled ...
0
votes
1answer
29 views

Unable to send email via Apex Trigger on Non-Admin profile

My data structure: Opportunity -> SH_Quote__c -> SH_Quote_Line__c Apex trigger at SH_Quote_Line__c level public without sharing class QuotationLineItemController { //After Update Trigger Handler ...
-2
votes
3answers
54 views

how to update parent object field when we make any changes in child object field?

i have a parent object 'salesforce project' and child object 'salesforce ticket' whenever i will select the priority of child object 'high'( then it should update the description field of parent ...
0
votes
1answer
32 views

Should I use a single callout with a list or mulitple callout for each Account?

I wanted to Bulkify my code to be able to update/create a long list of account for which I need to callout to my api. I know that I can't do more than 50 callouts per future methods. But using ...
0
votes
1answer
27 views

Want to add Amount field of Opportunity on custom object field

I want to add Amount field of Opportunity on custom object field. Objects- Opportunity, Sector Target. Fields- Amount on both objects Currency(16,2). Criteria - If Opportunity Stage = Closed Won. I ...
0
votes
1answer
25 views

Update Parent based on changes in 3 different child object records

I have a parent "Contact" object which has 3 different child objects (Paid__c, Received__c, Forum__c) . Based on changes in these 3 different objects, I would like to have a multi select picklist ...
2
votes
0answers
39 views

Will trigger fire when cross object fields update?

I have written Trigger on Object 1 and I am manually updating a field on Object 2 which will automatically update one field on Object 1. So will trigger fire when the field in Object 1 is updated? ...
1
vote
1answer
31 views

How to Activate a File Drop Triggered Automation through the API

This question has been asked a few times over the years but has yet to receive an answer. I am trying to figure out how to activate a file drop triggered automation through the API(Changing it from "...
0
votes
0answers
35 views

Picklist field value being mapped does not display on original object but does display on mapped object - change code to show on both - how?

I am still learning and have created this code that triggers when: On Enrollment (custom object) When the user changes the enrollment status (picklist field) to 'graduated', it populates the ...
0
votes
1answer
26 views

Hyperlink is not showing in lightning in trigger code but working for Classic

Here I'm just written code for finding a duplicate record and displaying link through the hyperlink but it's working fine in the classic but lighting it showing directly code. Please just check images ...
0
votes
1answer
17 views

Different currencies in PricebookEntry throwing exception FIELD_INTEGRITY_EXCEPTION, PricebookEntryId (must have the same currency as the order)

I wrote a trigger which converts a Quote to Order on changing Status to a particular value. This Quote has QuoteLineItems, hence, they should converted to corresponding OrderItems. Now when the ...
0
votes
1answer
45 views

The trigger that updates another object's field after inserting new record

I am new to Scaleforce. I created a new app, added three custom objects (Client, Property, Client_Property) and created tabs for them. So now CRUD is working correctly but I want to change Available ...
0
votes
2answers
41 views

Variable doesn't exist: contactid

I am trying to refer the element(listname.contactid) from the list but I am getting error: Variable doesn't exist error However I am getting the entire list when I just use list name. I know I ...
0
votes
0answers
12 views

Set Approval/Rejection comments to field values using trigger?

I've written a trigger to check that certain fields have been filled out before a rejection is valid in my approval process. I'd like the trigger to also set the rejection comments to a concatenation ...
0
votes
2answers
27 views

How and where can i use map along with list/set collection to get unique output

When I enter united states I need only one language. If I selected wrong language it want to throw an error. Map<String,String> countryMap = new Map<String,String>(); ...
2
votes
1answer
49 views

Placing an array into a Map

I'm placing data from the order sObject into a map and would like to be able to take the data from the orderItem sObject and add it to the end of my map so it can all be sent over in a JSON format. Is ...
1
vote
1answer
26 views

How to delete the shared object record

I have written a trigger which will insert, update and delete the project when a new project team is created and removes access when the it is deleted . I have successfully written the code for insert ...