Questions tagged [trigger]
A trigger is a feature of the Salesforce platform consisting of Apex code that executes before or after DML operations.
1,460
questions with no upvoted or accepted answers
16
votes
2
answers
644
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 ...
9
votes
1
answer
363
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 ...
8
votes
1
answer
243
views
Query highest value of custom Field on Large Object
Existing Logic:
We have a trigger that gets the highest value of a custom Field "UIN__c" on various Objects and increments the value by 1 on each new Record. This Field functions as an ID ...
6
votes
0
answers
494
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:
...
6
votes
0
answers
847
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
1
answer
322
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
2
answers
2k
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
0
answers
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
0
answers
491
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 ...
4
votes
0
answers
684
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 ...
4
votes
0
answers
245
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
1
answer
193
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
0
answers
1k
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
1
answer
68
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
0
answers
142
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
1
answer
4k
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
0
answers
135
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
1
answer
664
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
1
answer
2k
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
0
answers
67
views
Platform Events - setResumeCheckpoint method is not working as expected after throwing an EventBus.RetryableException
We have a Platform events framework that takes the responsibility of processing a batch of n incoming platform events. This framework was working fine until around one/two months ago when we realized ...
3
votes
0
answers
112
views
Platform Event triggers for Subscription Management events cannot be covered by unit tests
As part of the Subscription Management license, certain platform events are fired when an Asset is updated, an Invoice is processed etc.
For example the CreateAssetOrderEvent.
Currently we are using ...
3
votes
0
answers
347
views
Blob to PDF not retaining HTML CSS
I have the following HTML -
htmlBody += '<table width="100%" style="background:#16284c;max-width: 900px;margin: auto;">';
htmlBody += ...
3
votes
0
answers
2k
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 { ...
3
votes
0
answers
216
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
0
answers
512
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
0
answers
667
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
1
answer
532
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
0
answers
720
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
0
answers
207
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
0
answers
564
views
Implementing Financial Force Lib built-in trigger recursion handling?
I'm looking at implementing the fflib_DomainClass in an org as our trigger handler. I know from @AndrewFawcett blog that there's a built in means of handling it. There's also been discussion on Github ...
3
votes
1
answer
866
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
2
answers
246
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
0
answers
3k
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
0
answers
112
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
2
answers
3k
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
0
answers
159
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
0
answers
555
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
1
answer
55
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
1
answer
198
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
3
answers
1k
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
1
answer
577
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
0
answers
136
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
0
answers
64
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
1
answer
150
views
Packaging trigger on UserTerritory2Association object (part of Enterprise Territory Management 2.0)
Our managed package (1gp) has a dependency from Enterprise Territory Management (ETM 2.0).
And we've created a trigger on UserTerritory2Association object to track moments when user is assigned to a ...
3
votes
1
answer
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
0
answers
76
views
When a Quick Action creates a record can Trigger identify the Quick Action?
If an Quick Action creates a record and the creation of that record results in an Apex trigger being executed, can the Trigger determine which Action (if any) created the record?
The Action could, of ...
2
votes
1
answer
78
views
Reducing loop runs and code repetition in a trigger where junction records are created which match several criteria
I'm new to Apex and coding in general and trying to get the best practices down where possible.
This trigger challenge came from David Liu's Apex Academy series and gives the following requirements:
...
2
votes
1
answer
126
views
Update field on related object
:)
I want to update field on WorkOrderLineItem when the value on related product is changed (Product2). I don't have any error, but the field is not updated. Can you please take a look?
@...
2
votes
0
answers
507
views
Visibility InternalUsers is not permitted for this linked record only in Test context
I am receiving the following message when trying to insert a ContentDocumentLink in a trigger but only in test context :
Visibility InternalUsers is not permitted for this linked record
I checked ...
2
votes
0
answers
72
views
newlist empty on BeforeUpdate when using TDTM
newList and oldList is empty when using HED TDTM - unsure why...
code snippet
global class GM_TDTM_OpportunitiesDuplicateFilter extends hed.TDTM_Runnable {
global override hed.TDTM_Runnable....