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

learn more… | top users | synonyms

1
vote
1answer
26 views

Apex trigger not working

I have tried to set the name field of the Volunteer Job object to the case number or an auto increment number and neither seems to be working. I have tried to use a trigger: trigger AddCaseNumber on ...
1
vote
1answer
10 views

Dereferencing a Null Object error

1) This method "ConverttoInventory" is called via Custom Button on Page Layout. 2) The following below is a helper class whose static method "ConverttoInventory" is called with "Merchandise Id" ...
1
vote
1answer
18 views

Apex Trigger - Query on Execution

I would like to do understand the following trigger execution. trigger MerchandiseTrigger on Merchandise__c (before insert) { Merchandise__c[] m = Trigger.new; for(Merchandise__c mer ...
0
votes
1answer
18 views

Traverse Parent Object on Map Get Method

I'm looking to retrieve the string value for the Inventory_Stage__c field in the following logic. The code is incomplete, but I'll post the relevant stuff of what I have. Any help in doing this would ...
1
vote
1answer
27 views

Updating OpportunityLineItem fields issue

I've written a trigger that updates some fields on the Opportunity Product object with Product values when the Opportunity reaches 95% probability. The trigger works when I edit and save the ...
2
votes
2answers
42 views

Bulkify Unique check Trigger

I have a trigger on a custom object (Contact_Communication_Method__c) that checks if a Contact already has the specified Communication_Method_Type__c. I am having a hard time changing the logic so ...
0
votes
3answers
50 views

Assertion failed, expected null

I'm currently trying to test my trigger but it keeps expecting null instead of date.today(). Can anyone help me? Trigger: Trigger UpdateLastSurveySent on Case (after insert, after update) { ...
1
vote
1answer
147 views

Best Practice on Triggers

I have the following trigger logic built in Contact object during Create event. If Mobile Phone is given and Home Phone is not given while creating a contact, then set the Mobile as Home Phone ...
3
votes
1answer
25 views

Best Practices for Validate field in Salesforce

Hi, This is my scenario, - Object Name: Contact . - Field: -Status__c (Picklist) contains: Active ,Inactive or NULL -StatusDetail__c (Text) The requirement is whenever Status not null , ...
0
votes
1answer
31 views

How can I communicate a trigger exception to user in a bulk upsert for each record?

I am performing a bulk upsert with a large batch (sometimes as much as 3000 records at one time). I am splitting the list of 3000 into 5 batches and performing an upsert using the Bulk API. When I ...
1
vote
1answer
21 views

How Can we create a trigger that updates a counter for closed won consecutive opportunities?

We are thinking to have a field under Contact Object that counts the number of consecutive won opportunities. If the Opportunity has the stage "Failure" the counter must be updated to 0 but if it has ...
0
votes
1answer
50 views

Please help me with below test coverage

I have below trigger. And i have one test class. Trigger is Covered 76%. i want to make it more than 90%. The code which is not covered is at line numbers : For Trigger 1 :14,17,25,26,27,32 For ...
0
votes
1answer
29 views

Retrieving Record from Top Level of a Nested For Loop

Still very much a trigger noob, so if there's a more efficient way to accomplish this, please let me know. Basically, this trigger should be creating a new 'In' inventory transaction every time an ...
0
votes
0answers
13 views

on insert/update standard [on hold]

On Lead Insert/Update ensure that standard mailing address is same as custom mailing address and vice versa. Below are the custom fields created. If you insert/update lead standard email address ...
6
votes
1answer
82 views

Is it possible for two users to update separate records in the same transaction?

This requires a little context... I want to create a trigger that only fires when one record is being updated. It's a trigger that shouldn't be fired with bulk data manipulation. I've set it up so ...
1
vote
1answer
26 views

Custom Object Creation Trigger failing in Test only due to null Opportunity.Account.Name value

We have written a trigger that creates a custom object Opportunity Labor upon the insertion of an Opportunity. It works quite well in all aspects in the Sandbox, though fails during Apex testing due ...
2
votes
0answers
32 views

Sharing Records

I have an org that was recently updated to API 32, which broke some triggers that create Sharing Records. This code worked previously to the update to API 32. public void ...
0
votes
0answers
18 views

How to restict user from deleting activity history for all the objects [on hold]

Remove ability to delete activity history and notes and attachments from all the objects and display Custom message
2
votes
1answer
33 views

writing a trigger to mention reporter of a case

i have a tough time with Salesforce. How do i go about writing a trigger to specify the person who created the case as the reporter in the "reported by" field? this is code i have written trigger ...
0
votes
1answer
32 views

System.ListException: Duplicate id in list in Trigger

I get System.ListException: Duplicate id in list error in my trigger code. i haven't used single list in code. i used Set and Map in all places. Following is my trigger. trigger ...
1
vote
1answer
40 views

Rollup Summary to Calculate Weighted Average

As a child (master-detail) to my opportunity object, I have a custom object 'Transactions'. Each transaction has its own interest rate, transaction date, and amount. The opportunity has a term (in ...
0
votes
0answers
15 views

Invalid field isActive for SObject User in trigger (before update)

Can you please help me figure out why is the following code giving this error: 'UserBU : UserBU: execution of BeforeUpdate caused by: line 9, column 21: Invalid field isActive for SObject User'. The ...
0
votes
1answer
24 views

Able to perform DML operation on Read only object from trigger running with sharing

I have a trigger which runs with sharing. All I am doing in this class is updating or inserting another sObject on afterInsert or afterUpdate. Trigger is running in system context Profile/user used ...
0
votes
0answers
20 views

How to prevent email triggering goes to Enduser for adding new field to case page [closed]

I need to create one new field in case page, if i create new field on case page the Emails goes to End users,How to prevent those emails to End user.,Thanks in advance
1
vote
3answers
37 views

Unit test for trigger SOQL query that is uncovered

I'm having an issue finishing up my unit test, and I think it is related to the SOQL query in my trigger. The trigger itself checks to see, upon Lead creation, if a Contact exists with a matching ...
0
votes
1answer
28 views

Trigger to Update picklist value based child records picklist value

I have two custom objects Sale__c and Project__c. Both Sale__c and Project__c have different status in a picklist. Sale__c status is broken into two picklist Status__c and Status Detail__c ...
2
votes
2answers
35 views

Code Coverage 70% but I can't figure out how to make it to 75% or 100%

I am new to triggers. I will admit that but this is my first trigger and I really want it to work! My problem is that I still am receiving only 70% Code Coverage when the trigger works fine in ...
2
votes
1answer
16 views

Chatter Answers trigger not available in Eclipse - no access to trigger I know is there

I need to correct a known issue with Chatter Answers and one of the triggers that needs modification (chatter_answers_question_escalation_to_case_trigger) is unavailabe in Eclipse, i.e. I can't access ...
1
vote
1answer
30 views

Accessing lookup fields within trigger context

I have a custom object Customer with a few fields. One of the fields is a Lookup field that refers to a standard object Account. I'm writing a trigger that should fire before each insert/update. The ...
0
votes
0answers
23 views

How to write a trigger to send an email notification to author whenever a thumbs up/ down voting or a comment is given on a Published content?

How to write a trigger to send an email notification to author / designate whenever a thumbs up /thumbs down voting is done on a Published content? This following trigger doesnt work.It doesnt fire ...
0
votes
0answers
9 views

How to write a trigger to send an email notification to author / designate whenever a thumbs up /thumbs down voting is done on a Published content? [duplicate]

How to write a trigger to send an email notification to author / designate whenever a thumbs up /thumbs down voting is done on a Published content? This following trigger doesnt work.It doesnt fire ...
0
votes
1answer
30 views

APEX trigger error on Account Level Only

I'm new to coding and my developer friend and I have this APEX trigger to update a custom field on opportunities, based on recently created tasks. However, we can't create a task on the account ...
2
votes
0answers
30 views

Code coverage is 70% and I get a DUPLICATE_VALUE issue

Code coverage is 70% and when I dive into the problems I get a duplicate error. Please help I am new to writing triggers. Thank you ahead of time! Problem on several Lines Message: [object ...
0
votes
1answer
19 views

increment in number of calls field when task is completed through trigger?

trigger totalnumberofcalls on Task (after update) { Set<id> leadid = new set<id>(); for(task t:trigger.new){ if(t.Type=='Call' && t.Status=='Completed'){ ...
1
vote
0answers
18 views

Need to send a pdf attachment from trigger when a update happed

I have created a trigger on my invoice object when a update happen I want to send a email from my trigger with a pdf attachment. But when I try to update my record I am getting an error. ...
1
vote
1answer
22 views

How can you ensure a feedcomment trigger only applies for cases?

I apologize if this is turns out to be ridiculously easy. I've managed to configure a feedcomment trigger that behaves as desired except for a big point: we need it to either: - Only apply within ...
2
votes
0answers
45 views

No test coverage on after insert trigger

I can't quite tell why code coverage is saying that there are 0 lines covered. My objective is that every time an Award is inserted, an Award Judging Criterion is inserted with a link to the Award. ...
3
votes
2answers
70 views

List Exception Duplicate id error

I get an error in my trigger when i tried to insert bulk data from data loader. Error is : ERROR: SubscriberUpdateTrigger: execution of AfterInsertcaused by: System.ListException: Duplicate id ...
1
vote
3answers
103 views

Problem with System.assertequals in test class code

I have below trigger code : trigger updateopportunities on Account(after update) { Set<Id> accountIds = new Set<Id>(); for(Account ac : Trigger.new) { ...
0
votes
1answer
14 views

Error: Compile Error: Loop variable must be of type SOBJECT:Account

When I try to write a trigger on my account object I am getting an error. Error: Compile Error: Loop variable must be of type SOBJECT:Account at line 3 column 17 My code : trigger ...
0
votes
1answer
25 views

delete trigger not removing last value

I have a trigger that copies values from child records to a field on the parent record. The trigger runs on insert, update and delete. The problem is occurring when I try and delete the last child ...
2
votes
1answer
40 views

Cannot use @istest in Apex Triggers

I'm brand new to Apex/Salesforce development, and am attempting to create some Apex triggers and tests. Each time I try to add a new class, when I start it with @IsTest I am unable to save it. I see ...
0
votes
1answer
18 views

Confirmation Dialog to Run Trigger on a picklist.

I have a pick-list on accounts that when a certain stage is selected and saved, all oops are cancelled (via trigger). Is there a way to add a confirmation after selecting the stage from the pick-list ...
1
vote
2answers
15 views

Apex Managed Sharing Rule to share master object after insert of detail object

I am developing a team model like Opportunity Teams for a custom object (e.g. CustomObject). I have developed the necessary objects and fields. I have also developed a Visualforce page to create the ...
0
votes
1answer
18 views

Lead assignment round robin based on lead source

i want to implement round robin for lead assignment but it should only work based on a lead source value . only should run when lead source is equal to facebook . can any one suggest me what would ...
0
votes
2answers
25 views

help in multiplying values in Two Fields & display in 3rd Field in trigger

help in multiplying values in Two Fields & display in 3rd Field Request help in multiplying values in Two Fields (UnitPrice__c & QuantitySold__c} & display the value in edit mode in 3rd ...
0
votes
0answers
12 views

Task are not getting updated

Standard salesforce functionality: when Parents Owner gets change related tasks Assignee gets updated with parents Owner. In my case: I have after update trigger on account in which when account owner ...
6
votes
2answers
162 views

Are inactive triggers counted against test coverage?

We are in process of deploying a project to PROD and found that test coverage is coming up less then 75%. There are some triggers we have merged into single trigger. Question is: whether the ...
4
votes
1answer
103 views

Why does this call to Trigger keySet() throw a null pointer exception?

I have a simple trigger like: trigger littleTrigger on Custom__c (before insert) { Set<Id> idSet = Trigger.newMap.keySet(); //Some stuff } Why could the second line throw a null ...
7
votes
2answers
133 views
+100

Checking 'Correct' Previous value method in Trigger design best practice

One of the most common questions on this forum is around trigger recursion. There are a few standard ways to prevent recursion. My method of choice when it comes to checking for field changes, is ...