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

learn more… | top users | synonyms

0
votes
0answers
4 views

I have this trigger and test class . why my test class cover 0%

trigger openTrigger on Project_Item__c (after insert,after update,after delete,after undelete) { Project_Item__c[] items; //Use Trigger.old For After Delete and The Others is Trigger.new ...
2
votes
2answers
23 views

Running into Trigger Depth Limit

I can't seem to get my head wrapped around this one. We have main account that has many child account and what I'm trying to do is to use a trigger to automatically add up a field (eg. FieldA) and ...
2
votes
1answer
18 views

Only execute Before Update trigger if conditions are met

I have a trigger on the opportunity object with the below format: Before Update on Opportunity Create List of ID's Create Set Using SOQL Query Create Map Using SOQL Query Iterate over ...
-2
votes
0answers
20 views

unable to access updating opportunity access (readonly to read/write)

opportunityTeamMember[] newmembers = new opportunityTeamMember[]{}; //list of new team members to add opportunityShare[] newShare = new opportunityShare[]{}; //get the user id of the user ...
0
votes
0answers
9 views

Conga template with apex trigger

Hi I am new to apex code and I need to create a trigger that fires off a call to appextremes.com/apps/Conga/PM.aspx when I tick a check box on a custom object. I am looking to update the checkbox via ...
1
vote
2answers
12 views

ExactTarget: How to Trigger Send for only one record in Data Extension

I have the following steps to create a trigger send email: Create a new Subscriber Create Data Extension Record about this subscriber Create Email on a triggered send definition, using the data of ...
1
vote
1answer
18 views

Have the CaseOwner Follow the Newly created Case

I have a Trigger that creates a new case. I need to add code to the trigger that automatically has the case owner following the case so that they get a notification is salesforce1. How would I do ...
3
votes
2answers
46 views

validation rule and triggers

I have a field on case linked to an order that is present both in the case object and in the object order. When the case field is true, the order field becomes true in a trigger (after insert or ...
2
votes
1answer
27 views

How to identify deleted vs. undeleted ids in a trigger

I am trying to calculate sums of child records in a master-detail rel. in a trigger and recalculate if child records are inserted, updated, or deleted. We decided not to use a formula to avoid ...
3
votes
1answer
36 views

Trigger is not updating field

I have trigger on lead where i need to update the owner name into custom field (User__c), this field is on lead object which is lookup to user object, here is my trigger. It only updates when you edit ...
1
vote
1answer
22 views

Help writing test class for trigger

I need help writing the test class, I am getting only 70%, I don't know what else to do. I will appreciate any help! Trigger Code: trigger updateOSOTrigger on SO_Detail__c (before insert, before ...
0
votes
1answer
44 views

How to bypass validation rule for trigger in salesforce?

I have a picklist field on opportunity, which contains some values for example: A, B, C, D The user must be able to update A or C during record edit if he tries to edit values other than A and C ...
4
votes
1answer
35 views

Developer console updates current user's User record

We have noticed that Developer Console does some kind of an update on the current user's User record. When that happens, our User trigger is invoked, but with what seems limited permissions, and we ...
2
votes
1answer
44 views

How can I move my select statement from my for loop (trigger)

Hi i have a trigger in my custom object and it hit governor limit due to select statment in my for loop. now i would like to move my statement out. can anyone help? here is my trigger: trigger ...
1
vote
1answer
30 views

Different way to implement this trigger?

I am new in APEX, so I was wondering if there is a simpler way to write this trigger or this is the only approach? Thank you in advance! trigger RemovalCountsONProducts on NRProducts__c (before ...
0
votes
1answer
45 views

Error: Compile Error: unexpected token: public at line 1 column 0

I need some help, this is my trigger. i have created a custom field on the user object called lastlogindate__c . i am trying to get the value from lastlogindate populated in the lastlogindate__c i ...
1
vote
1answer
23 views

Trigger to find contact records who are community users on account

I need to write a Trigger on the Case Object that lookups the Account field on the Case Object on and then determines which contacts on that account are community users and assigns them as case team ...
0
votes
2answers
63 views

Insufficient test coverage of trigger's conditional SObject construction logic

I wrote down a trigger that create an account from a custom object Account_Setup__c. code coverage is 100%, as soon as I add the if statement, it drop down to 35%. the goal is to insert the account if ...
2
votes
1answer
25 views

Help needed getting set of child object IDs in a trigger

I have a set which I want to populate with child record ID's set <custom_object_name__c> ids = new set <custom_object_name__c>(); for (Opportunity opp : Trigger.new) ...
2
votes
1answer
111 views

Is using Database.executeBatch from a trigger an anti-pattern?

In a managed package we have a trigger on Account that propagates a custom field status value from the Account to a large number of related custom objects and wrote the logic in a batchable to avoid ...
2
votes
1answer
75 views

Copying field from object to object on update trigger

I would like to copy the field Outlet_ID__c from my Opportunity object to my Service Orders custom object. I have added the code below to an existing trigger I have which updates the status of an ...
0
votes
2answers
54 views

in sales force trigger why use Trigger.newMap.keySet()?

Please explain one thing here - contact Id and account Id, how to identify and why use Trigger.newMap.keySet()? trigger accountTestTrggr on Account (before insert, before update) { //This queries ...
3
votes
2answers
41 views

Convert Lead on Update trigger

anybody know how to convert a lead on update? It is for if the lead Email matches an existing Contact's email. I can get it to work on after insert, but when I try on update(before update or after ...
0
votes
1answer
48 views

Why is my after insert trigger not get fired?

I have made a trigger for the object Assignment. When an assignment is inserted the after insert trigger should check if there is a linked project. If this is not the case it should make one. Now I ...
0
votes
1answer
24 views

Variable does not exist: loginids

I need some help I have the following trigger on the user object, but i am keeping getting a comple error on at line 16 column 9. the trigger needs to be fired from the User object, when the last ...
1
vote
2answers
28 views

Is this query correct?

Case oldRequestownerid=[SELECT OwnerId FROM case WHERE OwnerId =: Trigger.oldMap.get(d.Id).OwnerId ]; This query is written ...
2
votes
0answers
31 views

workflow rule executes and reverts back

Have a workflow rule to change the status of a case to “Open” when the customer adds a comment to the closed case. It shoots an email to the customer that the status is changed. workflow rule ...
2
votes
1answer
57 views

System.DmlException: Delete failed.SELF_REFERENCE_FROM_TRIGGER

Hi All I have written the apex trigger.It working in sandbox but not in Production.While upload the csv file by using apex data loader in production it throws an exception below. Exception: ...
12
votes
2answers
670 views

How do I generate a random string?

How does one generate a random string sequence with Apex? I need to generate a code when a particular object is created in our Salesforce environment. I'd like the code to contain numbers from 0-9 ...
2
votes
1answer
49 views

How Do I populate the Last Login Date from User object into a custom object/field?

Aim – Pull the last login date from the user object into my custom object and populate a particular field Now I am under the impression that LastLoginDate on the user object is not accessible through ...
2
votes
2answers
27 views

Synchronize value between two fields for parent Object A and child object Object B - strategies?

I have a question. I have a field titled Familiar Name (text field) in two different objects. the objects are: Contact (standard Master object to Profiling Information a custom object). What I ...
3
votes
1answer
72 views

How to lock down an opportunity and prevent edits after generating a sales order?

I'm new to Salesforce and even newer to apex, so I'm struggling a bit here. My goal is to lock down an Opportunity once a sales order has been generated on my company's side. My current idea is to ...
1
vote
1answer
20 views

I cannot find the source for the insert trigger

I'm looking into a issue in salesforce. I can see a insert trigger for a object being called in Debug logs. But, i couldn't find what is the source for the actual trigger. There's no workflow for ...
0
votes
1answer
32 views

Duplicate ID in After Update Trigger

I am writing a trigger to copy childs field value into parent field value. Let say operational_metrics__c is a parent object and contacts is its child object with lookup relation ship. Contact object ...
-1
votes
4answers
98 views

Copying attachments from object to object trigger

I have a custom object called Server_Order__c used in my customer portal which is mirrored to the Opportunities object, as well as mirroring the data I would also like to mirror any attachments that ...
2
votes
2answers
107 views

Separating a Trigger to a Helper Class

I got the below trigger written in a trigger and I need to separate it out to a helper class as a method and call that method in the trigger. if (Trigger.isInsert){ LIST<Category__c> li ...
4
votes
1answer
122 views

Rollup summary of currency field using Apex Trigger

I have written an Apex Trigger to perform the rollup summary(sum ) operation..In the image "Total order Item value" field will be populated using trigger. And "Total Order Items" populates the value ...
1
vote
2answers
44 views

Trigger to Insert Child Object Records

On update of a Parent Object (Recipe Sheet) to be set to "Add to Inventory" I need to add Child Records (Recipe Sheet Items) based on another table in Salesforce tied to the Product table (Product ...
0
votes
1answer
27 views

Trigger to update Child Records based on Parent Record

I am trying to update the status field of all the related child (Recipe Sheet Items) for a given parent (Recipe Sheet) when the status is updated to 'Void' and I am trying to make this trigger handle ...
1
vote
4answers
50 views

Trigger to validate selection of Pick-list values

I got an object called 'Category' which has a master detail relationship with 'Scheme' object, 'category' has a pick list field called 'Type' & it has different values Ex:Cost,Time etc. I need ...
2
votes
1answer
25 views

Sync Quote Automatically on record creation

I am trying to get our quote system to automatically sync a quote on creation if it meets certain criteria. (Status, and a couple of custom fields.) I have done some research and found a few places ...
4
votes
3answers
109 views

How to display an error message from a trigger insert failure

I have an odd problem. A trigger was creating a record which failed to insert due to workflow field update being too long for the field. The error did appear in error log, but did not in the standard ...
2
votes
1answer
71 views

Trigger.New is not working properly when update record

can anybody tell me why this trigger only works when the record is created but not when is updated. For example, if I create a new record the trigger will set the buyer name correctly but if I changed ...
0
votes
0answers
17 views

Looking for a way to update a field on an Opportunity Product when a field on the Opportunity is checked

We have a start date on the Opportunity Product that we would like to be able to automatically update to the close date on the opportunity only some of the time. We thought that a check box giving the ...
0
votes
3answers
53 views

Why would a trigger fire on insert and update for the same transaction?

I'm building a trigger, and when I create a new record it fires on both Trigger.isInsert and Trigger.isUpdate context. trigger Custom_Trg on Custom__c (before insert, before update) { ...
3
votes
1answer
43 views

How to bulkify a trigger that has unrelated objects

I'm trying to bulkify a trigger, previously when I've done this there has been a relationship between the objects within the trigger and i've been able to figure it out from other peoples triggers. ...
10
votes
1answer
163 views

Consolidate trigger methods or not?

I have a general best practices question about triggers. I have created a handful of triggers that perform different actions but are called by the same event, such as after account ...
2
votes
2answers
29 views

Email Alerts and Formula (Lookup) Fields

I'm hoping a SF guru can help me think through this problem. Here's an example: imagine that I have two objects: Offices, and Issues, a child object. In Office, I have an email field called 'Point ...
7
votes
3answers
86 views

Workflow+Trigger vs Trigger

What are your thoughts on using a combination of workflow + trigger versus running all logic through a trigger. The reason I bring it up is I'm undertaking a massive trigger cleanup in a new org I ...
1
vote
3answers
33 views

How to check that the email Id on the person account selected on a case is null or not

I want to check in my trigger on a case whether the email Id of the person account for the case is an null or not. I have a lookup to contact(person account) on the case page. How to achieve this. ...