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.

0
votes
1answer
32 views

Test class Limits.getEmailInvocations() showing zero and assertion is failing

I have a bizarre issue. I have a trigger that will send an email based upon a record update. When I debug my trigger running the test class it showing the email result as success and when I debug and ...
0
votes
1answer
24 views

unlock record submitted for Approval

When a record is submitted for approval, it is locked by default. But as per the recent change by Salesforce, it can be unlocked using Apex class. I have this below Apex class which unlocks the ...
0
votes
0answers
27 views

Limit file size to 2 MB for fileUpload Lightning compoennt

I have a requirement where i need to restrict the user to not upload the file size more than 2 MB. We are using lightning:fileUpload , for which i don't see any size parameter. We are uploading file ...
0
votes
1answer
21 views

Schedulable Batch Errors

I'm trying to write a schedulable batch class that runs every night at midnight that updates these particular fields. I keep recieving these error messages and I dont understand why I keep getting ...
-1
votes
1answer
20 views

How to make editable field of CreatedBy in salesforce object?

CreatedBy field should be editable for only Salesforce Administrator Profile. Is it possible ? Please give me Solution of this problem. Because My scenario is Whenever user will de-active by ...
0
votes
1answer
25 views

Recursion in Trigger and Process builder

I have a before update/insert trigger on Contact trigger ContactTrigger on Contact (before insert, before update) { for(contact con:Trigger.New){ If (con.FirstName ==con.LastName){ ...
-3
votes
1answer
31 views

Delete Contact lastname

This is mycode if i deleted the contact record delete the last name in Contact_Names__c in Account trigger ContactNamesOnAccount on Contact (after update, after insert) { Set<id> ...
0
votes
1answer
25 views

Can we create platform event dynamically without using UI? [closed]

I want to create a platform event dynamically using any programming language. But I didn't find any API. Can you please tell me I can make platform event dynamically?
0
votes
1answer
27 views

It's showing error - Variable does not exist: CreatedById

trigger AssignToReportingManager on User (After update) { String query,userId,reportingManId; List<sObject> sObjectList = new List<sObject>(); //Set<Id> userId = new Set&...
-3
votes
1answer
29 views

Triggers not working

My previous problem is not resolved I have a Custom filed in accounts which is name as No of contacts now I have to write trigger after update which follows the logic of if I put no of contacts more ...
0
votes
0answers
17 views

Trying to determine the best way to write a trigger on a file(ContentDocument) which is uploaded and Is realted via COntntDocumentLink to a Case

I am very new to Apex (I wrote one two line trigger and test class successfully) and am trying to figure out this scenario. When a customer or internal user uploads a file related to a Case I need an ...
0
votes
0answers
27 views

Can we create a webhook using Partner Wsdl in Salesforce?

I want to create a webhook(trigger), whenever some object got inserted, deleted and updated and notification comes to my external server. So, I can do more action further with my data. Is it possible ...
0
votes
1answer
20 views

Not getting a value from SOQL query as expected when using a bind variable

public class ELOUpload_Class { public static void ELOUpload_Method1 (List<ContentDocument> lstContentDoc) { //Create a set of all the incoming IDs Set<Id> contDocId = ...
-1
votes
0answers
15 views

Im new in SF, I want to write test class of this trigger. And Trigger is to create contact from case if not exist in system [duplicate]

trigger TriggertoCreateContactformCase on Case (before insert) { List<String> UseremailAddresses = new List<String>(); //First exclude any cases where the contact is set for (Case c:...
0
votes
2answers
39 views

Apex Trigger Order Of Execution

Correct me if my understanding is wrong - All the DML operations are committed only if the entire code runs successfully. I've carried out the following activity: Written a block of code which will ...
-1
votes
1answer
22 views

Trigger on EmailTempAttachmentMap [closed]

Has anybody written a trigger on the EmailTempAttachmentMap object type. I am not sure how to access that ObjectType. thanks.
0
votes
1answer
40 views

No duplicate names depending on other field

I have a doubt on triggers. I have a object as Hospital__c. zipcode__c is a field in hospital. A zipcode should have only one hospital name. If increase error should throw. How to solve this using ...
0
votes
1answer
32 views

Convert List<Id> into Map<Id,sObject>

I have a list of Account Ids with me. I want to convert it into Map. Is it possible to do that without using SOQL in loop to retrieve the Account object per ID? I need this to add it to my trigger ...
-1
votes
0answers
22 views

Test Class Help - Opportunity Object [duplicate]

I wrote a trigger that will query Opportunities and automatically delete a duplicate if the name is found to match with an Opportunity that has the same name. We have a process builder running that ...
0
votes
1answer
77 views

System.DmlException: Upsert failed. First exception on row 0; first error: DUPLICATE_VALUE, duplicate value found [duplicate]

I had a trigger that fired from webhook, this trigger receive JSON that contain external Id for account object, inside the trigger I do an upsert on account object using the following code Database....
0
votes
0answers
43 views

Refresh standard lightning layout after trigger modifies records (After Update)

On Account I have a lightning flexipage it has a custom component, standard layout. Also, There is a trigger for after update that calls a future method and it updates this account and other account ...
-1
votes
1answer
37 views

Platform Events Subscription through Trigger and parsing a JSON payload field [closed]

We are going to implement platform events for inbound integration and subscribe to events using trigger. Among the platform event object, one of the fields is a long text area which has a JSON payload ...
1
vote
1answer
20 views

How to access Owner field using getDescribe().fields.getMap()

I have a below code to access owner field from sObject. Map <String, Schema.SObjectType > sObjects = Schema.getGlobalDescribe(); Schema.SObjectType targetType = sObjects.get('...
0
votes
0answers
15 views

Test coverage for test class of trigger is showing 53 constantly [duplicate]

I am new to salesforce development.I have written test class for following trigger, which is having coverage as 53 only. I tried several times by adding and changing code lines into test class but it ...
1
vote
2answers
74 views

System.FinalException: SObject row does not allow errors

Can someone point me in the direction of not getting the error OpportunityTrigger: execution of AfterUpdate caused by: System.FinalException: SObject row does not allow errors: Trigger....
0
votes
0answers
19 views

How can I add first map value into a second map [duplicate]

trigger DTrigger on D__c (before insert,after update) { Map<Integer, String> firstMap = New Map<Integer, String>(); firstMap.put(100, 'lokesh'); firstMap.put(101, 'lokeshA'); ...
0
votes
1answer
17 views

Does too many users in salesforce org impact salesforce performance.How does it impact?

If a salesforce org has more than 150k users does it impact the Salesforce performance ? And in what scenarios . How do we approach these performance issues.
0
votes
1answer
32 views

How can I manage sequence of DML operations in a trigger?

How can I manage sequence of DML operations in a trigger? Let’s say we have 3 objects, A, B & C. All have after triggers defined. Insert for B is present in “after insert” trigger of A and DML ...
0
votes
1answer
43 views

Need help on trigger which is used to update parent record when child record value changes

Hi i have written trigger in which SC_Problem_Management__c is parent object and SC_Problem_Case_Link__c is child object having master detail relationship. I want to update status field of parent ...
0
votes
1answer
36 views

Efficient SOQL for record classification

I need to "classify" an incoming Record A based on several related fields on records B,C,D,.. etc. Therefore I need a trigger that is triggering (:D) on this new record and check more then 5 lookup ...
0
votes
1answer
12 views

Task created upon Opportunity creation - Where is this code likely located?

Right now my SF is set up so that when someone creates an Opportunity over a certain amount ($1000), a Task is created and assigned to a user. I'd like to edit it so that it only creates the task if a ...
0
votes
0answers
15 views

Insert a record in custom object when attaching files in Salesforce

I am working on as assignment where I need to insert a record in a custom object (FileAttachment__c) when a file is uploaded under a Contact. When the file is uploaded, the custom object record needs ...
0
votes
0answers
15 views

How to avoid locking a record when the approval process is pending?

I need to have records of a given objects unlocked during the pending phase of the approval process. I tried to use a trigger on the object under the after update condition and check the status of ...
1
vote
3answers
58 views

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

I keep getting a null pointer exception error as follows : System.NullPointerException: Attempt to de-reference a null object Stack Trace: Class.ColloTest_utoStudentIDTrigger....
0
votes
2answers
24 views

Getting SOQL limit errors in before update trigger - due to records created that has other triggers with it

I am hitting SOQL Limits when I update a record from my custom object "OnBoarding_Data__c" . I have a trigger that is designed to create multiple "Case" records on before update. And as soon as the ...
0
votes
1answer
21 views

Apex Trigger, update records after all records have been processed

Here is my use case. I am syncing records between two orgs using Jitterbit. I select Users from orgA and create Contacts in orgB. Pretty straight forward and this is working. My challenge is that ...
0
votes
0answers
28 views

Testing In Salesforce [duplicate]

Please Let me know.How to write TEST class for the following code? trigger TriggerForACC on Account (before insert) { List<Contact> conUpdatedList=new List<Contact>(); List<...
0
votes
2answers
33 views

Query lead owner city in apex soql

I am trying to do an soql query in apex which will fetch the lead city value as well My query is looking something like the following: select count(Id)cnt, OwnerId from Lead where Owner.City =: ...
0
votes
1answer
41 views

Customize email-to-case feature to also add values to the contact name and account name fields

I need to automate the process of creating a new case for each new mail received in an email id and salesforce already has a feature called 'email-to-case' feature for setting up this automation. I ...
0
votes
2answers
20 views

AffterInsert PROBLEM

I am attempting to update a field on the Opportunity object with the project that gets created (that is associated to the opportunity) So basically the way things work is that when an opportunity is ...
0
votes
1answer
69 views

Too many SOQL queries: 101 and Triggers

SHORT VERSION: I'm getting a "Too many SOQL queries: 101" error on my production environment when updating some Leads through an external application. The theory is that it's due to multiple nested ...
0
votes
0answers
23 views

Insufficient access rights on cross-reference id in a managed package procedure

I have added a changing Opportunity owner logic inside Opportunity before triggers. And this is causing issue in a managed package procedure when I amend a contract in Salesforce cpq package. The ...
0
votes
1answer
42 views

SOQL to return COUNT value via Apex

I am trying to return the SOQL listed values into a field using an Apex Trigger:- Object: Name = RPA__c Fields: Business_Area__c (picklist) VALUES = Finland Managed Services, UK Managed Services ...
2
votes
4answers
473 views

Should I update trigger API version?

I am an admin and have looking through some of the old triggers that are currently in our org. There are a few of them that are still active and do some important job but are set to API version 20. ...
0
votes
0answers
14 views

Add error displays message as well as updates record in Salesforce lightning

I have the following piece of code in my case before trigger. approvalStatements.get(pi.TargetObjectId).addError( 'Operation Cancelled: Please provide a reason ' + ...
0
votes
0answers
34 views

Streaming API PushTopic VS Trigger and API Callout

I haven't used the Streaming API yet. I was just researching on it actually and I like the option for PushTopics. However it's not clear to me what's the advantage/difference using that versus a ...
0
votes
1answer
67 views

About heap limits on triggers, garbage collection and transient variables

My friend and I are studying for platform developer I, and one of the questions we use for studying asks what are the best practices to avoid heap limit errors in triggers. The full question reads: ...
0
votes
1answer
26 views

Create contact and community user when the lead status is updated

I am trying to create a contact , custom object record and community user when a lead status is changed , so issue is i am able to create contact and custom object record(without the code to create ...
0
votes
1answer
57 views

Trigger creating multiple records where i need only one?

I have created a trigger(after update) on Lead which will fire on status change and create a contact and custom object record. Issue is that trigger is working but creating around 7 records of ...
0
votes
1answer
15 views

How to create round robin lead assignment for certain lead status value and lead source?

I have done the setup listed here (https://help.salesforce.com/articleView?id=000004000&type=1) for round robin lead assignment, but 'd like to do a lead assignment based on two criteria: the lead'...