Questions tagged [apex-trigger]

Apex trigger is Apex code that executes before or after operations with Standard or Custom object.

Apex trigger is Apex code that executes before or after the following types of operations:

  • insert
  • update
  • delete
  • merge
  • upsert
  • undelete

on Standard or Custom objects.

47 questions
1
vote
1 answer

Why does SalesForce on before delete trigger delete record before processing?

I have created a trigger in Salesforce : Trigger myTestDelete_D on Account (before delete) { set ids = Trigger.oldMap.keyset(); myClass.Details('Account','delete',ids); } So the steps are I create an account Acct1. I then delete the…
Kylie
  • 95
  • 1
  • 12
1
vote
1 answer

Why i need to set the parentId for each record for Queueable Apex

Hope you are well and doing well in these times,Below is a common scenario to take some set of sObject records, execute some processing such as making a callout to an external REST endpoint or perform some calculations and then update them in the…
Carolyn Cordeiro
  • 1,525
  • 3
  • 11
  • 26
1
vote
1 answer

I've created trigger for below mentioned scenario and I want solution for that. - apex , salesforce

There is two object: Fund and opportunity. and opportunity object has a lookup of Fund. I've developed one trigger that sums up the total amount of all the relative opportunity and set that amount in a custom field of fund object. now a problem in…
1
vote
0 answers

How to create primary contact in account contact role for an account without duplicates

Whenever I'm trying to insert a new multiple contact for single account using dataloader, one primary contact should be inserted in account contact role object. If multiple contacts are there we should consider first contact which is going to be…
siva
  • 11
  • 3
1
vote
1 answer

Apex Trigger - Junction Object

please bear with me as I'm new to Apex and triggers. I have a custom object, Conferences. This custom object is the master to a custom Junction object, Junction. That Junction object is set up to allow me to show a related list of standard…
1
vote
2 answers

Convert Unix time to Datetime in Apex Salesforce

I have requirement to to store the timestamp returned from the response to Salesforce DateTime. But the timestamp returned is in Unix format. How do I convert it to DateTime in Salesforce using apex?
1
vote
4 answers

Apex Triggers - Trailhead

The code itself doesn't give any errors, but anytime I run it Trailhead gives me this message: "Challenge not yet complete... here's what's wrong: Executing the trigger did not work as expected. " Here are the instructions: For this challenge,…
Tyler Pavlovic
  • 13
  • 1
  • 1
  • 3
1
vote
0 answers

Apex trigger for Number of Time Record is Viewed

I am trying to develop an Apex trigger for an Object Lead. Requirement is like count number of times that record viewed. I am Sharing my Code with you. trigger ContactedRecord on Lead (after insert,after update) { List lid=new…
Shantanu Mahajan
  • 199
  • 1
  • 2
  • 14
0
votes
1 answer

Trigger unexpectedly failing (Trailhead - Get Started with Apex Triggers)

I am attempting the challenge at https://trailhead.salesforce.com/content/learn/modules/apex_triggers/apex_triggers_intro?trail_id=force_com_dev_beginner It says: Create an Apex trigger Create an Apex trigger that sets an account’s Shipping Postal…
0
votes
2 answers

How do I make the trigger run after all the data is inserted into the batch class?

I want to use Apex Batch class to put 10,000 pieces of data into an object called A and use After Insert trigger to update the weight field value of 10,000 pieces of data to 100 if the largest number of weight fields is 100. But now, if Batch size…
whytili
  • 107
  • 7
0
votes
0 answers

Apex Trigger that emails user once user is assigned a case

I have a trigger that does a round robin assignment to queue that assigns cases. How would be able to send a custom email to the user once the case is assigned to them via apex? How can I query which user was assigned the last case in the queue? My…
0
votes
1 answer

After Update in Apex Class - Total Contacts "Roll-Up Summary"

I added the Apex Class and Apex trigger below to update the field Number_of_Contacts at the Account level when a Contact is added or removed to a certain Account. My idea is to display in Accounts reports, how many Contacts an Account has. I had to…
0
votes
0 answers

Trigger on opportunity scenario

I want to write a trigger on opportunity there is a field on account Opportunity_Amount__c if suppose Opportunity_Amount__c has value 200 and sum of its relted Opportunities is 160 and you are adding opportunity of amount 60 then it should throw…
0
votes
0 answers

Once Case is created with updated fields, The updated fields should be updated in Account

trigger Ecare_Trg_UpdateContCoreData on Case (after update) { List arcList = New List(); for(Case c: Trigger.New) { if(c.Status =='Closed' && c.Type == 'Commercial' &&…
0
votes
1 answer

How can i bulk update Accounts in Salesforce?

I am trying to update the Description for over 200 Account entities by matching on Salesforce Id. I am using the following trigger , Trigger MyNew_tr_U on Account (after update) { set ids = Trigger.newMap.keyset(); for(ID id : ids) { …
Abbey
  • 153
  • 2
  • 11
1
2 3 4