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

learn more… | top users | synonyms

0
votes
0answers
17 views

Bulk API and Static Variable State

Our trigger logic has some recursion detection built in. Essentially, we have some static variables that act as counters for trigger executions. When our set "max" gets hit, our triggers quit to avoid ...
3
votes
2answers
128 views

Order of execution of trigger and workflow

I am aware of the flow of execution in salesforce(validation, autoresponse, assignment...etc). I also have knowledge of the order of execution of a visualforce page. I have 2 questions on execution: ...
0
votes
2answers
27 views

Need help writing a Custom Object Trigger

I need the custom object (Installed Products) to have the same owner as the account as it will resolve some sharing issues. The API name is SVMXC__Installed_Product__c and the Owner field name on the ...
0
votes
1answer
25 views

Question on trigger to roll up on formula field on detail object

Consider me a beginner in Apex and Programming in general, so i am sorry for what may be a fundamentally dumb question. I am writing a trigger to roll up a formula field, Elapsed_Time_days__c, in a ...
1
vote
1answer
34 views

How can I generate a sequence based on conditions?

I have fields region, revision and Quote. The Quote field will be automatically generated based on selecting region and revision. Quote will be combination of region, alphabetic and count value. for ...
-1
votes
0answers
28 views

Opportunity Trigger [on hold]

I need to write a trigger for an opportunity that is imported via Data Loader to insert the contact and account fields from a custom field. I haven't written a trigger before and having difficulty in ...
2
votes
1answer
40 views

Apex Trigger to populate custom field on Contract Object with value on contact object

I have a question for you knowledgeable people On the contract object we have a field called “Client Director” which is a look up to the contact record. Field: Client Director field api : ...
0
votes
1answer
39 views

How can I make my trigger only fire after all (of several thousand) records are finished being inserted?

I have a batch apex class that I need to fire only after all of the thousands of records from a record import have been inserted into a custom object. I thought I should use a trigger to fire my ...
1
vote
2answers
30 views

Can't change Opportunity owner from Trigger because Error record is 'read-only' [duplicate]

This is supposed to be a simple trigger that changes the Opportunity Owner to the the Account Owner upon insert or update of the opportunity. However, I keep getting the error, cannot update the ...
0
votes
0answers
13 views

Currency Conversion wrong [duplicate]

I'm trying to populate the sum(total selling price)of child object on to the "total order item value"{currecny data type field} of parent object. Here is the code trigger Rollup on OSF_Order_Items__c ...
0
votes
1answer
14 views

test class for Custom settings in Account

for (AccXYZ__c mdm : mdmObjs){ system.debug(' *** mdm '+mdm); String fieldName = mdm.Field_Name__c; system.debug('***** ...
1
vote
0answers
10 views

When we create Email To Case .. Can we fire Trigger on Email Message Object?

trigger MiC_Trg_DetectLanguage on EmailMessage (after insert) { For( EmailMessage message : Trigger.new) { String caseId = message.ParentId; MethodClass_Future.getLanguage( ...
2
votes
2answers
36 views

Trigger Error on Custom Object

and thanks in advance for any suggestions, greatly appreciated! we created a trigger that queries the accounts and creates custom invoice records for each stop on our service trucks. each route is ...
1
vote
0answers
22 views

Account History Track custom object

I have created this custom object. Problem is for say Account ID A1 if Lastname field was X now becomes Y. It creates an entry for this with Old value X new Value Y. Now if again updated by Z, the ...
2
votes
1answer
38 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 ...
4
votes
2answers
46 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
23 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
25 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
1answer
35 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
25 views

ExactTarget: How to Trigger Send work with 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
19 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
53 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
28 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
43 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
23 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
48 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
39 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
45 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
60 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
24 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
64 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
28 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
114 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
78 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
65 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 ...
4
votes
2answers
45 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
49 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
26 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
32 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
66 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
688 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
52 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
28 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
75 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
33 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
101 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
115 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 ...