Questions tagged [trigger]

A trigger is a feature of the Salesforce platform consisting of Apex code that executes before or after DML operations.

1,302 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
16
votes
0answers
417 views

Using the Tooling API to create trigger, getting Error No such column 'Email' on entity 'User'

I'm using the Tooling API to dynamically create an Apex Trigger. The trigger itself consists of one line, calling a method in a Util class. Creating this trigger by hand works fine. When I try to ...
7
votes
1answer
140 views

Bulk Delete operation in trigger does not split the data in chunks of 200

As far I know, while processing bulk operations in Trigger, the data is split in chunks of 200 per batch. I have around 40K accounts in org and I wanted to delete around 1000 of them. To understand ...
6
votes
0answers
174 views

How to detect a size change for a ContentDocument or a ContentNote in a trigger?

Both ContentDocument and ContentVersion have a ContentSize field documented to be: Size of the document in bytes but after adding debug code to check that field for both types for these events: ...
5
votes
1answer
178 views

How to Activate a File Drop Automation via the API

I can create a file drop triggered automation through both SOAP and REST API's but I cannot figure out how to switch them from "Inactive" to "Active". Any help would be be greatly appreciate, thanks!
5
votes
0answers
465 views

Apex trigger takes a lot of time to access items in list

I have a simple Contact trigger in a sandbox org that is exhibiting some serious performance issues. After doing some debugging it looks like the issue boils down to accessing the items inside Trigger....
5
votes
2answers
975 views

Preventing Recursive Future Calls

I have a usecase where when an account is updated, an after update trigger is fired. This trigger will call a future method which will call a SOAP API to assign the relevant territory assignment rules....
5
votes
0answers
481 views

Execute some code after all trigger batches complete?

Suppose I update 1000 records and I have an after update trigger. That trigger will run 5 times for each batch of 200. Is there any possible way to collect data over the course of the 5 executions and ...
5
votes
0answers
1k views

Trigger addError method is not working from past 1 week on after triggers

I have created a trigger which fires only after insert, update & delete on opportunityLineItems. I am checking if custom setting values does not exists then generate error. It was working till ...
4
votes
0answers
82 views

Can a Change Event Trigger include the same record multiple times?

I'm starting to play with Change Event Triggers, building a handler framework and I'm not sure if I need to handle a scenario where the same record would be included in the same Change Event trigger ...
4
votes
1answer
121 views

Invoking trigger when an answer is marked as Best Answer in Chatter

I am trying to invoke a trigger when an answer is marked as 'Best Answer' in Chatter Question. I tried a trigger on FeedItem and FeedComment objects, but the triggers were not invoked when I mark an ...
4
votes
0answers
552 views

Triggering on Account territory changes (ObjectTerritory2Association)?

Has anyone figured out a reasonable solution to detecting in real-time when an Account's Territory or Territories (stored in ObjectTerritory2Association) has been changed? We aren't allowed to create ...
4
votes
1answer
60 views

problem using ExclusionFilter without emailaddress

I am trying to setup a filter for my triggered sends. I want to exclude all of my users who exist in a certain Data extension: "DE_1" and have the column 'Email_Hater' with value 'True'. DE_1 has two ...
4
votes
0answers
138 views

Trigger Design Question

A bit of context: Our company sells vacation rentals and has over 60 properties. When a customer chooses a property, it is stored in a look-up field called Lead.Property__c. They will also choose ...
4
votes
1answer
2k views

How to catch Validation error in Flow

I have created flow + Process Builder to do a lookup relationship Count on parent object. My issues is I have a validation rule which fires when user try to deleted last child record from the related ...
4
votes
1answer
1k views

Assigning an input value to standard/custom field dynamically

I'm working on custom workflow field update I have taken the value to update as input field and by using the map<> method I'm getting the api name of the field and storing it in a record Now I ...
4
votes
0answers
132 views

impact of critical updates 'Enable CSRF protection on GET and POST requests' & 'Require secure connections (HTTPS)'

We are in the process of activating critical updates in our production environment. 1) Require secure connections (HTTPS) 2) Enable CSRF protection on GET and POST requests Can someone explains me in ...
4
votes
1answer
553 views

What mechanisms are available for firing Update triggers on Opportunity during a “Mass Transfer” action?

In this case the "Mass Transfer" action being performed is clicking the Change Owner link on the parent Account record which subsequently bulk-reassigns the child Opportunity owners and does not ...
4
votes
1answer
647 views

How to add the Public group in Managed Package

How to add the public group in managed package and how to get the notification when delete or renamed the group name. Is there any possibilities in SFDC?
3
votes
0answers
89 views

Sporadic “Insufficient Privileges”

We sometimes receive screen shots from business users indicating they are seeing "Insufficient Privileges" errors. These errors come up in a variety of contexts, but they appear to mostly be ...
3
votes
0answers
223 views

Platform Event Trigger won't execute in subscriber org but in scratch org

In my Managed Package, I have a trigger for the Platform event Notification__e. The publish behavior is Publish Immediately. When I publish an event via Workbench or Developer console in one of the ...
3
votes
0answers
195 views

Baffling compile 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 key ...
3
votes
0answers
181 views

Force.com Architecture Whitepaper

Are there any other technical resources besides this whitepaper that describes how things work under the hood at SFDC? The Force.com Multitenant Architecture PDF version
3
votes
0answers
96 views

In a Task trigger, is there any way to know if a Task is an Email before it has been inserted?

In the "before insert" section of my Task Trigger, I want to check if a Task is an email. But from what I can tell, the only way to know is by checking the Task.TaskSubtype field, but that field is ...
3
votes
0answers
273 views

AfterInsert Trigger on ContentVersion addError not working

In Apex using a AfterInsert Trigger on ContentVersion (cv) object, the method cv.addError ('Custom message') is not working as expected. Instead of showing the custom error message the error that is ...
3
votes
1answer
294 views

Apex class invalid for community user but not standard

UPDATE: this might be a Spring 19 only issue. Will try to confirm this. If I create an opportunity with a standard Salesforce license, no problem. But if I try the same operation as a community ...
3
votes
0answers
329 views

Platform Events allow REST API JSON inputs to bypass field Required-ness?

We are finding that when feeding data to a SF Platform Event via the REST API (/services/data/v43.0/sobjects/My_Pletform_Event__e), Required field inputs can bypass endpoint validation by supplying an ...
3
votes
1answer
2k views

Trigger.new and Trigger.Old Map hold same values for a field on Opportunity

I have a trigger on Opportunity which calls a handler and Handler calls an apex class. here is the code: //Trigger trigger MasterOpportunityTrigger on Opportunity ( before insert, after insert, ...
3
votes
0answers
122 views

Case Assignment Community Portal. Insufficient access rights on cross-reference id when enabling email

I have a trigger to assign cases when they are entered in our community portal. It works great for guest users, and for regular salesforce users, but for users in the community users profile I get an ...
3
votes
1answer
489 views

Case Owner changing upon case insert (all case triggers are inactive)

I'm trying to run a unit test to see if the case owner upon insertion matches an expected value. In this case, the expected case owner will be the account owner. However, upon inserting the case, the ...
3
votes
2answers
172 views

Why is my task trigger test failing

I have a task trigger which updates two custom fields on the Account object : Last_Call_Date and Last_Meeting_Date. I have tried logging a task in sandbox and it updates the fields correctly. However,...
3
votes
0answers
2k views

OP_WITH_INVALID_USER_TYPE_EXCEPTION, Error while inserting a CaseTeamMember using Trigger

I have a trigger which inserts a "CaseTeamMember" when we add a feed comment to a Case object. The issue is that once we login as a Community User and create a case with it and then try to add a feed ...
3
votes
0answers
105 views

Failures during bulk insertion of records not executing @Future methods

I have a requirement to populate the GeoCode whenever the Account records are inserted or updated. I have written after insert, after update trigger to fire a geolocation google API it works perfectly ...
3
votes
2answers
1k views

How to avoid creation of duplicate Opportunity Contact Role for every newly created Opportunity?

I have written a after insert trigger on Opportunity to create a Opportunity Contact Role. Here is the part of code if( trigger.isAfter && trigger.isinsert){ Set<Id> accIds = new Set&...
3
votes
0answers
116 views

Filter “Last Activity Field” by Task Subject / MapAnything

I'm using MapAnything with Salesforce and would like to color code all of my Sales Representatives' accounts based on how long it has been since they have last visited the account. This would be easy ...
3
votes
0answers
471 views

ContentVersion Trigger not fired upon upload of private Chatter File

We have create an APEX Trigger with following Type: trigger TestContentVersionUpsertTrigger on ContentVersion (after insert, after update) { system.debug('Trigger for ContentVersion invoked'); ........
3
votes
0answers
673 views

Send email through Pardot with Apex trigger

I have some workflows and triggers created to send emails at certain points of a sign-up process in my companies app. It was recently requested that I send these emails in a way that can be tracked ...
3
votes
1answer
51 views

Custom Mapping Parameter File

This is kind of an odd scenario and I was wondering if anyone had seen anything like this before. We have a custom object called Financial_Account__c which stores information about our customers' ...
3
votes
1answer
173 views

Issue while firing an event using ContactEvents method in Journey builder

I am trying a simple example of firing an event using Rest API in journey builder.Followed exactly the same steps as were mentioned in the link below. https://github.com/mattcam/Salesforce-Marketing-...
3
votes
3answers
754 views

Email BCC to Salesforce Function Not Triggering Workflow Rule (Task Field Update)

I've set up a workflow rule to update the activity TYPE field based on the subject of the email. AND( BEGINS(Subject, "Email: Fwd:"), ISPICKVAL(Type, "4. Email Out"), NOT(ISBLANK(WhoId)) ...
3
votes
1answer
546 views

ExactTarget - Salesforce Integration: Adding the report or Campaign to the 'Individual Email Results' record in Salesforce

I am asking the following on behalf a client. A features in a system requires the ‘Campaign’ and ‘Report’ field to be completed on the Individual Email Result (and for that matter on the ‘Email ...
3
votes
0answers
133 views

Strange TypeException errors in Account triggers

I have a very basic trigger that once particular object is updated serializes it to JSON (all fields) and posts to external web service. (This trigger is installed on the organization via managed ...
3
votes
0answers
62 views

Anyone run into this: “DeleteRestrictedByFkException not found in section Exception”

I came across this earlier today while working on a custom VF page and I was trying to delete a record from an object. Seems its stemming from the delete trigger or delete action but the exception ...
3
votes
1answer
4k views

System.DmlException: Delete failed.SELF_REFERENCE_FROM_TRIGGER

Hi All I have written the apex trigger.It working in sandbox but not in Production.While upload the csv file by using apex data loader in production it throws an exception below. Exception: 31:04....
2
votes
0answers
38 views

approval process: mandatory comments in rejection

would it be possible to know if the comment of an approval process is empty or not? I made this code but I get penultimate comment and no current. ProcessInstance[] pi = [SELECT Id,TargetObjectid, ...
2
votes
0answers
293 views

LWC Error: appendChild is not a function / Cannot add property innerHTML, object is not extensible

I am trying to add an iframe element to a container div: <template> <div class="container" lwc:dom="manual"></div> </template> JavaScript: import { ...
2
votes
0answers
52 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
0answers
32 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 ...
2
votes
0answers
47 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? ...
2
votes
1answer
240 views

How to Capture Approval Comments in Case Object Custom field called comments ? Below code i am getting an error trigger depth exceeded?

trigger CaseApprover1 on Case (after update) { List<ProcessInstance> instances = [SELECT Id,TargetObjectId,(SELECT Id, StepStatus, Comments FROM Steps) ...
2
votes
1answer
307 views

Notification mail is being sent despite the settings to not send it

Problem: the standard Salesforce "Case transferred to you" mail is ALWAYS being sent, despite the fact that we do not want it. Description: We have set up Email-to-Case and in the EmailMessage ...

1
2 3 4 5
27