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
1answer
9 views

New Email-To-Case forwarding rules due to winter update?

I created an email-to-case routing address. It generated an email service address as seen below: company@2pi5gutw5ily4pqew3jiu5s5tnopsjngn3pzxv64x6py.4x-3wk2ieaq.na150.case.salesforce.com Do we need ...
0
votes
2answers
19 views

Can we redirect a user into a VF page from an Apex trigger

I have a scenario where a user if he/she uploads a file against a particular record, then the user will be redirected to a VF page after the file upload is successful. I wrote a simple trigger in ...
0
votes
1answer
13 views

How to update associated planned date based upon the opportunity close date changed?

I have implemented a delivery delay for some of the opportunity line Item based upon the product family and opportunity close date. But now the business wants if a user changes the close date from 8-...
0
votes
1answer
28 views

Unable to parse xml data with address in Account object with address field

My requirement I have XML data with a set address I need to insert all XML address data into the Account object with the Address field respectively. any solution to this. My updated code: If I insert ...
1
vote
1answer
20 views

Update Case field from Service Contract related list

I'm asking for your help today because I don't know how to proceed. If you could give me advice or suggestions, I would really appreciate it! I would like to know how to update Case fields (Company ...
0
votes
1answer
44 views

Updating all Opportunities related to trigger records

In a trigger for Cases, I need to know how many opportunities relate to each of those cases, through a lookup in the Case, that is Case.Oportunidade__c . This is the code: // this at the start of ...
0
votes
1answer
22 views

Apex trigger not inserting records into custom object even though it is executing and record ID is generated

The problem I am facing is that the DML operation is being executed and a record Id is generated for the newly inserted record but when I try to query the record or access it in Salesforce, it does ...
0
votes
2answers
15 views

Count number of related Cases To a Contact

I have created a trigger to count the number of Cases related to a Contact. But my field does not update. Could someone help me figure out what I am doing wrong? Thanks trigger ...
0
votes
1answer
24 views

Method does not exist or incorrect signature: void get(Decimal)

public void caclculate_best_price(List<Goal_Items__c> goal_items){ Map<Id, Map<Id, Map<Decimal, Decimal>>> Savings_Goals_to_Products_to_Sizes_to_Prices = ...
-2
votes
0answers
20 views

How to add 30 mins to ActivityDateTime? [closed]

Actually I'm receiving call details from external interface after receiving the Call details I need to add 30 mins to the ActivityDateTime field so that it would results EndDateTime. Because we are ...
2
votes
1answer
41 views

If a trigger handler calls a static method, what happens when another of the same type of trigger fires before that method finishes execution?

All the samples I've seen of Apex trigger handlers have them calling static methods in a helper/service class. What happens when a second trigger of the same type (say after insert) on the same object ...
0
votes
0answers
10 views

Assign new Article Id to lookup field anytime a new version of KnowledgeArticleId is published

I have an aura component in community allowing a client to subscribe to an article(Knowledge__kav). When subscribing to the article, a record is created in Salesforce displaying the Article version ...
0
votes
0answers
26 views

Help Class for Trigger [duplicate]

Can someone help me how to write test class for the below trigger. trigger AccountOwnerUpdate on Account (before insert, before update) { Set<Id> accIds = new Set<Id>(); List<...
0
votes
1answer
13 views

Trigger to post the Task Comments to Chatter

I am very new to the Triggers and have very less experience with them. I want to write a trigger which will copy the comments from the Tasks section and post it onto the Chatter of that same account. ...
0
votes
2answers
42 views

Trigger on Account Owner Change

I have a requirement When an account is created or edited, the value entered in coverage lead field (which is a lookup to user) should copy over to account owner field and also to the owner field of ...
0
votes
0answers
26 views

Email alert when a user leaves the organisation [closed]

How to notify and what are the criteria needs to meet when a user in an organization leaves and how do we send an email notification to an system admin?
0
votes
1answer
18 views

Specific Profile Access to Create or Edit in Account Related Contacts in Validation Rule or Triggers

Iam trying to create a validation rule for specific profile access to create or edit in account related contacts in validation rule my code in validation rule at account object AND( NOT( $Profile....
0
votes
0answers
11 views

Record feed doesn't update on Event creation via trigger

I'm trying to get the record feed of my leads to update when I create an event with an after update trigger, it's not working. When I create the event manually the feed gets updated, but not when it's ...
0
votes
1answer
20 views

trigger to autofill the child field date with the parent field date

I wrote a trigger so that when i enter a date in parent field it should automatically reflect in child field. here is a code i wrote but somehow the date is not reflected in the child field. trigger ...
0
votes
1answer
19 views

knowledge__kav: System.NullPointerException: Attempt to de-reference a null object

I am unable to fix the error System.NullPointerException: Attempt to de-reference a null object on my trigger. Could someone help? Thanks trigger Knowledge_kavKnownErrorSubscription on Knowledge__kav (...
1
vote
1answer
30 views

Is it possible to detect which external Id was used inside the trigger?

Is there a way to identify inside a trigger (eg. before insert) which field is being used as external Id? The problem I have is that there is an external system upserting some records on an object (...
0
votes
0answers
6 views

account based entitlement automatically added to cases

community. I have an issue with automatically adding entitlements to cases created manually, from form to case in community and from web/chat. I found a solution here, but I'm not sure it actually ...
0
votes
1answer
78 views

Trigger confusion

trigger to block more than 2 contacts per account. This trigger is working fine on after insert. But I have confusion that it should be on before insert as we want this trigger to work before ...
0
votes
1answer
24 views

How to rollback Status on an object like Lead if the API response was not successfully?

I have made the integration process between salesforce and our external system. the idea is that all Lead Status Changes in Salesforce must be recorded in our External system. For sending data when ...
0
votes
0answers
29 views

How to decrease the size of a list in an apex trigger?

I am writing an Apex trigger in Salesforce to count the Open Jobs under one account. Since it is in lookup relationship with account, no rollup summary is possible. I'm a begginer :) It seems that ...
0
votes
1answer
32 views

how to show two error message for multiple duplicates record in apex trigger

My requirement In contact object I have two fields Apple__c and orange__c, if I create contact with the duplicate values of existing values in Apple__c and orange__c fields need to throw an error for ...
0
votes
0answers
6 views

Display Custom lookup for Survey Invitations Button?

I am looking for a way to connect a contact record with a survey and survey responses. For our business, the case owner sends a survey to a member of our services. The survey is providing feedback on ...
0
votes
1answer
24 views

How to get original submitter id regardless of step in Approval process?

I have an Approval Process, myApprovalProcess, that has multiple steps (total of 4) where different users are needed for approving a record. At each step, a different user will need to approve/reject ...
0
votes
0answers
18 views

Update n Delete ServiceAppointment obj field,ie,Service_Resource__c seperated by comma [closed]

ServiceAppointment(Parent) and AssignedResource(child) have Parent-child relationship And AssignedResource have lookup on Service Resource object So, Wheneever Assigned Resource record is created. ...
0
votes
0answers
15 views

Lead Owner Assignment Trigger Logic works for manually created leads but not for Web2Leads

I have written a trigger to assign a new lead to the owner based on certain logic. When I manually create the lead, the logic works perfectly i.e assigns the lead correctly. However, we are not going ...
0
votes
0answers
31 views

Apex tigger to count child object (lookup relationship) with a given criteria [duplicate]

I am writing a trigger to count the Open Jobs under one account. I'm a begginer :) It seems that when the stage of an Open job changes, the number of closed jobs is increased, but the number of open ...
0
votes
1answer
32 views

Only run trigger on first call pattern: Best practices

Our previous Salesforce developer used the below 'first-call pattern' in every Apex trigger. trigger ContactTgr on Contact (before insert) { public Static Boolean firstcall = True; //Test to ...
0
votes
1answer
26 views

OpportunityLineItems: execution of BeforeInsert caused by: System.NullPointerException: Attempt to de-reference a null object [closed]

I would like to set up a line item type base on the product name and length term. but i keep getting the error "OpportunityLineItems: execution of BeforeInsert caused by: System....
0
votes
1answer
21 views

Trigger.old is returning the new value

I'm doing some tests for triggers and I'm seeing that Trigger.Old is returning the new values of the updated object , instead of the old values. I'm assigning the values to a List, so I can then ...
0
votes
1answer
62 views

Governor Limit Hit ( Issue with code inside the for loop)

I created a trigger to call a apex code (Before insert, Before update). The process is basically initiated when a referral record is created, i used some fields from referrals to do a look up for a ID ...
0
votes
1answer
26 views

Trying to create a trigger that will for the query the name from another object then get its ID

I'm trying to create a trigger that will search in Object RecognitionPeriod using its name(FROM OpportunityLineItemSchedule) then get the ID(of RecognitionPeriod). trigger OppLineItemScheduleTrigger ...
0
votes
1answer
55 views

Sorting records in a before trigger

I have a one to many relationship between Project and Insurance. When a record is created on Insurance object, it needs to get the Project record and then count how many Insurance records are present ...
1
vote
1answer
43 views

How to Determine Whether a Field Can Be Updated in Trigger Context

My question is basically the same as question 289297, if I correctly understand its OP's intent. I am posting my own in the hope of giving the issue more visibility, and also because it is not an ...
0
votes
2answers
46 views

Using future method in triggers [closed]

Trigger batch size can be 200. If i call future method(callout=true) on every batch object, this will throw limits error or not? If it throw, how can i avoid this?
0
votes
1answer
15 views

CPU Timeout Error

I have a one to many relationship between Project and Insurance. When a record is created on Insurance object, it needs to get the Project record and then count how many Insurance records are present ...
1
vote
1answer
39 views

Unable to correctly configure a specific User as an Apex Platform Event subscriber

I'm following this Configure the User and Batch Size for Your Platform Event Trigger documentation taking this Tooling API REST option. The resulting PlatformEventSubscriberConfig record can be ...
-2
votes
0answers
24 views

How to write a test class for the below code! [duplicate]

trigger fieldupdate on Account (After Update) { if(Trigger.isAfter && Trigger.isUpdate) { Set<Id> AccountId_Set = new Set<Id>(); new list<contact>()...
0
votes
1answer
11 views

How to control Default case owner assignment if no conditions of assignment rules are fulfilled?

I have a scenario where the case owner is updated using the trigger based on some conditions and then the assignment rule is run. Based on the conditions in the assignment rule, the owner is ...
0
votes
0answers
19 views

To clone Chatter post (with comments)

I have a use case where, whatever chatter is posted on Quote__c object, the chatter and its comments also to be cloned to Lead__c. trigger chatterClone on FeedItem (after insert) { for(FeedItem fi : ...
-1
votes
1answer
15 views

To check if there is any opportunity present in account. If yes do nothing, else we have to create at least one opportunity under that account

trigger atleastoneopp on Account (before update) { List<Opportunity> oppList = new List<Opportunity>(); Map<id, Account> m = new Map<id, Account>(); // Select query before for ...
0
votes
0answers
13 views

Automate Mail Merge Process

Is there a way to set a trigger to generate a mail merge once a field has been checked? I want to generate a donor thank you letter (mail merge document already created and successfully tested) ...
0
votes
1answer
33 views

Apex Class & Trigger Issue

I am stuck on three errors that I cannot seem to diagnose in an Apex class and trigger combination. The class is below: public class DelegatedUserSetup { void setObjectives(User[] users) { ...
0
votes
1answer
62 views

Copy Task but Change Owner trigger

When a new user is created in Salesforce and matches a custom field named Role__c, I am trying to take a list of objectives__c and apply them to the user. I want to copy everything from the ...
0
votes
0answers
13 views

System.LimitException: Too Many SOQL Queries: 101 in Campaign memeberTrigger [duplicate]

I am getting error message "System.LimitException: Too many SOQL queries: 101" and I believe it to be error with this trigger. I am new to coding and this was done previously so any ...
0
votes
1answer
16 views

Apex Trigger insert Tasks to User on Profile Assignment - Error

I am trying to assign tasks to a user based on their profile once the recorded is inserted into Salesforce. The trigger is hitting an exception even though it's compiling correctly. The code is below:...

1
2 3 4 5
142