A trigger is an apex code, that can be executed before or after DML operations

learn more… | top users | synonyms

0
votes
3answers
17 views

Bulkify code with Map

I'm still new to map Usage.. How could this code be bulkified? trigger OppyStatusCheck on Opportunity (before insert, before update) { for(Opportunity opp : Trigger.new) { ...
0
votes
1answer
28 views

Can you help me with a trigger adding a contact to a public group?

Here is the code from my trigger which saves without syntax errors but gives the below error when I edit a contact. Code trigger AddToPG on Contact (after insert, after update) { ...
2
votes
0answers
31 views

Multiple Tasks are created. Need only one

I have a scenario,where Business Development Manager(BDM) will conduct promotions on company's products. The members attened for that promotions are added as Promotion members(PMM) Promotion is Master ...
1
vote
0answers
18 views

Test class for feed items in chatter for trigger increment

Test class for the below trigger @istest public class CountChatterPostsOnCase{ public static testmethod void () { for (FeedItem f : trigger.new){ String parentId = f.parentId; if ...
0
votes
2answers
35 views

User created a child record must capture and reflect the child status to the parent record [on hold]

Hello I'm a beginner here in Salesforce so bare with me. I created a Case (child record) with a STATUS field after saving the case it should capture/reflect its STATUS to the Account (parent record). ...
1
vote
1answer
28 views

Database.executeBatch cannot be called from a batch start, batch execute, or future method

I have an after insert,after update trigger on object A which calls Database.executeBatch for insert and update operation which inserts and updates object A records.I have anotherafter insert trigger ...
0
votes
1answer
26 views

Help me to retreive Account data in trigger

I am creating a service record when opportunity is closed won and product code in opportunity line item is null. I am filling the new service record with the values from opportunity line item and ...
6
votes
0answers
43 views

Sending an email from a trigger with an addError

We have the requirement that if a Case is created via email2case and the Account has a flag (SecureSupport__c) checked then we should block the case creation and send a notification to the contact ...
1
vote
1answer
38 views

Trigger to update record on other object

I am new to Apex. The scope of the trigger are 2 objects. Product__c and Specific_Product__c. There is an after insert trigger on Product__c to create a corresponding record on Specific_Product__c ...
0
votes
0answers
47 views

Trigger to perform bulk operations - Associating Parent Child records

I have a trigger(after insert) that works for a single insertion and update and I'm converting it to perform bulk operations - My logic is as below - I have a shadow object (subs_shadow__c) - I get ...
0
votes
0answers
12 views

How to identify the duplicate cases created and close them by adding their case comments to the original case. cases are created through Email

can Any one help me out with this Requirement : How to identify the duplicate cases created and close them by adding their case comments to the original case.These cases are created through Email . ...
4
votes
1answer
24 views

Triggers and order of execution on two different objects

Hi I'm trying to totally wrap my head around how one trigger's execution could affect another. To make things clearer here's a scenario. Say I have 2 objects A and B. Both objects have a trigger each ...
0
votes
1answer
22 views

List is not generated in trigger

While I insert data through data loader and check this debug.Debug log generates only one value for clientIds.So, I am getting only value for objList though I am inserting multiple records for custom ...
1
vote
2answers
26 views

@future method: Unsupported parameter type

I am trying to copy records from one org to other via web services. I am calling a class which has logic written into a trigger. But @ future method is not taking sObject list as a parameter. Can ...
-5
votes
0answers
30 views

Trigger error: SObject row was retrieved via SOQL without querying the requested field [duplicate]

I have a trigger that populates child object's field value when update or insert on Master. Please find my trigger here. Trigger: trigger HCPREFERENCE1 on Depth_Tracker_OAPI__c (after insert,after ...
0
votes
1answer
31 views

Apex error: Initial term of field expression must be a concrete SObject

I have to update bulk records by apex class which is called from an apex trigger. Please find my class and trigger below. Batch class: global class UpdateAccountArea implements ...
1
vote
1answer
37 views

Trigger populating parent object values in child

I have below trigger to populate master record's value in the child based on any update on Master. This code is getting error out for bulk loads. Can someone please suggest a best practice to overcome ...
0
votes
0answers
34 views

Trigger doesn't updates the values using dataloader

Here is my trigger where it updates the Amount and Account fields from opportunity when Opportunity is populated in my custom object OM or it updates Opportunity, Amount and Account if Quote is ...
1
vote
2answers
33 views

How to invoke webservice from trigger without using @future annotation?

The background of the problem is: I am building up a trigger on account which will be triggered when an account is deleted. During execution it will invoke some webservices. But while deleting an ...
1
vote
1answer
44 views

Trigger and Workflow on the same field facing Issues

Hi I have a requirement. I have a custom Checkbox field inside case object say "res__c". When a Email is received then this res__c should be TRUE. And later if the case record is edited, then res__c ...
1
vote
1answer
61 views

Find Duplicate case and close

I shall appreciate ur help. Can anyone help me on this Requirement : Requirement is : 1) Create a case with Subject line (User ) ----First Case 2) Create another case with Same Subject line ...
0
votes
0answers
18 views

Has anybody worked on alternate solution for Account Team Members triggers?

I have a requirement to capture the Account team changes and process them. Unfortunately i can't write a trigger on AccountTeamMember. Is there any alternate solution ?
1
vote
1answer
30 views

Query the cases where case contact = logged in user's contact

for(Case c: [select id from case where ContactId = :UserInfo.getUserId]){ System.debug(c.user.Name); } Am not able to get logged user by case
2
votes
2answers
62 views

ISNEW() Validation rule causing triggers to fail

I created the following validation rule on my contact records: IF( ISNEW()&& ( FormAssembly__c =""&& TEXT(LeadSource)="") && TEXT(Contact_Source_List__c) ="",TRUE,FALSE) I ...
6
votes
2answers
221 views

General trigger bulkification - best practices

A general question asked from time to time on stack exchange is question of trigger bulkification. Therefore I have 2 questions: Which best practices are you using? What is the best way to handle ...
0
votes
1answer
33 views

System.LimitException: Too many future calls: 11 [duplicate]

when i am changing the case owner for more than 10 records in the case list it is throwing the error : Apex trigger LFIQTriggerForCaseChanges caused an unexpected exception, contact your ...
1
vote
1answer
18 views

Increment Public Chatter Posts and Unread Public Chatter Posts

Custom field is created for Public Chatter Posts and Unread Public Chatter Posts trigger CountChatterPostsOnCase on FeedItem (before insert, after insert) { String caseKeyPrefix = ...
1
vote
2answers
30 views

Trigger to assign open tasks back to specific user when account owner is changed

We have a workflow that creates tasks and assigns them to a specific user when an opportunity is closed. It's salesforce standard behavior that when the account owner is changed, the open tasks are ...
3
votes
1answer
29 views

Future method cannot be called from a future or batch method, Case Trigger with Salesforce for Social

I get the following inside a Case Trigger when I try to call a future method: System.AsyncException: Future method cannot be called from a future or batch method So far this exception ONLY occurs ...
2
votes
1answer
58 views

Too many dml rows exception

I tried to insert records for call__c object which gives this exception Trigger: trigger trgInsertCall on Call__c (after insert) { Set<Id> clientIds = new Set<Id>(); ...
6
votes
2answers
174 views

First trigger: coding - best practices

This is my first production trigger and I'm just wondering if there is a more efficient way to write this code. Basically, if a campaign meets the criteria in the IF statement, I want it to create a ...
2
votes
1answer
36 views

trigger to find change in contact role for an opportunity

We have a scenario where we have contact roles added to an opportunity. We need to know if a contact role for a contact has changed for an opportunity. E.g John doe was an executive sponsor first for ...
1
vote
1answer
18 views

Opportunity Amount field rollup lifecycle

I recently experienced odd behavior where a trigger depending on the the Opportunity.amount field was not picking up the correct values from the amount field even though the context was after update. ...
0
votes
2answers
82 views

Too many DML rows: 10001

I have a trigger which performs an insert operation.One record count is more than 10k.So,Its giving this exception.I have tried batch apex and future method.Its is not working.Any help will be ...
3
votes
1answer
91 views

“Expression cannot be assigned at line -1 column -1”

I'm trying to write an Apex trigger that makes a field on the Contact called Meeting Date equal to the Meeting Date field on the Opportunity. For some reason I'm getting an error saying "Expression ...
3
votes
1answer
148 views

Error:System.LimitException: Apex CPU time limit exceeded

I am getting this error: 'Error:System.LimitException: Apex CPU time limit exceeded' for this simple trigger. The trigger is working just fine. Can anyone tell me if I am doing something wrong in the ...
4
votes
1answer
51 views

First time trigger help - am I being a bad neighbor or going to slow my org down?

Ok, my first trigger question was a bit more complicated (First Time Trigger - correct loop to use question). I'm taking a step back to simplify before I attempt the more complex. Good news my trigger ...
0
votes
2answers
35 views

How do I copy products from one Opportunity to another in apex

So I have a trigger on Order in a certain condition I need to create another opportunity based on the Order's current opportunity. It was pretty straight forward except for getting the products to ...
1
vote
0answers
13 views

Salesforce User Licenses valid for Public Groups

There are lots of different User Licenses in Salesforce. I need to know which ones are valid for Public Groups, since otherwise, the trigger that adds a user to a public group upon creation will ...
2
votes
1answer
58 views

Execute method is not getting called

I have called a batch class from a trigger.In debug log start method is getting called.But execute is not getting called. trigger: trigger trgInsertRecord on Custom_object__c(after insert,after ...
1
vote
2answers
191 views

How to avoid recursive trigger other than the classic 'class w/ static variable' pattern?

How can we avoid trigger get executed again and again (recursive trigger)? One way is to have a class with static variable and have boolean value and check it is true or false and changing the boolean ...
0
votes
0answers
28 views

How to achevie this Scenario by writing a code on case object

Can any one help me out with this requirement .Its very Urgent.I shall Appreciate your help. The User A is sending an Email to E2CP address by keeping User B and C in cc list .The mail is recevied ...
1
vote
1answer
40 views

First Time Trigger - correct loop to use question

I'm creating my first trigger (i'm an admin). It creates a new custom object,StakeholderContact every time a contact is created where 1-4 boxes are checked in the contact record. Right now I’m focused ...
0
votes
1answer
38 views

Can't create account using trigger

What I was originally trying to do (create an account for each lead as it was created): trigger LeadCreateAccount on Lead (Before Insert) { Public List<Account> lstAccts = new ...
0
votes
2answers
44 views

Apex Trigger: Variable does not exist

I am creating a trigger on my Opportunties object which on update alters some fields in the object, I also need this to update a related object called RBCO__c. The foreign key used to reference the ...
0
votes
0answers
42 views

Insert contact statement in test class is causing 0% code coverage

I've written a simple trigger to prevent duplication of a lead based on existing leads and contacts. My test has 90% code coverage based on the tests that I've written to prevent lead duplication. ...
0
votes
1answer
28 views

How do I write a test class for the below trigger? [closed]

I have just created the below trigger that is deigned to create a new custom object record(Services) when a custom date field (Service_Date__c) on another custom object (Unit)is equal to "This Month". ...
1
vote
1answer
42 views

Creating and updating a custom field for a Campaign Member

I am trying to send out an email whenever a campaign member's status is updated. I have the email side of it set up and working and am able to call that class from a trigger. Since I do not want an ...
3
votes
1answer
45 views

how to use Sobject in trigger

I have a scenario where the three objects trigger have relatively same logic for beforeInsert and beforeUpdate. Even the fields of these objects that i use in trigger are same. this is my below code. ...
1
vote
2answers
73 views

Error in loop iteration: 'Loop must iterate over a collection type'

Please find my code here. trigger PM1 on Account (after update) { List<Product_Metrics_vod__c> toDelete = new List<Product_Metrics_vod__c>(); set<id> ...