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

learn more… | top users | synonyms

2
votes
1answer
30 views

Internal Salesforce.com Error in a trigger when upserting Records

Actually i was trying to understand flow, that's why i have create this trigger. I have created a CSV with 4 Records having 2 existing Records (which have another field changed value), 2 new record. ...
4
votes
2answers
37 views

Null Pointer Exception add AccountId to WhatId for Task

Trying to build what I thought would be a simple trigger: when a task is created that is only related to a contact (WhoId = contact type, but WhatId = null), relate the task's WhatId to the contact's ...
2
votes
1answer
29 views

Help testing a case standard object trigger

I need help testing a trigger written against the Case Standard Object. It keeps failing at 74% and I don't understand why? Here's what I have... any & all advice is appreciated. TRIGGER trigger ...
3
votes
1answer
31 views

Possible to trigger an Outbound Message upon Attachment uploaded with specific naming syntax? [on hold]

Good afternoon! Looking for broad idea collection around the concept of triggering an Outbound Message upon an upload of an Attachment -with either a specific filename or a certain naming syntax- to ...
2
votes
1answer
29 views

Test coverage for FeedItem

I'm trying to get my test coverage up and I'm having a few problems to get it done. I have a trigger that will call a class every time a user inserts or updates an event. If that event contains an ...
0
votes
1answer
27 views

Task completed: Email Alert

I have a Service Cloud in which: a User A owns a Case X; a User B receives a call about the Case X; the User B creates a task of type "urge" on the Case X and sets it as "completed" (the User A is ...
2
votes
2answers
56 views

Basic Trigger Help

Could someone help me with this basic trigger? When a new task is inserted, I want to update the Status field in the lead to match the CallResult field in the Task. Here is my broken code: trigger ...
1
vote
3answers
61 views

Trigger between 2 independent objects but fields are same

I have a requirement to update CampaignMember field by comparing a custom object which is not link to Campaign Member table. But the fields are same in both the objects. My scenario is when the ...
0
votes
0answers
10 views

Email trigger on timer basis [duplicate]

Could we write workflow to trigger email in case object without having DML record created or modified perhaps timer basis?
4
votes
2answers
92 views

List has no rows for assignment: Trigger that shouldn't fire when there are no rows

sorry for the vague title. Essentially, I have a trigger I've created to change ownership of an opportunity based on some business rules our company has. When a sales user places a call to a ...
2
votes
0answers
27 views

How to allow Partial Commit on a Before/After Insert Trigger?

I'm having the following problem: I have a before Insert trigger on a Custom Object and we have to permit partial commit, meaning if they insert 3 records Ok and just 1 or 2 with errors at the same ...
0
votes
1answer
35 views

Roll up Summary via trigger for lookup relationship

I am trying to get this trigger to work but it is giving me an error and I am not able to figure out why. The error I am getting is "attempt to de-reference a null object) Why trigger? We have a ...
1
vote
2answers
70 views

“Bulkify” trigger updating parent object

My trigger currently looks like below: trigger UpdatePEPending on Price_Authorization_Extension__c (before delete) { //This trigger is to change the PE Pending field on the Price Authorization to ...
0
votes
2answers
36 views

Need help raising Code Coverage

I've been working on a trigger to auto-populate some information that goes into our company's Tasks. I have come up with the following trigger/test class but can only seem to get Coverage around 45%. ...
0
votes
2answers
17 views

Error: Compile Error: expecting a right parentheses, found 'Id' at line 8 column 31

trigger accountTestTrggr1 on Account(before insert, before update) { for (Account a: Trigger.new) { List < Contact > contacts = [select id, salutation, firstname, lastname, email ...
-1
votes
1answer
13 views

Error Error: Compile Error: expecting a right parentheses, found ';' at line 7 column 17

trigger accountTestTrggr on Account (after insert, after update) { List<Account> accountsWithContacts = [select id, name, (select id, salutation, description,firstname, lastname, email from ...
1
vote
3answers
20 views

What is the API Name of Remainder Field in Task?

I am creating a task via trigger which is working fine, but how to update this remainder field value via trigger. even in page layout also it is not visible and in "Task fields " also it is not ...
0
votes
2answers
41 views

How do i get data from a related list (custom object) so i can display it in a text field in Case object

I have a custom object with the name RepairLines RepairLines have a master-detail relation to Case I use the standard Case system where i have a custom text field named Repair In a Case trigger i ...
-1
votes
2answers
31 views

When can we use Trigger Context Variables?

What are the events where we can use Trigger.old and what are the events where we can use Trigger.new? For example, can Trigger.new can be accessed in before insert, before update, before delete, ...
-1
votes
1answer
18 views

Error: Compile Error: No such column 'color__c' on entity 'Product2'

trigger oppLineTrigger on OpportunityLineItem (before insert) { // For every OpportunityLineItem record, add its associated pricebook entry // to a set so there are no duplicates. Set<Id> pbeIds ...
1
vote
3answers
65 views

I Want to Write this Trigger as Bulkify How Should do that?

trigger ChildtoParentUpdate_Conidtions on Opportunity (before update) { for(opportunity opp:trigger.new) { if(opp.stagename=='Closed won') { ...
-2
votes
1answer
19 views

Error: Compile Error: unexpected token: 'map' at line 3 column 0

trigger StudentIdnew on Account (Before Insert) { map<Account,Account Number> map1=trigger.newmap; for(Account a : map1.values){ if(a.AccountNumber == null){ ...
-3
votes
2answers
39 views

Getting 0% code coverage for following trigger [closed]

trigger Risk_NegativeQuantity on OpportunityLineItem (before insert) { if(Trigger.isInsert) { set<id> oppid = new set<id>(); for (OpportunityLineItem oli : ...
1
vote
2answers
35 views

Apex Trigger test Class Issue; No Standard Price Defined

Here is my Apex Trigger trigger ProductNameTrigger on QuoteLineItem (before insert) { list<QuoteLineItem> plist = new list<QuoteLineItem>(); for(quotelineitem q : [select id, ...
2
votes
1answer
53 views

SObject row does not allow errors in Salesforce before trigger

I wrote this logic inside a before insert/update trigger to apply a validation logic. But I am getting error saying - SObject row does not allow errors. Althought the text inside addError is ...
2
votes
0answers
25 views

Centralize Object Initialization - (Insert Event with Attachment on same code)

I have a piece of code that sets a Boolean (has_Attachment__c) field to true in an After Insert context variable is executed in an Event in which an Attachment is inserted on the same time. The code ...
2
votes
0answers
24 views

FeedComment insertion does not generate Chatter email

I was able to create an automated FeedItem trigger that fires and automatically replies (from a dummy user) to a user when he/she makes posting. I did not get the typical "commented on your post" ...
2
votes
1answer
25 views

Trigger isTest coverage stuck on 61%

I have already spent few hours trying to figure out why I'm stuck on 61% and try to add or remove the test methods but no avail. I have the following test class that is only getting 61% coverage on ...
1
vote
2answers
31 views

Error on Refreshing Detail Page

I am trying to update an Field when i am refreshing a detail page. I am getting this error "Content cannot be displayed: DML currently not allowed" VisualForce Page: <apex:page ...
0
votes
1answer
10 views

Future geolocate method rewrite not updating record

I followed some advice on how to avoid the future callout 51 error. I turned the code into a list, and within the future method I add it to a map, and once loop is done I update the map. However ...
4
votes
1answer
108 views

Using Integers in SOQL For Loops - Apex CPU time limit exceeded

I need to insert Monthly Revenue Forecast records for each Opportunity that's been inserted / updated, matches my criteria and caused the trigger to fire. When I execute the below, in bulk via a test ...
1
vote
1answer
29 views

Field on Account to act as Rollup Summry field

I am trying to develop an apex trigger which will give me total amount of all child objects amount and it will act as a Roll up Summary field. I am getting below error, Variable does not exist: ...
0
votes
1answer
25 views

Trigger Execution order/context

In one of my Custom object, there are 4 triggers.( I know, ideally there shuold be one but there are present for long time and we might need some time to correct and put everything in one code) ...
0
votes
0answers
23 views

Track the time-stamp when the lead status was updated and display time spent on each status

I want to create functionality on Lead status similar to Opportunity stage tracking and track the time-stamp when the lead status was updated and display time spent on each status. Let us consider a ...
0
votes
1answer
35 views

Retrieving multiple results from a Map on a Trigger

I have created a trigger on a custom object that is going to be used to store Lead data, when this information is initially inserted to the object the trigger creates a Map of current Lead and ...
0
votes
1answer
30 views

Trigger on Object when lookup field is modified

I have a custom Object MyObject__c which has one field Contact__c lookup on Contact object and trigger on it. I want trigger to update ContactName field of MyObject__c when ever Contact object is ...
2
votes
3answers
45 views

Trigger Help - Similar to Roll Up Summary

I have several opportunities, which all have a record field assigned to a specific project. The project, which they are assigned to is mapped through a look up field. My goal is to create a trigger, ...
1
vote
0answers
29 views

Validation rule preventing initial update [closed]

I have a custom object (S&E) that has a field that is essentially "update_locked". This custom object gets created when an Opportunity goes to Closed Won. The S&E object trigger fires on ...
1
vote
3answers
89 views

Number of times contacted/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. //Code Starts from here. trigger ...
0
votes
1answer
17 views

Issue creating a list view button in Lead Object which will open new task form

Issue while creating a list view button in Lead Object which will open new task form based lead source is equal to web. Please find the script below. ...
0
votes
2answers
60 views

Help with Trigger Bulkification

I have a custom object opp__c, which has fields contId and role. I wrote after insert trigger where it will be get acctId from contact object. then checks in AcctcontRole with acctid,contId and role ...
2
votes
1answer
72 views

Apex CPU Time Limit Exceeded on Opp trigger

I have a trigger written on Opportunity and I think it's fairly efficient but when I tried to bulk test it, I received the CPU time limit exceeded error. I know I can get around this by putting it in ...
2
votes
2answers
37 views

Passing string of sobject name via trigger on …how to fetch the sobject name of type sobject in class

Passing string of sobject name via trigger on ...how to fetch the sobject name of type sobject in class.. class { method(String operationType,list <Sobject> ,list<sobject>,string ...
2
votes
1answer
50 views

Add result of several calculations to total & store in variable

Maybe I'm approaching this in completely the wrong way but.. In a trigger, I need to calculate an amount multiplied by a % which has been multiplied by an integer. For example if the amount is 100 ...
0
votes
2answers
33 views

List has more than 1 row for assignment to SObject: External entry point

I know that there's already several posts on SE for this error but none of them explain this for me. I'm testing my code by editing one Project Deadline date field, the upProjects size is one and as ...
0
votes
0answers
28 views

Updating, Deleting or Inserting records based on match with Integer

The below inserts a Project Month record for each month between a Project kickoff and deadline date. I now need to update existing Project Month records whenever one of the Project dates are changed. ...
3
votes
3answers
93 views

Making trigger into a custom button

I am new to Salesforce development. I made a trigger that creates a new asset record and autofills some of the fields on said record. What I want ultimately would be a button that I can put on the ...
0
votes
2answers
28 views

Trigger Problems - opportunity-lineitem

i have a trigger code thats updat a custom oppertunity fields with the details of a related product (we always have only one product each oppertunity). trigger PrimaryProduct on Opportunity (before ...
2
votes
2answers
44 views

Comparing Lead/Opportunity Data with a Custom Object

I am writing a trigger for a custom object Data_Vault__c where data such as Company Name and Postcode are entered, this data is then compared to corresponding fields on Lead and Opportunity, if a ...
3
votes
1answer
29 views

How to get the source IP field?

we want to get the source IP field from login history object. We do not know how to get it. We can get the IP but the system randomly chooses a one. Does anybody have any idea? thanks trigger ...