Stack Exchange Network

Stack Exchange network consists of 174 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

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

0
votes
1answer
67 views

Need help with System.LimitException: Apex CPU time limit exceeded

I am receiving the following error, when trying to bulk load the customer records. Some of them are uploaded successfully, while some of them are throwing the following error. <message> ...
0
votes
2answers
57 views

How to merge existing trigger code in managed package trigger?

I have installed one package in my org. when i write one trigger on campaignMember then it get in recursive call due to managed package trigger. Now i want to merge my code in package code. I want ...
2
votes
2answers
85 views

Help with Query Illegal Assignment from a List to a List

I have a custom object Relationship_Owner__C with a lookup relationship to Contacts. I need to query all the contacts that belong to the relationship owner, and all the tasks assigned to the contact ...
0
votes
1answer
21 views

Update event when related account is modified

I have a trigger on the event sObject that populates a few fields when the event is created off the account, contact or opportunity sObjects. This all works fine. If the account is updated, I need ...
0
votes
0answers
53 views

Update most recent (newest) Opportunity with Created Date to Stage ' Closed Won'

I am working on a requirement which goes like something bleow: We have Accounts and Opportunities. Opportunities has a record type as Surgery. If the account has more then one suregery opportunity, ...
0
votes
0answers
29 views

Dynamic copy questions

I need to add a new dynamic field for Marketing cloud. I am currently using %%First Name%% but I need to update it to %%CampaignMember:Common:FirstName%%. I want to ask: Is it possible? Is my ...
0
votes
0answers
18 views

Create and Assign Task to Account team member

We have an Account Team Member that helps keep the data clean on the Account. I would like them to be assigned a task every time a new Account is created, so they can check for dupes, clean up the ...
3
votes
1answer
98 views

Why is this ContentNote trigger receiving 1 record at a time even though multiple records are being inserted?

I am seeing a ContentNote trigger called on individual rows even though a bulk insert is done. A stripped down version follows. The debug log output demonstrates that 3 ContentNote objects are ...
4
votes
1answer
42 views

Trigger.new contains OLD value of edited Rich Text Area in come cases?

I am observing a very odd issue. It does not happen consistently, but I have seen it in both scratch orgs and sandbox orgs. I have a custom Note object (Note__c) with a Rich Text Area field Notes__c....
0
votes
1answer
24 views

Unable to create Auto EventRelation record via trigger

I am trying to create an EventRelation record on insert of an Event. Basically I am trying to add WhoID of Event into invitees automatically. Am I missing anything. I am not getting any error also. ...
-1
votes
1answer
61 views

Test Class for Trigger Null Pointer Exception

I am new to apex. Getting this error System.DmlException: Upsert failed. First exception on row 0 with id aBfn000000062BMCAY; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, OP_DeferralTrigger: ...
1
vote
2answers
210 views

You have uncommitted work pending. Please commit or rollback before calling out error

I see similar post to this issue but I can't find an exact match. Present Design: After Insert or update trigger calls 1st apex class > Future method 1st class calls 2nd apex class > Method http....
0
votes
1answer
26 views

Not able to create incident from salesforce to servicenow

I tried the following code to insert incident from salesforce to ServiceNow but not sure what I am doing wrong here, Can anyone guide me what changes needed in this code or do I need to create ...
0
votes
0answers
19 views

Permissions enforced during “Field Update Action”?

I've got a multi-user approval process that calls a "field action update". The change made by the field action update is caught by trigger I've written which performs additional operations. My ...
0
votes
1answer
29 views

System.QueryException: List has no rows for assignment to SObject — on Entitlements for an existing trigger

We have an old Salesforce org from which we are migrating entitlements and data to a new org. There is also a trigger for adding the entitlement by default to the case. It had 90% code coverage. But ...
0
votes
1answer
18 views

trigger on email sent to third party email id from salesforce

Wanted to track emails sent from salesforce to any third party email ids and not the contacts or any internal user.
0
votes
1answer
27 views

Sum values in multiple currencies

Suppose you have objects Customer and Invoice. Invoice has a lookup to to Customer, which means each Customer can have to multiple Invoices. Considering that: Multi currency is enabled. Customer can ...
0
votes
2answers
45 views

Not getting the oldvalues in test class - trigger coverage

I have a test class where i am updating the stage to cover my test class. Issues is i am not getting the old value in after update trigger All my debug are with new value :( Below is my trigger ...
0
votes
1answer
19 views

Approach for storing historical records and tracking changes

New to salesforce. I have a custom object Publisher that is related to the Account object. Whenever an Publisher is changed for an account I would like to keep an history of who the old Publisher was ...
0
votes
0answers
20 views

I have one dependant picklist and controlling picklist and just wanted to ftech value of controlling picklist from dependatn picklist [duplicate]

I have one dependent picklist, and controlling picklist, and just wanted to fetch value of controlling picklist from dependent picklist. How can I achieve this using apex? Controlling picklist ...
1
vote
1answer
38 views

How are QuoteLineItems related to OpportunityLineItems

How does the QuoteLineItems Generated from the OpportunityLineItems, Can I add Fields that It can copy? How? I'm looking for a way to add fields to copy from the opportunity items to the quote items, ...
0
votes
1answer
47 views

triggers and helper class to update quoteline items from account

trigger ct on Account (after insert, after update, before insert, before update) { Set<Id> accIds = new Set<Id>(); Set<id> oppIds = new Set<id>(); for(...
0
votes
1answer
40 views

How to Update the Date field(Custom Last Modified field) in the Parent object when the fields in the child object is changed

We have opportunity as parent object and this parent object has several related list(lookup or masterdetail), whenever the fields in the child object is changed this should update the opportunity last ...
0
votes
1answer
25 views

Trigger Test Class failing assertion

For the following class, I have a test class with two methods. The second method is failing at System.assert(Jet2.Status__c == 'Booked'). The status is still 'Active.' How do I fix this? Trigger ...
0
votes
1answer
37 views

Constructor not defined executeBatch trigger to pass ID to batch class

Ok...trying to write my first class and trigger and running into a wall that I can't seem to get over on my own. Use case: on a custom object called manufacturer__c, when a field goes to "in Process" ...
-1
votes
1answer
29 views

trigger on case feedItem when a chatter post is going on case it also receive by case team members [closed]

my need is that any time any chatter post is going on case Case Team Members should also receive it. i am using entity subscription for it? Basically here i want to do whenever some one insert a ...
1
vote
0answers
20 views

Using addError on object in trigger for custom validation messages is taking users to random Picklist Value Sets page in Lightning?

I have a page for a custom object that contains a link: <apex:commandLink styleClass="actionLink" onclick="return confirm('{!$Label.PCE_Are_You_Sure}');" action="{!URLFOR($Action.PCE_Step__c....
0
votes
1answer
62 views

External entry point Error in Trigger

In my Apex trigger I got an error: Error:Apex trigger Remittance caused an unexpected exception, contact your administrator: Remittance: execution of AfterUpdate caused by: System.QueryException: ...
2
votes
1answer
29 views

force an opportunity to always have the same contract

Currently our salesforce users are changing the contracts of the opportunities. We automatically create a contract and do some maintenance on the contracts so we do not want anyone to replace the ...
2
votes
1answer
53 views

Trigger to update child and grand child records when Account is updated

I need a trigger to update Contact Description and Contact related Case object Description whenever Account Description is updated. Below trigger working fine for updating Contact Description when ...
0
votes
1answer
43 views

Covering addError in test class

I built this error to fire off an exception when an account's SLA field with open cases is being changed, when it shouldn't. Trigger trigger DoNotAllowSlaChangesWithOpenCases on Account (before ...
1
vote
1answer
66 views

Lead Conversion Trigger Test Failing

I have the following trigger that is working properly trigger LeadConversionTrigger on Lead (after update) { for (Lead l : Trigger.new){ if (checkRecursive.runOnce()){ // only run if ...
1
vote
1answer
36 views

Update fields on Same record

In my Code the scenario is there is a Custom objects in which two custom formula field which is dependent on other three custom fields and i have to update two other field with that formula field ...
0
votes
0answers
15 views

Can you use a FeedItem trigger to hide Entitlement Feed Items to change visibility?

I found a idea on the Salesforce community that I need to implement. https://success.salesforce.com/ideaView?id=0873A000000lIYcQAM So I am asking if anyone has had any luck on using a trigger on ...
0
votes
1answer
31 views

Sending Triggered email from Email Click

I'm trying to trigger a "Triggered Send" from when a user clicks on a link in an email. At the moment I'm passing users through to a CloudPage, inserting their info into a Triggered Send DE and then ...
5
votes
1answer
32 views

Partner object - workbench says it's triggerable - but it's not

I need to create a trigger on the OpportunityPartner object. I know it's not triggerable. However, looking with workbench on the 'Partner' object, it's triggerable attribute is 'True' Is that a ...
1
vote
1answer
41 views

auto populate the account record field value

I have a custom object 'X', while creating a new record in object 'X' there a lookup field related to account object, when i select any account name 'Vinay' then the 'vinay' related account record ...
3
votes
1answer
21 views

What are multiline items in Salesforce?

I am learning about triggers in Salesforce using the documentation. It is said there: Salesforce runs user-defined validation rules if multiline items were created, such as quote line items and ...
0
votes
1answer
46 views

Apex Trigger Code Coverage Deployment Validation Inconsistent with Debug Logs

I have a test class for a trigger on a new custom object (Sample) that covers nearly 50% of the trigger in Sandbox, and is nearly identical to another trigger for a different (older) custom object (...
1
vote
1answer
36 views

Delete Trigger on mass deletion to prevent deletion if only one contact is remains

I am trying to write a trigger where if account has only one associated contact left then prevent deletion. I wrote a test class to validate the same and found this does not work for mass deletions, ...
0
votes
1answer
47 views

Trigger to be executed on DML?

There is two object Branch and Employee both are related to each other by a Branch_Lookup field on Employee field. Both are having a checkbox field named as External_Employee__c , as per req if parent ...
3
votes
1answer
71 views

Confirm if sub-query is selective?

I have a query in a before-update trigger that looks like following: [SELECT Id,(SELECT Id,Active_opp__c FROM Opportunities ORDER BY Days_from_Last_Stage__c ASC) FROM ...
0
votes
1answer
39 views

Bulk Update Accounts - trigger to throw error

I have a requirement that only if the accounts list has one record, the inspectionsToUpdate is updated. If there is more than one record in the accounts list, for example, because someone is trying to ...
0
votes
1answer
67 views

System.DmlException: Delete failed. CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, execution of BeforeDelete

BACKGROUND I have a simple trigger which is meant to block a record from being deleted based on the record type. I am using a Trigger Handler by Kevin O'Hara Trigger trigger InvoiceTrigger on ...
3
votes
2answers
120 views

Trying to access account geolocation fields in after insert trigger

I'd like to use the Salesforce account Geolocation fields (billing address latitude and longitude) to assign accounts to specific geographical zones. Salesforce automatically updates the billing ...
0
votes
0answers
27 views

Update OpportunityProducts field based on change in Products. Can we do cross object field update via Process Builders/Flows? [duplicate]

Can we update a custom field on Object - Opportunity products, whenever there is a change in a custom field on Object - Products ? I cannot use formula field as I want use this info for roll up ...
1
vote
2answers
96 views

Why is my flag not working on maximum trigger depth exceeded

I have written a trigger for purchases if the purchase contains several of the same purchase detail items they should be summed up and merged as 1 purchase detail. When I use a before insert I get in ...
0
votes
1answer
75 views

Unexpected token `<`. in Apex trigger

I have the following trigger: trigger AccountAddressTrigger on Account (after insert, after update) { List<Account> accs = [ SELECT ShippingPostalCode, BillingPostalCode ...
0
votes
2answers
105 views

System.debug does not output when written in trigger

I have the following trigger: trigger HelloWorldTrigger on Account (before insert) { System.debug('Hello World!'); } I checked that the trigger code is saved. Now I run the following anonymous ...
4
votes
1answer
82 views

Is it possible to inspect the `HttpRequest` object on MockHttp Callout?

I have a simple trigger that calls a class with an HTTP callout like this: Trigger trigger OfferChange on Offer__c (after insert, after update) { Boolean isSandbox = [SELECT IsSandbox FROM ...