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

learn more… | top users | synonyms

0
votes
1answer
14 views

Case Duplication on After Event

I took this code from cookbook but the problem is it's throwing error message before the record gets inserted.Do we have an option of writing an trigger including (Before and After events ).While ...
1
vote
1answer
41 views

Test Apex Class Error: Error: Compile Error: Expression cannot be assigned at line -1 column -1

I am playing around SFDC and wrote a trigger to count the total Contacts in the system. I wrote the test class and when I am trying to save the class I get the following error: Error: Compile ...
-1
votes
1answer
41 views

Trigger to update a custom field on Lead based on the latest campaign member status [on hold]

I need a help with a trigger that would update a field (custom) on Lead called "Recent Campaign" ( Type = Text) with the latest campaign name based on latest "Member Status Updated" of its Campaign ...
0
votes
0answers
19 views

Trigger is not running from testclass

I have to triggers in my task object. 1st trigger which is inactive and 2nd trigger which is active and calling different class method on insert, update, delete. Now I wrote a test class for the ...
0
votes
1answer
18 views

Check if the value was changed in the original object in a trigger

I'm writing a rollup trigger to update a field at account level based on some criteria. Let's say there's a boolean field with true/ false values. Should I check if the value has changed at original ...
1
vote
1answer
24 views

Missing FolderId in Chatter Trigger Test Class

We created a trigger and test class: when a new record under Keyword object is created, we want an email notification sends out automatically to record owner and confirm we receive his keyword ...
2
votes
1answer
38 views

Restrict converting lead is user is not owner

I have validation rule and trigger where i need to restrict users from converting lead if they are not the owners, both of them doesn't seems to work..what was the issue? Validation rule: AND( ...
2
votes
1answer
36 views

Are static variables reset per batch during bulk DML operation? (Executing triggers for field updates)

A while back I had a trigger issue where I needed a trigger operation to execute exclusively on the second update or an update after an insert. So I had some code like this: Trigger Handler Class ...
2
votes
3answers
89 views

How can I convert formula to APEX trigger?

I have already exceeded my 5000 compilation code, now I want to create trigger for following formula from custom object. Formula 1 (Custom Field = Package Fee) IF(ISPICKVAL(Package_Option__c,"One ...
2
votes
1answer
49 views

Trigger Before Insert - Comparing to Lists

I have a set of records I would like to load into my Account object. I'm trying to write a trigger before insert/update to validate the Bus. Id and Account Name already exists in SFDC or not. ...
1
vote
3answers
41 views

Can interdependent Rollups, Formulas and Triggers cause hard to reproduce bugs?

Let me try to ask this with out explaining my overly complicated case in detail. I have custom objects that heavily use formulas, rollup summaries and triggers. For the last days I am chasing hard to ...
-1
votes
0answers
26 views

Creating a unit test for a trigger

This is my first stab at creating unit tests so I am learning a lot as I go. The first block of code below is the piece that I have been focusing on creating test coverage for and below it is the ...
0
votes
0answers
11 views

SINGLE_EMAIL_LIMIT_EXCEEDED [duplicate]

I wrote one trigger for sending mail to admin account. " SINGLE_EMAIL_LIMIT_EXCEEDED". anybody knows the solution? trigger MailToAdminAfterDeletingEmployee on Employee__c (after delete){ ...
1
vote
2answers
22 views

Find if records exist with custom field comparing and as little SOQL as possible

I'm writing a trigger that needs to create a record based on a newly inserted one. The trigger I have now works, but only for small amounts of records. The problem is where I need to check if there is ...
1
vote
1answer
41 views

Duplicate case closed and its case comment need to be added to previous case

can we achieve this scenario ?any help is very much appreciated. Duplicate case closed and its case comment need to be added to original case??? Some Code written : trigger CasecommentTrigger on ...
0
votes
3answers
37 views

Unit testing a trigger - expecting right curly bracket, found 'insert'

I am creating unit tests to test a trigger that makes a calculation with particular variables depending on the value of a different. I believe the code below is correct, however I cannot figure out ...
2
votes
1answer
73 views

Mass update: Required field is missing

I deployed a trigger and trying to update all records to populate custom field of existing records with value ( account object ). Everything works perfect unless I get the following error: ...
3
votes
1answer
63 views

Create Chatter Post and @mention User in Trigger

I have a trigger that creates a chatter post after insert or after update for Tasks. However, I also want to @mention the created by user for the task. How Can I add this? Thanks trigger ...
2
votes
1answer
34 views

triggers on opportunity stage and probability to prevent the opportunity stage from regressing to a lesser value

For example, probability is high like 70% and it will not revert back with decreasing of probability. Like negotiation review - 90 And it will not back to Value proposition - 50
0
votes
1answer
34 views

lookup realtionship in triggers between two objects

for example in a lookup relation,customer object is a parent,bike object was child, both have same amount__c field ,when we enter the amount__c value in customer obj automatically update the amount ...
-1
votes
1answer
26 views

how to get theprofile name in triggers when saved? [closed]

one user have four profiles and one custom object with one field each time when the record is saved for the fifferent different prifiles,after it saved it shows with the profile name in salesforce.
1
vote
3answers
77 views

You have reached the maximum number of 10 object references on Case

While creating a validation rule the have got this error(You have reached the maximum number of 10 object references on Case), can i have a trigger used instead.
1
vote
1answer
42 views

Apex Deployment Issue from third party app

When I try to deploy a simple apex trigger and test class, I can't seem to pass due to third party app called accounting books. I tried to pass these trigger and test class from other Salesforce ...
2
votes
1answer
54 views

Email notification trigger upon deletion of a record

I need to write a trigger that sends out an email notification whenever an account, lead, and contact is deleted. Also, what is the best test class to write in order to get 100% code coverage? Here ...
2
votes
1answer
42 views

Help with Trigger logic

I am in the process of writing a trigger to create a child record when a parent record is created. I have it mostly working but need some help. Below is my code: trigger AutoCreateCommission on ...
0
votes
0answers
38 views

Error “System.String Exception: Invalid Id :Second External Entry Point ”

Getting This Error For Only 1 Specific Record this is my Trigger It is Working fine for 500+ Records but, Only for One Record I Am getting this Error trigger Create_Payment_Schdule on ...
1
vote
2answers
81 views

how can i populate an account field based on the account that a child record belongs to

I want to be able to take the child record id look up the parent id and take this parent id and save it into the lookup field for the parent, for illustration: a case with account lookup and asset ...
1
vote
3answers
85 views

Trigger to Auto Delete Records

We use MailChimp Salesforce App. Only thing that sucks about this app is that it creates records that are populating our database. I manually export records and do a delete through Jitterbit or ...
1
vote
2answers
31 views

Using a Workflow Rule to notify of Contact changes

Is there a way to create a workflow rule to send an email every time a contact's last name change or home address changes? Or would I need to create a trigger for this?
5
votes
1answer
84 views

'After' trigger's SOQL - will query fetch current value of the inserted/updated record?

I want to get data from children objects and populate field at parent object. I used after insert & update trigger to get the information. If I run a query on inserted/ updated object in a ...
0
votes
2answers
94 views

Help me out with Apex Test class for the Apex trigger

Can any one help me out with this Test class written for this trigger is right or wrong.The Test class get saved but unable to see the code coverage. Here is the Code for the TRIGGER : trigger ...
0
votes
0answers
37 views

Test class for trigger

I have below trigger on feeditem which i tried for test class to write am unable to cover all the fields in the trigger .because of that unable to meet criteria of salesforce. trigger ...
0
votes
2answers
48 views

How to write && in apex if statement?

In apex, what is a proper way to write && condition? trigger CreatePTOEvent on Thrive_HR_PTO_Request__c (after insert) { // Event is created when PTO Request record is created ...
2
votes
1answer
28 views

Related Event not showing up on Custom Object Related List

I am trying to auto create Salesforce Event record when a custom object is created And here is my code: trigger CreatePTOEvent on Thrive_HR_PTO_Request__c (after insert) { // Event is created when ...
0
votes
1answer
26 views

set custom field value to other field of same object

I am trying to set the value of one object in a custom object to be the same as the value of another object before deleting the first object. When I use the assignment operator, nothing happens ...
1
vote
1answer
30 views

get a custom field from a lookup relation

I have a custom field in my account called Priority (picklist) I have a lookup to Account in a custom object called Customer. I want to access Account.Priority but it always returns null even though I ...
0
votes
1answer
33 views

Update delete event in same trigger

Please let me know the reason for record captures for delete operation failing here. Code: trigger AccountHistoryTracker on Account (after update,after delete) { ...
1
vote
2answers
26 views

Increment value of the field by Time (bi-weekly)

I am trying to increment the value of fields over time. Basically, bi-weekly it needs to increment the value multiplied by another field value. Is there "Case" or "Switch" in Salesforce? This is ...
0
votes
0answers
34 views

Change custom lookup on object through trigger

I'm trying to create a trigger that will remove a custom object called customer when another customer with the same first name, last name and title (MR, MRS, Miss) is added, so only the second entry ...
0
votes
1answer
26 views

Opportunity Trigger

I have the following trigger: trigger UpdateOpportunity on Opportunity (before insert, before update){ Opportunity[] oppQuery = [SELECT ID, RecordType.Name, StageName, Win_Reason__c, ...
1
vote
1answer
24 views

PHP API Triggered Send

I am trying to create a triggered send using the API with PHP. The soap call is registering, however, i don't believe the function is registering correctly. I have a Triggered Send Definition ...
0
votes
2answers
37 views

How can I edit this trigger to only fire once?

The trigger creates a related record when a checkbox is updated. The problem is it is creating a new related record everytime the record is edited. I want to edit the trigger to only create the ...
0
votes
3answers
32 views

Salesforce trigger prevent duplication

I have written a trigger which prevent duplicate name. please refer following condition. "Test" and "Te st" are same name (which mean don't need to consider any in between spaces.) "TEST" and "test" ...
0
votes
1answer
23 views

Trigger not Updating Associated Record

The trigger below was created to update a custom check box field on the standard account object called "Billed" when a field called "Balance is 0.00 in zuora" is true. The issue is that field is not ...
1
vote
1answer
25 views

Master-detail: submit a child record with no master ID, let BeforeInsert trigger populate it?

I have a child object in a master-detail relationship. If I insert a child record with no parent ID value, but I write a BeforeInsert trigger to populate the parent ID, will Salesforce allow the ...
1
vote
2answers
40 views

Tally the number of items in a related lists on a related object

Hi guys I am a complete n00b with SalesForce.com, so please forgive me if my question is too basic, but I have been trying for about 2 days now and I feel like I am getting nowhere I have a database ...
3
votes
2answers
71 views

How to run a trigger only for specific record types?

I have a trigger in place that runs for every order record created. I need this trigger to only run when for specific record types. I am not sure if by my trigger and test class needs to be updated of ...
0
votes
1answer
31 views

Validation Rule: Voiding Order

Kindly help me construct my validation rule here AND( ISCHANGED(Status__c), OR( NOT(ISPICKVAL(PRIORVALUE(Status__c),"Draft")), ISPICKVAL(Status__c,"Void") )) Description of ...
0
votes
1answer
23 views

Field History Tracking via a Customer Object for a Custom Object

Follwoing this post What is the best workaround for the 20 field history tracking cap? I have tried to adapt it for my custom Object MPG__c where I want to track all fields. Tracking via field sets ...
0
votes
2answers
36 views

Trigger to update two fields cross objects

I am trying to update contact record field through Student custom object that once in Student object active field is checked than the active field in contact for that record should also be checked. I ...