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.

13
votes
0answers
262 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 ...
5
votes
0answers
65 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
0answers
218 views

Dynamic trigger creation from managed package

I have a requirement to create triggers dynamically after a managed package is installed. I have read that the tooling API can be used to create triggers dynamically however it cannot be used in ...
4
votes
0answers
316 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 ...
4
votes
0answers
693 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
132 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
0answers
129 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 ...
3
votes
0answers
69 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
0answers
385 views

AgentWork trigger is not firing before or after insert events

I have created an after/before insert trigger defined on AgentWork object. When a case is created from Email to Case, the record is automatically routed to an available Agent from a queue by Omni-...
3
votes
0answers
719 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
358 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 ...
3
votes
0answers
128 views

Is there a trigger I can use to catch changes to a user's e-mail signature?

I'm trying to write an Apex trigger that fires when a user changes his or her e-mail signature through Personal Setup -> Email -> My Email Settings. Because the signature is stored in User.Signature, ...
3
votes
0answers
101 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
356 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
405 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
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 ...
2
votes
0answers
38 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 ...
2
votes
0answers
83 views

Delete __Sharing object

I'm receiving the following error: TR09_MasterServiceAgreement: execution of AfterInsert caused by: System.DmlException: Delete failed. First exception on row 0 with id 02c1800002Lir2PAAR; ...
2
votes
0answers
79 views

HtmlBody of on EmailMessage does not stay as set in before insert trigger

I'm trying to cut off email threading from EmailMessage. I try to do this in BEFORE INSERT trigger. Original email: Hello Tom, We saw your complaint. We are working on it. Gigasoft ...
2
votes
0answers
110 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 ...
2
votes
0answers
144 views

How to replace long formula with Process Builder or Workflow?

I am getting this error: Formula(s) that reference this field are no longer valid: Compiled formula is too big to execute (5,329 characters). Maximum size is 5,000 characters (Related field: ...
2
votes
0answers
67 views

Before trigger - field not updating as expected

My last question got the error fixed but now I'm not seeing the expected behavior and I'm scratching my head as to why. I have another similar trigger on another object in my org that is working just ...
2
votes
0answers
23 views

Is it possible not to display INSERT FAILED Error in page, when our custom validation error is triggered

We have a visualforce page (Manage Packaged) that saves a record. We added a custom validation using trigger (addError method) to prevent it to save when a certain criteria is met. But when this is ...
2
votes
0answers
138 views

Is there any special restriction on using OriginalQueueId field in AgentWork trigger?

We have written a before/after update trigger on AgentWork object to get information about the Owner Change from Queue to User on Case record acceptance from Omni Channel. To get this From and To ...
2
votes
0answers
62 views

Intermittent non-selective query

tl;dr: I believe that my particular query is selective, but Salesforce occasionally insists it isn't. Evidence follows. What am I missing? ==== Every now and again (7-8 occurrences since 2017-1-1), ...
2
votes
0answers
108 views

Need help with the error : : Apex CPU time limit exceeded

I am receiving error in the below lines of code when I pass more than 200 records in the list. For the fewer records it is working fine. Is there any way to optimize the code to avoid the error. ...
2
votes
0answers
196 views

Trigger to replace HtmlBody on EmailMessage being overwritten by native SF logic?

We have written a trigger on the EmailMessage object that searches the HtmlBody of any newly inserted record for a static String. If found, Everything from the index of this string to the end of the ...
2
votes
0answers
93 views

Lightning UI - error after automatic lead conversion by trigger

Having a trigger to check if tasks/activities of a lead, to match a conditions then we do auto-convert the lead. On Salesforce classic, everything just go fine as expected. Unfortunately, Lightning ...
2
votes
0answers
72 views

Apex Sharing to multiple individual users throws duplicate row error

Scenario I have Community users that I need to share some account records to, where the Account that the Community user is linked to is referenced by a lookup field on the Account record to share.I ...
2
votes
0answers
59 views

Separating Concerns into Methods

I'm trying to write better code and make it clearer what each function does and build tests that cover it. I have a method in a triggerhandler class that updates a date field when another date field ...
2
votes
0answers
52 views

Old record shows the converted currency to EUR instead of showing the amount in USD

I have a field in Opportunity named List Price Summary that computes and displays the SUM of the Total Price in all its Opportunity Line Item records through trigger. For example, I have two ...
2
votes
0answers
586 views

Box.com creating folder for record failing

i'm encountering a wierd behavior in my box.com integration for salesforce. Here's the code. @future (callout=true) public static void createFolder(Id id) { //Instantiate the Toolkit object ...
2
votes
0answers
746 views

Create Box Folder via Apex

I have the code below in my Sandbox environment. I'm test running it in Developer Console. My sandbox environment is connected to my Box.com account. What I'm attempting to do is create a new folder (...
2
votes
0answers
2k views

System.DmlException: Upsert failed. First exception on row 0; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY,

While deploying the code the system throws an error as: Code Coverage Failure The following triggers have 0% code coverage. Each trigger must have at least 1% code coverage. When i run the test ...
2
votes
0answers
104 views

If an “update” doesn't include any real changes, will the update trigger still fire?

When I first thought of this question, I assumed it would be easy to find answered online, but I can't seem to find it posed anywhere. It's part development, part administrative in nature, so please ...
2
votes
0answers
356 views

ORA-20025 converting lead to contact

I am trying to convert lead to contact and I get this error: ORA-20025 common.exception.SfdcSqlException` ORA-06512: at "SNEEZY.CACCESS", line 2399` ORA-06512: at "SNEEZY.CACCESS", line 585` ORA-...
2
votes
0answers
142 views

ConnectAPI updateFeedElement with new mention in trigger double email

I'm coding a trigger for "FeedItem" to automatically add a mention to a certain user. I'm following pretty much the same logic stated here (by adding a new mention segment to the feed input): https:/...
2
votes
0answers
365 views

Lead conversion in lightning UI

We have a trigger in place which takes care of Lead conversion (we had to do this for certain customization requirements). It works fine in Classic version but gets hung-up in lightning UI. If we ...
2
votes
0answers
788 views

Trigger on PricebookEntry

I want a field on Custom PriceBookEntry to be updated from Standard PriceBookEntry when it is created. However, Salesforce doesn't allow writing a trigger on PricebookEntry. What are the options I am ...
2
votes
0answers
719 views

How to allow Partial Commit on a Before/After Insert Trigger?

I'm having the following problem: I have a before Insert trigger on a Custom Object and we have to permit partial commit, meaning if they insert 3 records Ok and just 1 or 2 with errors at the same ...
2
votes
0answers
82 views

Centralize Object Initialization - (Insert Event with Attachment on same code)

I have a piece of code that sets a Boolean (has_Attachment__c) field to true in an After Insert context variable is executed in an Event in which an Attachment is inserted on the same time. The code ...
2
votes
0answers
104 views

FeedComment insertion does not generate Chatter email

I was able to create an automated FeedItem trigger that fires and automatically replies (from a dummy user) to a user when he/she makes posting. I did not get the typical "commented on your post" ...
2
votes
0answers
2k views

INSUFFICIENT_ACCESS_ON_CROSS_REFERENCE_ENTITY, insufficient access rights on cross-reference id: []

I have been battling with this for few days now. Below is my scenario. I do have a trigger on Sampling__c object that updates the owner and assigns a manager for the request created. When updating ...
2
votes
0answers
142 views

Records created via API not triggering workflow/process

I have Tasks that are automatically created using an app Sidekick, which logs emails sent from gmail as activities. To my knowledge, workflows can usually be trigger by records created via API. (...
2
votes
0answers
56 views

Can I create a new case when an email is sent to a closed case?

We are implementing email to case and would like to create a new case whenever an email is sent to a closed case. Our customers have been known to respond to old email strings to open up a new case. ...
2
votes
0answers
93 views

Does adding a contact and user to an account trigger an update to that account?

I am trying to fire a trigger on the account when IsCustomerPortal if flipped to true. I have checked in workbench and this field is definitely changing when I add a new user and contact but it doesn'...
2
votes
0answers
233 views

Skip/bypass approval process

I want to skip/bypass an approval process by using some other VF page/apex class/trigger, is it possible ? what kind of framework should I think of ? Basically I want the record to be editable, even ...
2
votes
0answers
363 views

Insufficient Privileges During Lead Convert - Trigger Doing Owner Change

I have a basic trigger that defaults the owner for accounts and contacts upon lead conversion. After turing on triggers and validations for lead conversions this is mostly working, but in some cases ...
2
votes
0answers
246 views

Apex Code maximum trigger recursion depth with allOrNone false allows successful DML?

We recently changed some logic in a trigger, and some of the updates in the trigger mysteriously started to fail. Afterwards, we set up a simple test case to see if we could locate the cause of the ...