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.

-1
votes
0answers
13 views

Lead Reassaignment. Can we do this with one trigger and class Combination [on hold]

acitve --> No Chnage inactive - > user --> manager is active --> assigned to manager inactive --> user --> manager is empty --> assigned to unassigned inactive --> user --> manager is ...
0
votes
4answers
32 views

Why does my trigger not update the record?

I have a trigger shown below that is supposed to count the related activities on a custom object and update a field on the record. trigger Call_Report_AfterUpdate on Call_Report__c (after update) { ...
1
vote
0answers
23 views

How do I roll up an Account Hierarchy and keep all children in sync?

Problem My org has many extremely complicated account hierarchies because of our client type. I have an ask: to stamp all accounts with sum of all of the accounts sales volumes in the hierarchy on ...
-3
votes
0answers
28 views

Apex Trigger. Can anybody help me to decide this? [on hold]

When creating a record of the Product object, the trigger should check whether the AddedDate field is filled in, if not filled, assign it the current date and the current time. Need to use apex ...
0
votes
0answers
30 views

INVALID_CROSS_REFERENCE_KEY when trying to delete OppotunityLineItemSchedule

I'm stuck on this error and can't figure out where is the problem: I have a trigger on Opportunity object which would look at another Opportunities OpportunityLineItems and see if the ...
0
votes
0answers
21 views

Libraries and packages all Salesforce implementation should have [on hold]

I'm starting a new project and I would like to ask what are the libraries and packages that you always/often use in each new project/Salesforce implementation. Please also add GitHub, explanation and ...
0
votes
2answers
40 views

Apex trigger to stop duplicate records into SF if email already exists on a person account

I have an existing trigger which converts leads into peron accounts if the company name is blank. Trigger AutoConvert on Lead (after insert) { LeadStatus convertStatus = [ select ...
0
votes
1answer
17 views

Roll up summary Trigger performing total sum in account

I am not able to perform insertion,updation,deletion on account Apex class: public static void parentUpdate(list<Contact> records){ set<ID> ids = new set<ID>(); for(Contact ...
1
vote
1answer
24 views

How to use Schema class in Trigger to update a related child object feild?

Requirement : create a field called 'ExternalRef' on all child objects of Opportunity Object write a trigger on Opportunity that updates the new field on all child objects of opportunity to 'Rajsheakr'...
-1
votes
3answers
59 views

Compare Trigger vs. Workflow Rule vs. Process Builder [on hold]

Give an example of why you would use a trigger over a workflow or process builder to accomplish an update to a field?
1
vote
2answers
56 views

Flow Error - Apex CPU Time Limit Exceeded

I have a flow that is supposed to update multiple Account records and then triggers a process builder to update their related Opportunities. This happens at the start of the new fiscal year to set up ...
-3
votes
0answers
27 views

Need help to bulkify the trigger. Fails to delete over 600 contacts [duplicate]

public class AccountContactHandler2 { //trigger AccountContacttrigger2 //---------------After insert ----------------- public static void createContact(List<Account> acc ){ ...
-2
votes
1answer
22 views

Apex Trigger to Update Contact Detail field field Based on account information field

I am trying to create a trigger for update in Contact field(custom field name is Type). when I will update in Account information Section(Field name is Type for Ex. Prospect -> Customer-Direct.).
0
votes
0answers
23 views

Trigger Email send to an internal Mailbox with fields the Customer filled out in the Clouldpage

we want to send an trigger email, which should be routed to an internal emailbox after the customer filled out a Cloudpage. the values of the fields the customer has filled out should be displayed in ...
-3
votes
1answer
56 views

Trigger ---I want to delete the contacts in bulkify , but it fails to delete contacts over 600 , error: cpu time timit exceeds

public class AccountContactHandler2 { //trigger AccountContacttrigger2 //---------------After insert ----------------- public static void createContact(List<Account> acc ){ ...
0
votes
2answers
39 views

Apex Trigger and open VF page

I am executing apex trigger on Lead object, in that I have added (adderror()) error message for one condition, its working perfect. But after showing error message I wanted to open a VF page and come ...
-1
votes
0answers
20 views

Trigger to delete the contact from the lastly inserted one. Delete part not working [duplicate]

public class AccountContactHandler { //trigger AccountContacttrigger public static void createContact(List<Account> acc, map<id,Account> oldac ){ list<contact> newcon=...
0
votes
1answer
32 views

ignore empty values (or null) while passing JSON request to third party

I am passing request in JSON format to third party system but they want only to pass field which is not null else skip that field. I am trying to build logic to skip Null/Blank. Can someone please ...
0
votes
1answer
25 views

[apex]: Database.rollback(sp) not rolling back in my trigger

I am playing around with Database.setSavePoint() in a trigger. I put it at the top of my BeforeUpdate method and then I roll back at the end of the method. Then I try to modify an Opportunity record ...
-2
votes
0answers
12 views

How to create non_approved objects if lead is duplicate

trigger compareMultipleFieldLead on Lead (before insert) { List<Non_Approved_Leads__c> nonAplFinal = new List<Non_Approved_Leads__c>(); List<Lead> errorLeadList = new List<Lead>...
0
votes
1answer
32 views

Trigger to make autonumber field on account with format 'ACC-001'

I need to create a trigger that will autopopulate the field created in Account object. The field value will be auto populated using the value like 'ACC-001','ACC-002' everytime an account is created. ...
0
votes
1answer
43 views

Auto-populate fields w/o Triggers [on hold]

Is there any way to autofill custom fields without using a trigger while still using Apex code? I have fields that are aimed to be filled in based on more complex logic and accessing information of ...
1
vote
1answer
15 views

Can the below code be Optimized and include the logic to check for related opportunityteammember records before updating checkbox to true?

Need help in Optimizing below code. Requirement is to update "opportunity shared" checkbox on "Opportunity" object whenever opportunity is un-shared. (Delete trigger on "Opportunityteammember" ...
-2
votes
1answer
26 views

whenever i change account active field related case status field should be changed to working..please help me out with this

trigger AccRecCase on Account (after update) { map<id,account> oldMap=Trigger.oldMap; //old records ids map<id,account> newMap=trigger.newMap; //new record ids List<Id> ids=...
0
votes
1answer
24 views

Why it is not updating the YourMail__c after Recursion Handling?

Class: public class Hr { public static Boolean f_t = true; } Trigger: trigger HandleTrigger on Input__c (before insert) { if(Trigger.isInsert){ if(Hr.f_t){ Input__c acc = new ...
0
votes
2answers
37 views

Apex after insert trigger - variable does not exist

I am calling another class from my trigger and it works in sandbox, but when I try to validate my deployment (I am using a change set to deploy) in prod, it says "variable does not exist: ...
-2
votes
1answer
38 views

How to write test class for Database.error [duplicate]

for (Database.SaveResult result : results) { if (!result.isSuccess()) { for (Database.Error error : result.getErrors()) { System.debug('Error returned: ' + ...
-4
votes
1answer
50 views

Test class for below class [closed]

public class ExampleClass { public static void publishCaseUpdateNotifications(List<Case> cases) { List<Case_Updated__e> notifications = new List<Case_Updated__e>(); for ...
0
votes
1answer
37 views

How to achieve code coverage for trigger after lead conversion

I have a trigger on lead and wrote a unittest but are not getting any codecoverage. What amI missing. Trigger trigger LeadTrigger on Lead (before insert, before update, before delete, after insert, ...
0
votes
2answers
42 views

Account Apex Trigger Help

I'm trying to prevent the deletion of accounts if one of the contacts within the account has a "Do Not Delete" checkbox as true. Here's a trigger (My very first one!) Please let me know if this is ...
0
votes
1answer
53 views

Apex trigger helper class - deployment error “variable does not exist”

I'm trying to deploy an apex trigger from sandbox to production. But when I test/validate in production I'm getting the error "variable does not exist" for the trigger's helper class: Trigger '...
0
votes
0answers
33 views

How to Prevent Account Deletion based on Contact Field? [closed]

So I've created a trigger to prevent contact deletion if a checkbox is true. trigger PreventConDelete on Contact (before delete) { for(contact con : trigger.old){ if(con.Do_Not_Delete__c != null)...
0
votes
2answers
32 views

How to display validation error in same page using trigger on click of delete button?

How to display validation error in same page without redirecting to new page using trigger on click of delete button?
0
votes
1answer
39 views

SObject row was retrieved via SOQL without querying the requested field: s2cor__Sage_INV_Trade_Document_Type__c. s2cor__Use_Company_Shipping__c

I have a C# application that was meant to upload invoices to salesforce financials. All other functions of the application works fine except the uploading module. During the upload process, I have to ...
0
votes
1answer
21 views

validation rule for sum of percentage field should not be more than 100%

HI I am looking validation rule and am not sure whether can be done with validation rule. I have a task where I will mention an account executive and assign quota and revenue % for that account ...
0
votes
0answers
19 views

Method does not exist or incorrect signature: void setToaddress(List<String>) from the type Messaging.SingleEmailMessage [duplicate]

trigger mailsentcreateaccusindtri on Account (after insert) { //list<string> mail= new list<string>(); if(trigger.isafter && trigger.isinsert) { list<...
0
votes
1answer
25 views

Apex Trigger Based On Related Links Changes

I want to sum the number of Opportunities Related Links using a field trigger (I know I can do a roll up summary, but i cant use it as it is unclickable for the object I am using); I was wondering how ...
0
votes
1answer
23 views

Field information not updating?

I want to update a custom field using Apex triggers. However, after "updating" it doesn't seem like it actually changes the value of the fields. Here is my code (in Apex Execute): for(Contact c:[...
0
votes
0answers
11 views

put value in parent related list can uh explain me how can create trigger? [duplicate]

trigger ProductDetail on Design_Selected_Junction__c (After insert) { if(Trigger.isInsert){ Set<Id> designTemplateSet = new Set<Id>(); Set<Id> oppSet = new Set<...
0
votes
0answers
31 views

How to disable the trigger in production with the custom label

I have one trigger onAccount which is not allowing me to insert update new Accounts to other objects so I would like to know how could I disable the trigger/class in the production without moving in ...
0
votes
0answers
15 views

Is there a way to send email alert when Omni-channel is set to offline automatically or by user in salesforce?

We have a requirement where we have to send email alert to current user when his/her omni-channel is set to offline. I don't see an option to achieve this using Process Builder. But would like to know ...
0
votes
0answers
21 views

Calculating the Min of Date from the related list

I am having one big task and from the last 2 weeks I am working on to solve it but without any result. Please help me out to solve this puzzle. So we are having one object Entity group, which is the ...
0
votes
1answer
19 views

type=meeting for all events

I have a requirement where I want to put type=='meeting' for all the events type has a picklist data type where meeting is a value Here is the trigger I have written but it is not working. trigger ...
1
vote
0answers
21 views

Selecting the Opportunity Price Book

I'm still fairly new to Salesforce Apex and trying to figure out how to select a price book from the opportunity. The reason being I have a trigger which adds in a product when the opportunity is ...
-1
votes
1answer
31 views

Trigger; Initial expression is of incorrect type, expected: String but was: List<String>

//trigger code trigger mailsentcreateaccusindtri on Account (after insert) { //list<string> mail= new list<string>(); if(trigger.isafter && trigger.isinsert) { ...
0
votes
2answers
24 views

How to remove an option from mutli-picklist field in apex trigger

I want to write an apex trigger action to remove a particular value from multi select picklist field based on some condition.How can I do this? This is my trigger action: public static void ...
0
votes
1answer
16 views

Need to call different method from same class on Trigger context

I have written one class and inside that there is method which calling one small method ,what i need is to call inside method based on Insert and update If Operation is INSERT then call one method if ...
0
votes
1answer
17 views

Populate contact field based on email

We're doing a demo of Survey Monkey and can't seem to get the contact populated from the form mapping. My solve for this would be to make a trigger that looks at the required email field and finds a ...
2
votes
1answer
22 views

Standard User profile gives error for delete task trigger testclass

I have trigger to stop users to delete task except if profile is "System Administrator". Trigger : trigger TaskTrigger on Task (before delete) { if(Trigger.isBefore && Trigger.isDelete){...
0
votes
2answers
25 views

When an approver is dynamically chosen on the base of a related field is possible to reassign the approval step through apex?

Suppose to have an approval process where the approver of a step is a related user designated through a custom field. If the value of the custom field is changed, all the records in this approval step ...