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
3answers
16 views

try catch with addError not showing message

I wrote this code in a trigger so addError works fine, but when code fails within a try-catch block i expected my addError message but i getting a error as i not using the try-catch. public with ...
0
votes
0answers
11 views

Error: Compile Error: Invalid type: DuplicateRecordItem

i am writing a trigger on account object on after delete event . scenario: once Account records are merged the trigger should delete corresponding Duplicate Record Set record. code: public static ...
0
votes
1answer
17 views

I am getting CPU time limit exceeded on one of the controller

I am getting an error on below class but not able to find where exactly the issue is happening. "CASLonLead : CASLonLead: System.LimitException: Apex CPU time limit exceeded" public class ...
0
votes
1answer
19 views

How to calculate the following exponential logic in the trigger? [closed]

How to calculate exponential in trigger?
0
votes
1answer
32 views

How to only update for new multi select pick list values after update trigger?

I am trying to compare multi-select picklist old value vs new values after the update. The new values should not have old values. For example, in the below case, only the "MA" value needs to be ...
-2
votes
0answers
22 views

prevent deleting files for customer community [closed]

Why are the files in lightning community are not getting prevented from delete through the below code for customer community user ?Its a before delete trigger Trigger Network nw=[select id,name,...
-2
votes
0answers
23 views

Triggers: Not able to write text in a text field with condition [closed]

public class example{ public static void method(list<Job_application__c> newlist){ for( Job_application__c temp : newlist ){ if(temp.Age__c<30 && ...
-1
votes
0answers
14 views

I need a list of trigger scenarios (no code, just ideas) to exercise [closed]

I started to learn apex and I want to do some practice on triggers, can you give me some example scenarios that I have to implement with triggers? I don't have a lot of fantasy. Thank you!
0
votes
1answer
9 views

Account/Opportunity Team Member trigger not working for default account/opportunity team creation

I'm trying to create a trigger that fires and updates the Account/Opportunity Team Members when they are created using the Default Account/Opportunity Teams. However, my trigger does not seem to fire ...
0
votes
1answer
20 views

Trying to understand correct logic for before and after trigger

I am new to apex and have wrote a trigger on the lead object that updates fields on the record, and also creates tasks associated with the record. I have set up the code for both of these ...
-1
votes
1answer
37 views

How to write test for this trigger [duplicate]

Want to write Test case and unit test for this trigger trigger Autoleadconversion on Lead (after insert, after update) { for (Lead lead : Trigger.new) { if (lead.isConverted ==...
-2
votes
0answers
10 views

How to Auto lead conersion using apex class and apex trigger [closed]

Auto lead conersion using apex class and apex trigger Is it possible without process builder
-1
votes
2answers
31 views

Triggers : After insert will have to change the data in rest of the records . But i am getting below error

public class example{ public static void method(list<Job_application__c> newlist){ for( Job_application__c temp : newlist ){ if(temp.Age__c >=40){ temp.Salary_Expected__c = temp....
1
vote
0answers
12 views

How Test LogoutEventStream

I am creating a functionality to count the number of minutes that a user is connected. For this I use the LogoutEventStream in a trigger. The problem is that I don't know how to test it. I already ...
-1
votes
1answer
20 views

Unable to create Contact Record using Lightning Record Edit form [closed]

I'm unable to create new contact records using lightning record edit form.Below is my code and error i'm getting.I'm passing all the required fields on contact. <aura:component> <...
1
vote
0answers
7 views

Dynamic Test Class for Trigger in managed package

Problem Using a managed package and Metadata API, we are deploying a trigger class that calls to a global packaged class. We are deploying also the Test Class dynamically for the object where we are ...
0
votes
2answers
32 views

How to get a list Size on a Map key without iteration

I try to write a trigger that set case status to "Closed" if thereare more than 2 cases created that same day (today) associated with the same contact. The problem is I don't want to use SOQL queries ...
1
vote
2answers
32 views

CPU Limit Exceeded because of nested for loops [duplicate]

This is a question which I really can't find an answer to. In a trigger before insert or update, I like to compare 4 field values from the object named Calculation__c with 4 field values of ...
0
votes
1answer
19 views

salesforce trigger on add values to picklist case object field

I want to build trigger when added/change values to a pick-list field in Case Object. i tried a lot of examples (Apex-Trigger, MetaDataAPI) any of them not work for me, the trigger not raise. what I ...
3
votes
1answer
41 views

NullPointerException BeforeInsert on Lead Trigger

I am pretty new to writing custom code in SF and would appreciate any help. I have a trigger on Leads to update Status to "Contacted" when a task on that Lead is "Completed". I found this in a ...
-2
votes
1answer
30 views

ERROR: 'Variable does not exist

I have a trigger bellow which calculates a sum of field in a related field in custom object . I am getting an error massage Variable does not exist:House_Improvements__c. Any ideas how can I resolve ...
0
votes
0answers
22 views

MetadataAPI : Picklist values not mapping to RecordTypes [closed]

My requirement is : Picklist values Add or Delete for Custom /Standard objects using MetadataAPI. When i can add picklist values manual, all picklist values mapping to recordTypes. But when i try to ...
0
votes
0answers
19 views

apex triggers to send email reminders for animal rescue nonprofit [closed]

i am trying to create triggers and generate reminders- and make the reminders prompt an email (google is connected with sf and syncing both ways). the former developer left some framework- so there ...
0
votes
1answer
21 views

It is possible to create trigger invoked on EVERY send email message?

i want to make a thing witch one will be working with every sent email from my org. It is possible to write a trigger to do that? The only possibility that comes to my mind is create a factory to send ...
0
votes
4answers
77 views

How to write apex class or trigger for changing the opportunity name to lead name after lead is converted [closed]

When a lead is converted to opportunity , the field opportunity name is set with account name default. But I want to change the opportunity name to lead name using apex class or trigger. How can do ...
-2
votes
1answer
26 views

trigger to stop adding duplicate values into the rich text field [closed]

I am working on a trigger which will populate the date on rich text field on Lead object from Related_Tow__c object. can anyone help me out in checking rich text field whether it contains data or not,...
1
vote
1answer
22 views

How to find a sobject used in which apex class

How to find which object is used in which apex class or trigger.Ex I want to find apex classes where account object is used.
0
votes
0answers
19 views

Trigger Not Firing When Condition is Based on Custom Event Picklist Field

I am trying to update a custom date field on the Account object when an event of a specific type is created. The Event UI includes a custom type field called Type__c, and the picklist value from this ...
-1
votes
1answer
38 views

How to throw an error using trigger, if an opportunity already having a quote and agreement, and agreement status = in Effect?

when I create a quote (using a button on opportunity object), I want to throw an error when Status Category = 'in effect' and there already exists a primary quote i.e Primary Quote Is Checked. ...
0
votes
0answers
29 views

We hit a snag before update trigger

I wanna choose pricebook for opportunity automatically. For this i created some picklist fields for both object, and a trigger that select pricebook based on this fields. The trigger work properly ...
1
vote
1answer
53 views

map collections

I am new to Apex and just starting to understand using maps to avoid loops within loops and hitting limits. My trigger below updates opp line items with the internal cost from another object using a ...
0
votes
0answers
30 views

Need to calculate hours difference between two dates

I have requirement where i need to calculate the time differnece between two datetime fields called Sent__c and Verify__c in hours with in business hours to 8am to 4.30pmGMT+2(those two dates are ...
0
votes
1answer
26 views

I need to call the trigger from the class that has a validation rule to populate one of the two custom fields

I am trying to call the class in my trigger that validates that only one of the custom fields must be populated and that custom fields cannot be empty. Below is my class and trigger, that shows of the ...
1
vote
1answer
33 views

Automating entitlement Management

I am working on an entitlement management project and the company wants to make sure that every case has an entitlement process associated to it: I looked at some of the APEX solutions as seen in ...
2
votes
1answer
68 views

Do trigger.newMap and trigger.oldMap have the same keySet() in apex after update triggers?

My potential use case by knowing the answer to this question would be, if I'm working with a legacy code and I can't make modification to the method signature and I only have access to trigger.new and ...
0
votes
1answer
32 views

Apex Trigger Creating Duplicate Records

I wrote an Apex Trigger that would create a new record on a custom object whenever the Results__c picklist is set to 3 specific values. Everything seems to functional, but it always creates 2 records ...
0
votes
1answer
24 views

trigger throwing too may soql error on EmailMessage object

I am working on one trigger on EmailMessage object. I have Application object, whenever I am receiving an incoming email,I want to update CC field to owner email of application object. I worked on ...
0
votes
0answers
30 views

Alternative of Batch calling Future method

I've looked around to try to find some posts on this and there are many but none that address my specific question (that I could find). I am trying to call a @Future method inside a for loop in my ...
0
votes
0answers
13 views

Populate Contact Custom Picklist Filed Value in Account's Custom FIeld

I've Created a custom picklist field on Contact 'Contact_Rating__c' with the values High, Medium, Low and created 2 fields on Account 'ContactHighestRating__c , ContactNameWithHighestRating__c' if ...
1
vote
1answer
20 views

Should creating an object in a process builder flow invoke before insert triggers?

I have a process builder flow, invoked when an instance of a custom object, A__c, is created. This process builder flow creates an instance of another custom object B__c. This custom object B__c has a ...
0
votes
1answer
42 views

too many queueable jobs added to the queue error - make 2nd callout upon receiving response from first callout [duplicate]

i have a triggerHandler class in which on after update i am sending list of records of Account object to queueable class public override void onAfterUpdate() { If( Limits....
0
votes
1answer
28 views

How to invoke Apex Class dynamically using Callable Interface?

Recently I was tasked with a project to dynamically call a class from a packaged trigger. This will allow clients to hook their custom logic instead of what is supplied as part of the package. I ...
0
votes
1answer
31 views

Custom settings in tests if it's trigger

I have a trigger with custom settings and test for it. And I have an example how to test it right: @IsTest void testWithSettings() { Example_Settings__c exampleSettings = Settings.getExample(); ...
1
vote
1answer
72 views

Automatically Publish Knowledge Article

I am trying to implement a requirement where few knowledge articles based on the priority(custom picklist) will be auto published immediately they are getting created. I am currently doing this with ...
2
votes
0answers
21 views

Sharing knowledge articles between multiple data categories

I am trying to solve a use case for which I need expert advice whether the solution I am thinking is good or there is any better solution available. Customer is having below data categories – ...
-2
votes
1answer
37 views

Count Tasks related to Opportunity

I have an apex trigger which displays total tasks related to opportunity, but my trigger is not working even it doesn't have any errors. Can someone help me with this trigger? //Apex Trigger trigger ...
0
votes
0answers
25 views

How to update all actual records when 1 of them is updated?

I have code. But it's a bad practice with query in the for-loop. How to make it better? The point is that I need to update comments in all actual tools when the comment field is changed in one of ...
0
votes
1answer
19 views

Develop a trigger to update “MC Commercial Setup” with Account Record Type information when a new customer is created in SF

For Account, we have some record types defined like 'small organisation', 'large organisation', 'business' etc. There are 2 millions records. Requirement: I need write Apex Trigger while creating new ...
1
vote
0answers
46 views

Dynamic class invocation in trigger - Callable Interface

Recently I was tasked with a project to dynamically call a class from a packaged trigger. This will also clients to hook into their custom logic instead of what is supplied as part of the package. I ...
-4
votes
1answer
45 views

Trigger not updating task (MISSING_ARGUMENT) [closed]

I have changed my trigger as advised above but I am getting following error: LeadClosedStatus: execution of AfterUpdate caused by: System.DmlException: Update failed. First exception on row 0;...

1
2 3 4 5
130