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
0answers
4 views

Is it possible to access the Lead ID on a newly created Campaign Member through the Trigger?

I'm writing a trigger on Campaign members, and I'd like to use the ID of the Lead associated with the campaign member. When I try to access the Lead Id in the trigger it returns null. Is it possible ...
0
votes
2answers
35 views

Setting record type in Apex before insert trigger isn't setting default value of a picklist for that record type

I have a Task in Salesforce with a custom record type of My Custom Record Type. This record type has a picklist field named My Custom Field and for this record type, I set the default value to My ...
0
votes
0answers
13 views

Need to update Lead executive (Lookup with User) field based on the odd or even value of Lead_number__c(auto number external Id) field

I am looking to change the Lead_Executive field on Lead object(Lookup field with User) if the Lead_number__c(auto number field) is Odd or even. if the Lead_number__c is odd, then Lead_Executive will ...
0
votes
1answer
17 views

How to solve this: Multiple IN condition in SOQL - System.QueryException: Only variable references are allowed in dynamic SOQL/SOSL

Hi am getting an following error while running dynamic soql. how to over come this when we use multiple IN condtion in soql query dynamically code: String docid = 'hi asma US6775512356'; ...
0
votes
1answer
24 views

I am getting lots of email from salesforce- Saying exite governer limt?

Can you please help me with what I am doing wrong here? Please help me? public with sharing class ReservePaymentHandler { //Variables public static List<coverBenefitWrapper> ...
0
votes
0answers
12 views

Measuring Monthly Targets in Salesforce

I need to measure my Sales team's monthly target. I have setup a custom Object Monthly_Target_Details. I have target date and User (Lookup)field and Opportunity (Lookup)field. My requirement is to ...
1
vote
1answer
30 views

Force auto response rule to send email after case update

i'm looking for a solution and wondering if it's possible to send an email from auto response rule after a case update. triggerAutoResponseEmail in a trigger after update is set to true but i receive ...
0
votes
1answer
22 views

Isolate multiple IF statements?

I'm running into some difficulty in getting a case milestone to update correctly. The context is that my Org had three departments, and three separate entitlement processes (which all completed on ...
0
votes
1answer
34 views

How to bulkify trigger when I have to query using a field in Trigger.new?

I am writing a trigger for a custom object (Subscription__c), where I need to find other records of the same object that share a lookup to Contact (field name: Subscriber__c), and copy some ...
0
votes
1answer
16 views

Button “Disable Customer Account” on Account does not fire trigger on User record

I try to set up a trigger that modifies the email adress on the User object once I hit the button "Disable Customer Account" on Account. I have seen the discussions where you should use "...
-1
votes
0answers
31 views

How to check field's value exists on sobject using Apex?

I have a contact Object and salary object(Lookup relationship to contact) in salesforce, upon updating the contact in the background I'd like to check if the contact's associated salary object record ...
1
vote
1answer
23 views

Test Class for Trigger After Delete with Update Opportunity

I'm writing a very simple trigger. At this point I have 100% coverage, but I don't feel like the tests are robust enough. High Level Opportunity Contact Role Trigger that fires on Delete. The ...
1
vote
3answers
108 views

At least one contact should have checbox checked Apex trigger

i have the below scenario. One account is having many contacts. contact_status__c is a checkbox field on contact. i am trying to write a trigger which will check at least 1 contact should have this ...
0
votes
1answer
53 views

Bulkify a Trigger

I have written a trigger on Tenant_Details__c object which has a lookup relationship to Room_Details__c object. Every time a new record is inserted, I want to update a field in Room_Details__c and ...
-2
votes
1answer
57 views

Why is my code coverage 0% in the Sandbox

To stop automatic transfer of open activity Ownership related to account/case I have created a trigger on task and cases which calls an apex class. Apex class: Task Public class taskTrigger{ ...
0
votes
1answer
12 views

Do setResumeCheckpoint commits revert after RetryableException?

I'm trying to build a high-volume integration through platform events, and I'd like to know how setResumeCheckpoint behaves when a RetryableException is thrown after the checkpoint. According to the ...
3
votes
1answer
59 views

Queueable apex and trigger execution context

If I enqueue an instance of a Queueable class during a before trigger, is it guaranteed that the Queueable class will not run until the after trigger completes?
0
votes
1answer
20 views

Publish Event Messages generic solution

I am looking for a generic solution that would allow instead of creating triggers for each platform event to create one and in some way forward to it. If this even possible and what pattern should I ...
0
votes
2answers
23 views

maximum trigger depth exceeded while updating old child records

I tried to check previous answers here for similar issue but I could not apply it in my condition We have a scenario where Account is master and Annual Potential is a child object, THe scenario is ...
1
vote
1answer
23 views

Moving code to trigger for Lightning and And Visualforce

I have a vf page that accepts few url query parameters. When a submit button is clicked, the apex controller takes the parameter and depending upon the parameter values different sorts of SOQL and DML ...
0
votes
1answer
28 views

Changing Chatter Post Parent from Community

Problem Statement I need to change the Parent of the Chatter Post (FeedItem) when a specific community user posts a question or poll type post to a Collaboration Group. What have I done so far I ...
0
votes
2answers
37 views

Update checkbox when related object is deleted

I have a small problem because I need to write a trigger which will update checkbox when the related object will be deleted. Between those object is lookup relation. So only what I need is when ...
2
votes
0answers
26 views

Unit test false positives because of future callout triggers

Background I have the following Apex class method which is called as a result of a trigger on a custom object, MySet: @future (callout=true) public static void exportMySet(string setId) { // do ...
1
vote
1answer
22 views

Is there a design pattern to follow to avoid updating same record more than once in different methods?

Pseudo code to describe the problem I am facing. ContractTrigger.trigger: trigger ContractTrigger on Contract (after update) { ContractTriggerHelper helperObj = new ContractTriggerHelper(); ...
0
votes
1answer
31 views

Trigger running DML regardless of if null or populated

I wrote a trigger to update the lead associated to new campaign members with values from the associated campaign. The leads should only be updated from the campaign if the fields are blank on the lead....
0
votes
0answers
35 views

Trigger after update create a Duplication records

I have two custom Objects Projects and weeks so i have created a trigger on Projects that populated weeks based on start date and end date, but when i updated start date or end date it create a ...
-2
votes
0answers
25 views

Is it possible to fetch all failed records data and run it again in Batch Apex?

I want to collect the failed records data from Batch Apex. I also want to process the failed records once again. Is it possible or what is the best way to do this operation? Thanks in Advance.
1
vote
0answers
19 views

Attachment as PDF is blank

I'm trying to save an attachment as PDF inside a record. The process happens after insert trigger - when I send the data to a function to generate a pdf as an attachment and saving it in the record. ...
-1
votes
0answers
28 views

Write a trigger that will create a report for any specific object [closed]

Requirement - Write a trigger that will create a report for any specific object It should remove all duplicate rows from each record and only keep the latest ones. Can anyone share the code? Code for ...
-1
votes
1answer
37 views

the field not updated [duplicate]

trigger LeadStatusCheck on Lead ( before update) { List<String> leadEmails = new List<String>(); for(Lead lead:Trigger.new){ leadEmails.add(lead.Email); } List&...
0
votes
1answer
25 views

This error occurred when the flow tried to update records: CIRCULAR_DEPENDENCY: This case is parented by a case that is also its child [closed]

I am getting the error while updating the case parent ID with the same case ID. Thank you
-2
votes
1answer
52 views

find the solution of this trigger [closed]

When a Lead status is updated at Lead record , check if contact exists with same email address of lead and update 'Lead Status' picklist of contact with same value. trigger LeadStatusCheck on Lead ( ...
1
vote
2answers
35 views

Apex Trigger Order of Execution Transaction

I am a bit confused lately regarding the order of execution of multiple updates: Consider the following scenario: I have Three Records: A and B and C A fires an after update trigger that updates ...
0
votes
2answers
24 views

Want to write trigger on object to update the picklist field

Class : MonsterPositionClass Field : Experience__c Field : Position__c (picklist )> ( values:'Jr Engineer', 'Team Lead') Condition : if(Experience__c >= 7 ) then Team Lead should be shown my ...
-3
votes
0answers
27 views

Can we create Report with the help of apex trigger? [closed]

Can we create Report with the help of apex trigger?
0
votes
1answer
20 views

How to make the File upload mandatory once the stage is changed to Closed Won on the Opportunity

I need to create a trigger on Opportunity, such that when stage changes to Closed as Won, it throws an error saying you need to upload the attachment before moving it to Closed as Won. I have below ...
0
votes
1answer
24 views

why user not send email from site in salesforce?

In salesforce when i send email from visualforce page email sent but on site email not sending. List<String> toAddresses = new List<String>(); toaddresses.add('sumit@...
0
votes
1answer
37 views

DML in @Future called from Trigger in Batch

I have a after insert trigger on an object that calls a @future method to do a callout to an external system. If the callout fails I want it to update the original object. I am batching up 100 at a ...
0
votes
2answers
81 views

Trigger for creating Opportunities from custom object

I am creating some automation for a custom object "Handover". When the custom stage field is set to "Accepted", a new Opportunity should automatically be created and the Opportunity lookup field on ...
-2
votes
1answer
41 views

Error through program ple rectify this one [closed]

trigger ContactCreate on Account (after insert) { List<Contact> conList2 = new List<Contact>(); Map<Id,Decimal> MapAcc = new Map<Id, Decimal>(); for(Account acc : ...
0
votes
0answers
68 views

Update checkbox on the father object depending on the child values - with a trigger

I need to update the 'Is Cloud Customer' check box in the account object when at least one of the Child's as the Installation type field containing the word 'Cloud'. If none of the Child as 'Cloud' ...
0
votes
1answer
29 views

Trigger is updating values regardless of whether null or not

I wrote a trigger to update the lead associated to new campaign members with values from the associated campaign. The leads should only be updated from the campaign if the fields are blank on the ...
-1
votes
1answer
30 views

Trigger to insert the name of an employee who badge in after 9am into a custom object late_report__c from work_clocked__c is not working

I am new to Salesforce. I have created two custom objects work_clocked__c and late_report__c. If an employee badge in after 9am in work_clocked__c, the employee name must be inserted into ...
0
votes
0answers
26 views

Convert lead trigger

I am running into cpu limit with this am I am missing somthing? And also how can I adjust the code to avoid harcoding the ID like i did. Trigger AutoConverter on Lead (after insert,after update)...
1
vote
1answer
41 views

Archived content documents not found in SOQL

This soql is not retrieving any records, any issue in soql ? SELECT Id, Title, FileType, ContentSize FROM ContentDocument ALLROWS WHERE isArchived = true
1
vote
0answers
27 views

How does flow accept input parameters from batch class

I have an apex trigger and a batch class. I am running apex trigger on contact, sending it to batch class and from batch class sending the parameters to flow. Trigger: trigger BulkContactsLoad on ...
0
votes
1answer
26 views

Trigger Recursion after API Callout to Run Territory Assignment Rules

I am trying to trigger territory assignment rules on accounts via the API (the only way you can, apparently), and then change the account owner based on the territories that are assigned. It’s an ...
0
votes
2answers
39 views

How can I take my SOQL out of the loop?

I have an Id in the String format. I'm trying to convert this string into lookup field if it's the Gear__c Id. How can I take my SOQL out of the loop? trigger SMSTrigger on Message__c (before insert) ...
0
votes
1answer
42 views

How to make two callouts in sync?

From Trigger on inserting I am making a callout (from method1 of class A) i.e by using @future annotation and updating the field of the same object on which the trigger called, with the values ...
0
votes
1answer
93 views

Trigger resulting in System.LimitException: Apex CPU time limit exceeded

I have a trigger that runs on AccountDomains to update a Contact's Account when a new Domain is added to the Account and it's hitting the Apex CPU time limit. Right now it pulls all the contacts with ...

1 2 3 4 5 128