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

learn more… | top users | synonyms

2
votes
1answer
9 views

Fire trigger only if we update custom field

I have an object in Salesforce called File_uploaded__c with some fields like Filename__c, fileSize__c, IsMain, and I want to know if there's a way to implement a trigger that is only fired when we ...
1
vote
1answer
24 views

Can we create notes using trigger on contact.?

I want to create notes (not attachment) using trigger on standard contact object. I have 1 custom field called as notes__c, which i want to be reflected in notes once trigger gets fired. Is it ...
1
vote
1answer
18 views

Keep track of counter variable that forms part of a programmatically generated custom field in Apex Trigger

I am new to Salesforce and the bulkified logic of Apex development and I am trying to wrap my head around a task I have to accomplish. I am writing a trigger logic , where, for each new inserted ...
1
vote
1answer
18 views

Change account owner on insert/update

I have on the account a lookup field on account named ' '. And two account record types 'RT1' and 'RT2' While adding an account with RT2, I have implemented a trigger to change the account owner with ...
1
vote
2answers
70 views

Avoid recursion in trigger - handling multiple triggers

I'm using this sample code from Developerforce to avoid recursion in triggers. public class TriggerMonitor { private static boolean run = true; public static boolean runOnce() { if( ...
-2
votes
0answers
25 views

Creating a task class for Apex test fails

I have written a trigger that fires after tasks are created with the subject "Activity Report." When writing my test class, I attempt to make a new task and insert it with the following code: ...
1
vote
1answer
17 views

Passing Trigger: Method does not exist or incorrect signature

I'm trying move majority of my code to Apex classes and minimize on the trigger code. When I pass Trigger.old and Trigger.new to class methods, I keep getting this error: Compilation error: Method ...
0
votes
0answers
15 views

How to updated PreHeader in TriggeredSend using SSJS

I am trying to dynamically update Pre-Header in the email associated with a Triggered Send to send email out to subscribers. When I execute the code below, the PreHeader gets updated in the email but ...
0
votes
2answers
13 views

Instantiating an custom object and insert

I'm having problems with my apex code inserting. I don't know whats going on here is my code: // object instance with memory allocation. Work_Order__c wo = new Work_Order__c(); wo.Est_Hours__c = ...
0
votes
1answer
11 views

Calculate days from date

I'm looking a way to calculate the days....this is what the requirement: If the CalendarInterval is 90 days and LastCompletionDate is 04/05/2015 then find the # of days. Here is what I have ...
1
vote
1answer
40 views

Checking whether a Case is closed

I've put together some code to automate the completion of CaseMilestones when the user makes certain changes to a Case. trigger completeCaseMilestone on Case (after update) { List<WEID__c> ...
-1
votes
1answer
13 views

execution of AfterUpdate caused by: System.NullPointerException: Attempt to de-reference a null object

Here is my very super simple code and what I'm trying to do is returning the Id... that's all I'm doing. Getting the following error: Apex trigger test caused an unexpected exception, contact ...
1
vote
1answer
25 views

Trying to update a field after insert of new record

I am trying to set a boolean to true upon insert based on first this logic: if((pr.recordtypeid == '012g0000000D63fAAC' || pr.recordtypeid == '012g0000000D63iAAC' || pr.recordtypeid == ...
1
vote
1answer
24 views

Illegal assignment from Schema.SObjectField - apex code [duplicate]

Do I have to load that in List only ? I'm coming from .Net background and still learning how does the SF works... PS: Schedule__c is a custom object and trying to access the field from. Error: ...
1
vote
2answers
19 views

Should use Workflow rule/Trigger/Apex Code

I'm new to SF and working through my way and I need some recommendation or best practice from people who have been working heavily in the SF. My question is: I have the following requirement: if the ...
3
votes
2answers
37 views

Why is this Apex Trigger throwing a Null Pointer Exception: Argument cannot be null?

This trigger references blank fields, and complex formula fields. The reason I'm trying to do a trigger and not a formula is that it resolves to too many characters because of referenced formula ...
0
votes
1answer
18 views

Trigger error before delete on custom object

I have a custom object in salesforce called : File_Uploaded__c with many fields such as Name, Size, DeletionDate__c and i declared a trigger to set the deletion date when a record is deleted, here's ...
-2
votes
1answer
50 views

Bulkify Trigger

Updated Any better way without looping circuits__c records and checking all conditions again after getting Building__c map trigger UpdateLoc on Circuits__c (before insert, before Update) { ...
0
votes
0answers
20 views

multiple email from email service received [duplicate]

I have written a trigger to send email. Whenever the trigger is fired i am getting equal no of mails which is equal to no of records retrieved. Ex - If i am getting 3 records, three times i am ...
0
votes
2answers
15 views

Post Chatter on Field Change on Update

Can someone help me nail the syntax on chattering on a field update? trigger ChatterCoverageUpdate on Account (before update) { List<FeedItem> feedItems = new List<FeedItem>(); for ( ...
0
votes
0answers
27 views

Trigger upon change in formula field result

I have standard object - ServiceContract, on which there is a formula field Status__c. Lets assume the formula field does this "StartDate__c>=Today>=EndDate__c, status=Active, else status=Expired" ...
3
votes
0answers
18 views

Custom Mapping Parameter File

This is kind of an odd scenario and I was wondering if anyone had seen anything like this before. We have a custom object called Financial_Account__c which stores information about our customers' ...
2
votes
2answers
44 views

Trigger - too many rows

The following trigger works well in sandbox, is validated in production, but when I used email to salesforce, it returns the following: UnexpectedException: MoveAtt: execution of AfterInsert ...
-1
votes
1answer
22 views

How do I disable a trigger condition in a class? [closed]

I am trying to load a raw data to check the functionality of my workflow.It is firing trigger errors.where do I turn off these triggers
1
vote
2answers
40 views

Error on Lookup

i have a new problem, I receive the error message List has more than 1 row for assignment to SObject Trigger.MoveAtt: line 9, column 1 for the following trigger. trigger MoveAtt on Attachment ...
4
votes
3answers
63 views

Error in using multiple @future methods

I have created a Trigger and Class that works in dev environment, but I'm trying to deploy it to production, and it is testing all of my code with all the other classes in the environment. The only ...
2
votes
2answers
41 views

Keep getting this error: System.QueryException: List has no rows for assignment to SObject

I have a Trigger that is referencing a class. It works in Dev, but now I am trying to create the test class in order to push it to production. I am trying to test that a new user is created. I keep ...
0
votes
0answers
25 views

need to invoke class method through trigger for multiple products [closed]

I have a trigger on opportunitylineitem where on adding products it will create a new record in other sobject for each product. when i am adding multiple products at a time it is invoking class but ...
-2
votes
0answers
10 views

Opportunity Product [closed]

My Requirement: User cannot add more than 1 product line to an Inside Opp Either prevent user from adding by disabling add button or provide error message that reads: "This is a inside opp deal ...
5
votes
1answer
117 views

One Trigger to rule all!

I'm trying to make work a trigger architecture pattern that was designed by Adam Purkiss, I believe around 2012. I know that there are other more recent designs but I just want to try this one from ...
2
votes
0answers
29 views

Records created via API not triggering workflow/process

I have Tasks that are automatically created using an app Sidekick, which logs emails sent from gmail as activities. To my knowledge, workflows can usually be trigger by records created via API. ...
1
vote
2answers
52 views

Trigger on Tasks to change Lead Status

I'm trying to create a trigger on Leads that when the Lead Status = 'Open' and a Task is created for that records, as soon as the Task is saved (it doesn't matter if it is completed or still open) it ...
3
votes
3answers
62 views

Apex Test Class Help on a Basic Trigger

I have a basic trigger that creates a child record when a parent record is created, and it works perfectly in the Sandbox. But I can't get the Test Class syntax right in order to push to production. ...
2
votes
1answer
57 views

Case Routing: assigning queue as Case OwnerId-

I have an issue for a case routing process. My aim is to route a case upon creation to a specific queue based on different attributes. I am taking three attributes Product Org, Product and Account on ...
1
vote
1answer
81 views

When to use after triggers

When to use after triggers? I came to know that we use after triggers when depending upon the id of a record, if we are modifying fields of another record. But what is my about means in flow of ...
0
votes
1answer
44 views

The record couldn’t be saved because it failed to trigger a flow - Process Builder

I have one Process Builder which helps me to do certain things on my Opportunity create/update and all. Now, the problem is I have written one Trigger on Opportunity which is expected to run "After ...
2
votes
3answers
42 views

What's the most accurate method to identify which lead is an opportunity/contact/account converted from

Just started to work with the lead conversion. What's the most accurate method to identify which lead is an opportunity/contact/account converted from? Thanks
0
votes
0answers
20 views

Visualforce Email Template: parameter

I am using Vf template for email alert and i am triggering this by a email service in a trigger. But whenever i am receiving email i am not getting any value populated. Can anyone let me know where i ...
1
vote
1answer
40 views

Retrieve all ContentDocument Ids whose related ContentDocumentLink record is updated/added

I want to retrieve File Ids for which new entry has been added or removed from child ContentDocumentLinks relation. Following is the parent to child relationship query I made for retrieving Ids, title ...
0
votes
2answers
29 views

I want to do insert and update at same time on same object on different records

trigger InsertOrderBatch on Batch__c(after update,after insert){ List<order_batch__c> oblist= new List<order_batch__c>(); List<order_batch__c> itemupdateList= new ...
0
votes
2answers
39 views

Before insert with million of records on custom object

Hi we have requirement where an external system will call Salesforce to insert millions of records in a custom object. External System will send contactAddress id in SOAP request. I need to make sure ...
2
votes
1answer
34 views

Trigger on ContentDocument not working

I am trying to setup triggers on ContentDocuments. The following link says that this is possible https://developer.salesforce.com/releases/release/Spring12/contentdocument+triggers I am able to ...
0
votes
1answer
41 views

What is the best practice of chain trigger

I had a scenario about 3 sObjects (Opportunity, CustomProduct, CustomSample). Both CustomProduct and CustomSample had lookup field to Opportunity. Each sObject have triggers (immediately and future ...
1
vote
1answer
23 views

Test class error - Field is not writeable: OpportunityPartner.OpportunityId

I am trying to write a test class for a tigger and ansure why I am getting the following error - Field is not writeable: OpportunityPartner.OpportunityId at line 40 column 68 // test 2: ...
-3
votes
3answers
33 views

Apex Trigger - Picklist Value Updates Separate Picklist Value - SAME Object [closed]

Very basic trigger...2 Picklists, same object (Lead)...Use custom Lead Source Picklist to update standard "Lead Source" picklist, they have exact same values...they should always be in sync trigger ...
1
vote
1answer
71 views

Apex Trigger - Create a child record when a new parent record is created

I'm trying to create a very basic trigger - when I create a Parent Object record, create a Child Object record under it. Here's what I have so far, it saved without errors, but no child record gets ...
0
votes
1answer
32 views

trigger.new and trigger.old collection contain same field value

I have a trigger where I compare whether a field values changes in order to process some code. This has been working fine, but recently with some new code that has been added, the field value is now ...
2
votes
3answers
32 views

Help bulkifying trigger

So I am a total newb here and I am sure I'm missing something easy but can anyone tell me why the key isn't being set thus resulting in a null point exception? trigger Contact_Assignment_ET on ...
3
votes
1answer
48 views

Trigger on opportunity error - Field is not writeable: OpportunityPartner.Role

I'm creating a trigger to update a field depending on a partner role, but receiving the following error. Any help would be much appreciated! Error: Compile Error: Field is not writeable: ...
1
vote
2answers
20 views

How can I trigger some code when a field is changed, but before the record is saved?

I want to detect when a certain field has been changed in the browser, and run some code to clean up the text in that field so the user can see the clean version before saving the changes to the ...