Last call to make your voice heard! Our 2022 Developer Survey closes in less than a week. Take survey.

Questions tagged [trigger]

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

Filter by
Sorted by
Tagged with
-1 votes
1 answer
12 views

How to give profile label permission for files upload and delete

I want to give permission for some profiles users where the users should not able to upload files and delete files. They can only download file. What is the suitable way to achieve that.
user avatar
0 votes
1 answer
21 views

Triggers on contact to update decsiption field of its parent account

i am new to sales-force triggers i need help for writing this trigger i tried to wrote but whenever i am inserting new contact for the same parent the account descriptions is getting over written with ...
user avatar
0 votes
1 answer
14 views

Unable to fetch the Parent Account information into the Child Account Record

I have one section in Account named as Credit Information having five fields init. While creating Child Account Record, I wanted to fetch the Credit Information from Parent Account. Below is the ...
user avatar
  • 1
0 votes
0 answers
17 views

Throwing Error Message Using Trigger for aggregate query

My scenerio is like we have a case object. That case object has relation with "sample" object. "sample" has master detail relation with case object. Now in "sample" we ...
user avatar
  • 1
-1 votes
0 answers
16 views

Can you able to suggest me any solution for the errors what I have in my trigger?

I just want to do that. When I attach any document to an opportunity, that related account should also be updated with that same document in Notes & Attachments. [! [enter image description here] ...
user avatar
-2 votes
1 answer
20 views

How to assign a value to to a field stored in a custom setting?

I'm building an app and I'm giving users the ability to select a specific field to populate from a list of all of their fields. I'm storing that field's API name in a custom setting. I want to create ...
user avatar
-1 votes
0 answers
26 views

Writing Triggers [closed]

I'm new to writing triggers how do I write a trigger for this Populate Number_of_test_to_check__c with Required images where Status__c = 'Waiting for approval' Note, Required images is a custom object,...
user avatar
-1 votes
0 answers
20 views

Need to populate a field in a new claim form based on the logged in user

We have all custom objects in our org that our customers use. What I need to accomplish, is, that I need to auto-populate a field based on the logged-in user. Under the user profile, they have to set ...
user avatar
-2 votes
1 answer
38 views

System.LimitException: Too many callouts: 101 Error

I have this below code which is pushed to prod. Where in I am trying to make callout in future method to update lat/long values on Standard location Trigger, and each time the records are processed i ...
user avatar
  • 1
-1 votes
1 answer
31 views

Multiplication of two fields in salesforce using trigger

I am new to salesforce. I tried multiplying two fields from two different objects but was failed to do so. I have two objects object 1 and object 2 as given below: object 1 is child of object 2. ...
user avatar
-2 votes
0 answers
26 views

Create a action-button based automation to auto convert leads to Account, Contact, Opportunity - For New Leads [closed]

Create a action-button based automation to auto convert leads to Account, Contact, Opportunity - For New Leads If Account, Contact is new - then create Account, Contact, Opportunity If Account is ...
user avatar
-2 votes
0 answers
22 views

How to separate handler class and Trigger from below code [closed]

Trigger ContactTrigger on Contact (AFTER INSERT, AFTER UPDATE) { set<Id> accIds = new set<Id>(); if(Trigger.isInsert || Trigger.isUpdate) { for(Contact con: ...
user avatar
  • 1
1 vote
2 answers
34 views

I am trying to split logic from Trigger to handler class with "Method does not exist or incorrect signature: void Error

I am a starting SF developer and having issues with handler class. This is my original trigger: trigger OpportunityTrigger on Opportunity (after insert, after update, after delete) { Map<Id,...
user avatar
  • 13
1 vote
2 answers
93 views

How to avoid nested for loop condition for code optimization & reusability?

My requirement: Restrict users from updating some specific fields. These fields can increase or decrease in the future. So, it should be dynamic. Checking should be done in the triggerHandler. There ...
user avatar
  • 320
1 vote
1 answer
30 views

user country is blank when updating records from my setting ("personal information")

I have added country validation in the user trigger so when the country is blank then the system displays validation error to the user. My trigger code is working as expected when we modify the user ...
user avatar
0 votes
1 answer
16 views

Want To Return First Response Timestamp As Null If The Case Origin Is Web

I'm trying to ensure that two of our fields, which are formula based, return as Null if the Case Origin field (object = Case) is "Web". If it's any other origin source, the First Response (...
user avatar
0 votes
2 answers
39 views

Trigger to prevent deletion of account which has atleast one contact linked to it not working

I am trying to create a Trigger which will prevent deletion of Account which has atleast one contact linked to it. But its not working. Here is my code trigger AccountDeleteonPrevention on Account (...
user avatar
  • 15
-1 votes
0 answers
34 views

Too many rows Exception

Can you please assist to debug below, while calling below method from Helper class into trigger, getting too many rows exception Thanks in advance public static void LeadAssign(List<Lead> ...
user avatar
  • 9
-1 votes
0 answers
30 views

Rollback update with future

I have this use case: There is an Account record, which updates type and calls a future method that updates industry. I want to rollback to the initial state. Trigger trigger UpdateAccount on Account (...
user avatar
-1 votes
0 answers
25 views

Call External Url on record update from standard record page [closed]

When a record is saved in the standard page, I need a external url to open in a new window without any intervention after the save operation
user avatar
0 votes
1 answer
28 views

Validate records by date ranges in SOQL and apex en bulk

I have a custom object with two dates - start and end. When inserting multiple records, I want to ensure they don't overlap at all. Naive implementation: global with sharing class OverlapFilter_TDTM ...
user avatar
  • 4,429
2 votes
0 answers
20 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....
user avatar
  • 4,429
0 votes
1 answer
47 views

Create Apex trigger on an Object than execute a Platform event

I`m trying to create an Apex Trigger on an Object (Asset for example) to check if a specific Checkbox fields is true than execute a platform event (which I have a PE flow that updates the record) I ...
user avatar
0 votes
1 answer
44 views

Bulkifying a trigger with a fiscal year/quarter specification

Please, give me a hint about how to approach the problem. Problem Every first Event based on StartDate in a Fiscal year and quarter should have the FirstEvent__c boolean field set to TRUE, other ...
user avatar
  • 33
0 votes
1 answer
21 views

Issue while inserting new Opportunity Product records on after insert trigger

Here is the scenario: I have a Bundle product which when added to the opportunity should add related products in that Bundle. I have written trigger on after insert but instead of adding related ...
user avatar
  • 101
-1 votes
1 answer
56 views

Populating field automatically

My requirement is once any user creates a new task, and the Related to value is "sales", the field Campaign will be updated automatically with the value from Related To field. The data type ...
user avatar
0 votes
1 answer
26 views

Do triggers in salesforce have test class created by salesforce not by the developer?

I am using Ant Migration tool to deploy or retrieve my metadata in salesforce. I have a LeadTrigger that I fetch but when I was running the test before I deploy, I got the error that I didn't reach ...
user avatar
1 vote
0 answers
17 views

Write Test Class for ContentDocument Trigger that sends email notification

I have the below code that fires an email notification to 3 related users from the account of the user that uploaded a document (this is for experience cloud users only). I'm struggling to get started ...
user avatar
  • 11
0 votes
1 answer
16 views

execute logic beforedelete event trigger

Before deleting the record (Ex: Account obj record), I want to update the field on the account record and send it to content management, hold it for a few seconds, and then delete it. For this ...
user avatar
  • 235
0 votes
1 answer
39 views

Apex - Insert json value into custom field

I am inserting records into custom object Rating__c via trigger. This object has a field that stores json value against each record based on Account ID(Related Account). Example: {"attributes&...
user avatar
  • 1
0 votes
3 answers
40 views

trigger to update parent record field from child

I have a requirement where i need to update a field on Account object everytime a related case is closed. The Field "Closed Cases" is a number field on Account object. Everytime, I close a ...
user avatar
-2 votes
1 answer
27 views

Method does not exist or incorrect signature: void contains(String) from the type List<Lead>

I'm trying to find if there's a duplicate record Name in Lead object if I create new record, however I'm getting this error when using contains() method. What can I do to fix this? And why I'm getting ...
user avatar
0 votes
1 answer
19 views

How to retain the create date of a deleted Lead record after merging

What I would like to achieve via automation is to record the created date of the latest record on the retained record after merging. Example: A new lead comes in on 01/01/22 and a duplicate lead is ...
user avatar
0 votes
1 answer
19 views

Tagging Lead with most recent pre-mql campaign (help with trigger)

I need some assistance, and greatly appreciate any help I can receive. I am trying to tag a lead with its most recent pre-mql campaign. The code I have does in fact work on insertion of a campaign ...
user avatar
  • 13
0 votes
1 answer
23 views

Apex Trigger to Update Feed Comment

I am new to Apex Triggers. I have a checkbox field in Opportunity called "Opportunity Approved?". Currently as soon as user selects the checkbox, its adding a feed comment like this, ...
user avatar
0 votes
1 answer
29 views

Trigger related projects leads

I am new to the salesforce platform and am looking for some guidance. I have read a bit about triggers and was wondering if it would be possible to create one for the following case: I have a file ...
user avatar
0 votes
2 answers
106 views

How to track time spent in each stage of a custom detail object

So we have a custom detail object which uses a custom stage picklist field which we use for the path. We also have a custom status picklist field with values as unclaimed, In progress and completed to ...
user avatar
  • 63
0 votes
1 answer
43 views

After response from future callout how we can update the field value in record, can you please assist

here I'm calling below class from the trigger and getting response from external system as well whether my regNo is blacklisted or not, but after saving the record how we can update the status basis ...
user avatar
  • 9
0 votes
0 answers
26 views

Error while deleting record on update using trigger

when i am updating a checkbox using record page a trigger is running on update which is deleting the recently updated records. The trigger is running fine but after deleting a record its showing me ...
user avatar
0 votes
0 answers
47 views

Apex Trigger - Write a trigger on contact to prevent duplicate records based on Contact Email & Contact Phone

I am trying to make trigger with best practice i.e. by creating Handler class. I am not getting what should be done in this scenario. I have written some code as per my understanding. Kindly check and ...
user avatar
  • 3
-6 votes
2 answers
41 views

Getting error in trigger recursion for example if I create account and than update it. It will give me the concatenation of both insert one and update

Trigger accpre on account(before insert, before update){ list<account> acclist=new list<account>(); for(Account acc:Trigger.new){ if(acc.phone!=Trigger.oldMap.get(acc.id)....
user avatar
0 votes
1 answer
24 views

how to invoke a trigger manually in salesforce

Is there a way to invoke triggers manually using apex code. (not by updating field values for the record using ui or code)
user avatar
0 votes
0 answers
9 views

Need to Create Test Class for Apex Trigger that Prevents File Deletion if Attached to Opportunity [duplicate]

Need to get Code Coverage up, and not sure how to write a test class for this. Code below. Thanks for your help! trigger PreventOppyFileDeletePROD on ContentDocument(before delete) { if (Trigger....
user avatar
1 vote
1 answer
30 views

Swap 2 "Unique" values in a single transaction

Scenario: "User" Object has a field "UNEQ" which is setup as Unique. Object "ABC" is adjusted in an Enhanced List View, which causes "User" to be adjusted via ...
user avatar
-2 votes
1 answer
32 views

How can I show the Result with the trigger that I created?

So, I'm studying Apex Triggers in Salesforce with a practical exercise. As long as I was developing the exercise, I thought at my logical code, but when I tested the components, I had a problem with ...
user avatar
0 votes
0 answers
29 views

UNIT TEST TRIGGER - Coverage Test Trigger and using System.assertEquals [duplicate]

Hello, I'm new to salesforce and I have a problem with test coverage and System.assertEquals My coverage is insufficient And I get this as an error: Errors : System.AssertException: Assertion ...
user avatar
-3 votes
1 answer
30 views

Variable does not exist: Trigger

Could you please let me know what i am doing here here, it would be a silly question for most of them sorry, I am actually completely new to this development so trigger AccountContactAddressUpdate on ...
user avatar
0 votes
1 answer
46 views

Not able to fetch the newly created child record id from the newly created parent record in Apex Trigger

We have a scenario, where 3rd party system send us the data to salesforce and using that data we are creating new parent object record along with its child record and we are able to create it. Problem:...
user avatar
-1 votes
1 answer
26 views

Trigger getting Coverage on Insert but not Update

Why This Question is Necessary: It is clear that this question get's asked quite a bit on here, but the examples in other questions are oversimplified (for example the post had a "redundancy"...
user avatar
  • 1,268
1 vote
1 answer
33 views

Trigger After update doesn't show custom exception message

I created a trigger that throws an exception when the Order do not have the required attachment types. I would like the message 'Required document types were not found' to be displayed to the user. ...
user avatar
  • 79

1
2 3 4 5
152