Tagged Questions

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

learn more… | top users | synonyms

0
votes
1answer
10 views

How can I troubleshoot my dysfunctional Trigger-Ready Flow?

Currently following the "Calculate Discounts on Opportunities" in the "Cloud Flow Designer Workbook" (starts on page 26.) I'm 99% positive that I've followed all the instructions exactly. But when ...
3
votes
2answers
90 views

trigger design pattern

I was watching some videos on apex best practises and I spotted some discrepancies in advice people give. I wonder how you people code your triggers. The recommendation is to have one trigger per ...
1
vote
1answer
19 views

Apex Trigger: After Update - need to update fields as part of query

I'm trying to make an email send to all contacts that are on an account related to a contract. To trigger it, I thought I'd have a field update on the record using time-delay workflows, and then the ...
1
vote
1answer
9 views

How to make matching fields (in unrelated records) trigger workflow?

I have professional edition, but we have access to workflows. I would like to trigger a workflow when two contacts in our org have matching email addresses, phone numbers, or names. Any suggestions ...
1
vote
1answer
23 views

CampaignMember AfterUpdate trigger doesn't fire after lead conversion

A Campaign Member After Update trigger should fire after a lead in a campaign is converted, correct? My AfterUpdate trigger is not firing at all in unit testing. I have enabled "Require Validation ...
2
votes
1answer
11 views

Is it possible to launch a flow from an update trigger?

I would like to launch a flow from an update trigger if a field on the object is set to a certain value. Is this possible? I understand that this is possible with the new Lightning capabilities, but ...
0
votes
0answers
31 views

I want to write a trigger between two object without any relationship between them? [on hold]

Please give the solution..................... I create new number field on Oppty Object named Total SE Hours. i want populate this field. This field should act similar to a Roll Up Summary field ...
0
votes
1answer
11 views

Do I have to update an object that will be inserted in a before insert/update trigger?

I have a simple question: in a before update/insert trigger, do I manually have to call update on a field that I want to change values in or, since that object is going to be inserted/updated after ...
1
vote
2answers
25 views

Update Closed Opportunity Owner when validation rules/triggers otherwise prevent changes to closed Oppos

Scenario : If I update Account Owner then I want all its Opportunity Owner should be updated with the same, irrespective of its stage(Closed/Open). I want the new Owner Updations to be made on ...
0
votes
0answers
14 views

Insert Trigger not firing when creating record by REST API

I Have (after insert, after update) trigger on Account sObject. When I manually inserting or updating Account trigger fires, also when I updating existing Account via REST API request it fires too. ...
0
votes
1answer
12 views

Add AccountTeamMember and TeamMemberRole when Account Request Object is Converted

Good evening, I have been at the office since 0700 this morning and it is now 2309. I have the majority of all of the trigger and everything situated for my new custom object except for this last ...
-1
votes
0answers
14 views

I need help with createa trigger which will add null to a lookup field. [on hold]

I have never written a trigger before, need help. There is lookup field in opportunity object which is related to opportunity to lockup for a duplicate record. I need a trigger to add null to ...
1
vote
1answer
22 views

Getting Recursive Error in with test Class

I'm trying to create an update on the account object when someone creates or updates task. I'm not getting enough test code coverage, and I'm also receiving a recursive error when running the test. ...
1
vote
1answer
16 views

Trigger won't execute with duplicate elements

System.ListException: Before Insert or Upsert list must not have two identically equal elements I get this error on a trigger i'm trying to run, I don't understand why it won't allow this create two ...
0
votes
1answer
19 views

Move EmailMessage's attachments from one Case to another

Here's my use case: Existing logic: When an email with attachment is processed by email2case handler, case (Case A) gets created followed by email message and attachment resides with the email ...
1
vote
1answer
11 views

Changing DateField inserts on a trigger

I'm using a trigger to insert a list of invoices to a contract object, what I want to do is for the iterations of the loop have the Effective_date__c have todays date, then the second iteration be for ...
2
votes
0answers
25 views

How can I create a trigger for when a lead has activity?

When a lead has activity and the lead status is new, that it prompts the user to change to lead status to open.
1
vote
0answers
26 views

Help with Apex code to test a triggers

I've have a child entity - Credit Application that is created on the parent entity - Lead(Appointment). After the child has been created, users go in an update information on the banks used for the ...
0
votes
0answers
18 views

APEX trigger to Update Custom field on Opportunity Splits from Opportunity [closed]

Can anyone help me write an APEX trigger to update a custom field on Opportunity Splits from the associated Opportunity record. It needs to update every time the associated opportunity field is ...
0
votes
1answer
30 views

Update field on Contacts attached to an Opportunity

I have a custom Stage field for Contacts that I'd like to be tied to the Stage field in Opportunities when they're attached via Contact Roles; ideally by updating it with an after-update trigger on ...
0
votes
1answer
20 views

Trigger to make @future callout to the Data.com match API

My company uses data.com premium. We want to create a trigger that will update a lead based on company information since the out-of-the-box functionality only matches based on the lead. (contact). I ...
-1
votes
0answers
21 views

Trigger to validate if the update is for rejecting the timecard? [closed]

I have 2 custom objects Timecard (pse__Timecard_Header__c) Period (c2g__codaPeriod__c). Here I want to compare timecard and period but before doing that I want to validate the timecard. Assume there ...
1
vote
1answer
17 views

Opportunity Event Trigger not working

I'm trying to get a trigger to go off that would create an Event on an Opportunity. The trigger should go off when a box is checked (Create_Calander_Event__c) but the trigger isn't working at the ...
0
votes
1answer
19 views

Restrict creation of duplicate records under parent object based on picklist values

I have Account object as my master and have created a contract object which is a child of Account. I am trying to restrict the duplicate creation of contract records based on pick list values(category ...
1
vote
1answer
34 views

Trigger to match fields in another object

I have 2 custom objects Timecard (pse__Timecard_Header__c) Period (c2g__codaPeriod__c). They don't have relationship. Timecard fields:- Start date (pse__Start_Date__c), Close date ...
0
votes
1answer
16 views

Trigger on Cases, trying to access predefined Case Teams

So I'm trying to create a simple trigger that pulls the list of Case Team Members anytime their updated and copies the list into a custom text field that can be accessed by an email template. trigger ...
0
votes
2answers
43 views

Update Trigger not working

I'm trying to update fields on the opportunity object once the fields are updated on a custom case object. I'm getting the trigger to save, but nothing is happening. Can someone help me with the ...
1
vote
1answer
14 views

Account Trigger with Contact 'for' Loop error

I am relatively new to building Apex Triggers and need some help. Trigger's Purpose: The Account Triggers purpose is to throw an error message if there is no contact associated to the Account upon ...
1
vote
1answer
16 views

Controlling who receives workflow rule email alerts

Here's the scenario: I have set up a community where external users can create cases. When a case is commented on the creator of the case receives an email alert based off of the template I added to ...
0
votes
1answer
27 views

A Trigger that counts the amount of contacts that has Primary Liaison (custom field) populated

I have written a trigger to count the amount of Contacts that has "Primary Liaison" (a custom field) populated and make this count number appear on "# Primary Liaisons" (a custom field on Account). ...
1
vote
1answer
21 views

Lead trigger test fails - newbie alert!

Trying to write a trigger to set a lookup field (Account) on the Lead object, which is based on Account ID as a string that is passed through from an external form)... I have a working trigger (100% ...
1
vote
2answers
103 views

Deployment of a trigger failed due to error, “average test coverage for all Apex Classes and Triggers is 38%…”

Trigger and test class works in Sandbox with 100% code coverage (trigger code listed below) I have checked the following: 1.My code coverage in Production is 98% and Sandbox is 94% according to ...
0
votes
0answers
20 views

Contact's child records transfers

I have few custom child objects (lookup relationship) of Contact. My requirement is if I change the Contact owner from User A to User B, I want the child records of that Contact to be transferred to ...
2
votes
1answer
49 views

Lead Trigger on Import

Hi I have a trigger that runs to dedupe leads that have matching phone numbers(we have 2 phone fields) it works when you go and manually create a lead in Salesforce but when using dataloader.io it ...
0
votes
1answer
35 views

Trigger deployment to production shows “maximum trigger depth exceeded” error

I am deploying a trigger from a sandbox to a production org. During validation it gives me "maximum trigger depth exceeded" error for some other trigger which is not part of the change set. The error ...
0
votes
1answer
15 views

Error: Compile Error: Comparison arguments must be compatible types: Schema.SObjectField, String at line 8 column 113

trigger quantity on OpportunityLineItem (after update){ set<id> lineset= new set<id>(); for(OpportunityLineItem ql: trigger.new){ if((trigger.OldMap.get(ql.id).Quantity!= ...
4
votes
2answers
61 views

Will SFDC manufacture batches from concurrent operations?

So, like all SFDC developers worth his/her salt, I know when writing triggers and other code, we need to bulkify. And I have a pretty good handle on how to do that, so I am not asking about that. ...
1
vote
1answer
24 views

Clone a record in after trigger to update field values

Hi I need to fetch the status field values from the Case History in order to set date/time on when the status was changed to a waiting state. While I was running this code I encountered a run time ...
-2
votes
1answer
38 views

Cannot Specify Id in an insert call error [duplicate]

I have been trying to do a bulk load of accounts in salesforce and it keeps triggering the following error UpdateCSMTeam:execution of AfterInsertcaused by: System.DmlException: Insert failed. ...
0
votes
1answer
28 views

Rewrite apex class to be out of the loop

I have an apex class that I have been having trouble with when I try to upload in bulk accounts. It is tied to triggers that do certain things depending on whether the Customer_Success_Manager__c ...
1
vote
2answers
37 views

Compile Error: Initial term of field expression must be a concrete SObject: LIST<Contact>

trigger VerifyExistingPcList on PACTPackage__Test_Result__c (after Insert) { List<Contact> contObj = [Select LastName,Id,PACTPackage__User_Id__c,Email from Contact where ...
0
votes
0answers
19 views

Campaign trigger

Can someone help me to create a trigger on Campaigns that adds the number of Leads added to a certain campaign so that I can override the Total Leads field with the correct value. Thanks, Darko
1
vote
1answer
56 views

Turn off Trigger and Classes - Code coverage error below 75%

I need your help on this one. Need: We have several triggers that use classes and we need to disable or deactivate both the triggers and classes in production because they are causing issues with ...
3
votes
1answer
40 views

Create a Class that I can access from my trigger to login as another user

I need to be able to impersonate another user from my Trigger, and thinking that I could create a class that logins as another user using the REST API and then post messages from that class. How ...
0
votes
1answer
46 views

Update Child records from Parent using trigger

I am trying to update the child record from the Parent using a trigger, this is what I am trying to accomplish: when the record is updated, the system should check for the field buyer_approved__c, if ...
1
vote
1answer
63 views

APEX Dataloader fail INVALID_FIELD_FOR_INSERT_UPDATE, cannot specify Id in an insert call

I have a trigger and a class that seem to be causing an insert fail in Dataloader. I am trying to insert 200 records to see if an error is generated before moving these to production. I'm just ...
1
vote
0answers
22 views

Creating A Timer on a Picklist Values which calculates how long its been on that picklist option

i have been trying to get Salesforce to create a timer which will tell the user how long the specific object has been in a certain pick list option for, for example say it has been on the option 'New' ...
0
votes
1answer
25 views

How to set a field in oppty based on a parameter of it's products?

I need to check a CB on an oppty, when any of it's products are of a certain character. Our products have a CB named: 3D If an oppty, has any such 3D product, I want/need to check the CB: is_3D - on ...
0
votes
0answers
26 views

Update existing records after adding new trigger on object

I have written trigger on child object (Contact) for show count of child records on parent records(Account in lookup relationship). Trigger is working fine, but it only if any of child record is ...
1
vote
1answer
30 views

Post to a Chatter feed as a different user than the logged un user from a Trigger

I have a trigger that posts to a Project Object's feed and @mentions someone. The only problem is that I need to be able to post the message as another user, not the user who is logged in. How can I ...