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

learn more… | top users | synonyms

0
votes
2answers
16 views

test class for a trigger

I have 2 triggers into sandbox that work s perfectly and I want to transfer it into production. The only problem is that I need to write a test class for each one in order to cover 75% of the triggers ...
1
vote
2answers
21 views

Updating the owner of records connected via lookup relationship

I was given a task to write a trigger to update the owner of records connected via lookup relationship. Consider i've a custom object which is having a lookup relationship to another custom object. ...
0
votes
1answer
28 views

Showing an exception when saving apex class or trigger from laptop

I am trying to implement an apex class in my developer organization on my laptop but I'm not able to save the class. It gives me this message: Error: Compile Error: unexpected token: 'undefined' at ...
1
vote
1answer
18 views

What is the best practice method to summarize contact information to leads?

Here's the business case. I want to have a reportable field on a lead that displays the number of contacts for, say, a city field match. This value could be used in reports, dashboards, snapshots, ...
0
votes
0answers
30 views

trigger to update date field on object B, when date field changes on object A

I need a trigger on object A. It should only run when CloseDate__c changes and it should populate Start_Date__c on object B. By the way, CloseDate__c is a field in object A Start_Date__c ...
2
votes
1answer
51 views

Help modifying a trigger for bulk uploads

I'm working on some systems integration pieces and as part of it I've written a trigger to automatically determine the related campaign based on the criteria entered. This all works small scale but I ...
0
votes
1answer
31 views

Problem updating records via anonymous apex

I ran anonymous apex to update 50k records. This is my query.. update[select account__c from orders__c where account__c=null and ship_to__c!=null limit 1000]; At one point of time at around 11k ...
0
votes
0answers
19 views

Julian date to salesforce format date

We have the data coming from external application to salesforce where the dates are stored in Julian format in 6 digits in external party application. . Can you please help me to convert this to ...
0
votes
1answer
32 views

Trigger to create new event after insert/update creating dupes

I have a trigger that should create a new event after insert or after update of a custom object called Handoff, but only if a custom field (Status) of that new record = "Delivered" The after insert ...
0
votes
1answer
18 views

Recall Approval Process through Trigger and Controller

I need to unlock a custom object (Events__c) record when an Task is created. Hence I propose to recall the approval process when the Task is created by using an After Insert Trigger. Here is the ...
0
votes
0answers
18 views

Recall Approval Process through Trigger

I need to unlock a custom object (Events__c) record when an Task is created. Hence I propose to recall the approval process when the Task is created by using an After Insert Trigger. Here is the ...
1
vote
2answers
26 views

Error: System.QueryException: Non-selective query

I get this error.. System.QueryException: Non-selective query against large object type (more than 100000 rows). Consider an indexed filter or contact salesforce.com about custom indexing. Even if ...
1
vote
0answers
27 views

Does adding a contact and user to an account trigger an update to that account?

I am trying to fire a trigger on the account when IsCustomerPortal if flipped to true. I have checked in workbench and this field is definitely changing when I add a new user and contact but it ...
2
votes
3answers
35 views

contact trigger efficient way

I've to update field on Account which shows total count of Contacts associated with Account (after insertion and deletion of contact) I've written it and it seems to be working fine But I'm ...
0
votes
1answer
45 views

Update Parent Object with Child Objects

I have 4 record types, 3 (Service, Access and Equipment orders) are child, and the parent is (customer Orders) When a date is updated in one of the child obejcts, I would like that date to be ...
2
votes
2answers
40 views

SOQL Fails only in Apex Trigger

I am trying to query a list of objects using a value from the account object being inserted. When the query executes it is returning a row count of 0. However, if I run this same query using the ...
1
vote
1answer
50 views

Invoke Apex With No Invokeable Method From Workflow Rule or Process Builder

I'm looking for a way to fire an Apex Class without using code or a button click. My Apex Class does not have an invokeable method so I can't fire it using the standard Process Builder. But I do have ...
0
votes
0answers
19 views

Trigger updating Person Account Details on cases

I have a made a trigger that is updating the Case Contact fields with person account details finding the exact match of Contact Name and Phone or email. It is working fine for the cases received ...
0
votes
1answer
25 views

Custom settings cant access

CLASS public with sharing class AccountUpdate { public static void doAfterUpdate(List<Account> newRecs){ Account_Source_Value__c other = Account_Source_Value__c.getValues('Other'); ...
0
votes
2answers
51 views

Test class not firing trigger update

I All, I am facing an issue with the test class. I have trigger on Insert and Update. I am using the test class given below which covers Insert trigger but do not cover the portion in Update. Need ...
0
votes
3answers
48 views

Apex CPU time limit exceeded (How to test trigger using large number of records?)

I wrote a trigger and need to use test the trigger by insert/update/delete large number I wrote one method to test the insert/update/delete trigger and I ran into Apex CPU Limit. My requirement is ...
1
vote
1answer
17 views

Activate an InActive Trigger using the Force.com IDE

Trigger code : trigger SetFieldsOnContact on Contact(before insert){ System.debug('------------inside contact trigger SetFieldsOnContact before insert---------'); String accId = [SELECT Id ...
-4
votes
1answer
48 views

Please answer me some Interview question [closed]

I have some interview question anyone here please provide me answer to these questions. 1) Can a batch call from another batch class? 2) If there are 100 Account and 100 contact records as result. How ...
0
votes
2answers
28 views

I have created a trigger ..i am updating contact address using account address

as soon a I create account record I want to update the contact record's mailing address field. I have written trigger on account because if I update account address field automatically related ...
2
votes
1answer
54 views

addError in trigger is conflicting with test method written for another class

I have written a following trigger code - trigger manageEmailCases on Case (before insert) { for(Case thisCase : trigger.new) { if(thisCase.Origin == 'Call-Center') { ...
1
vote
2answers
51 views

Issue with inserting split percentage using trigger

I am beginner to salesforce. I am trying to insert an opportunity split record whenever an opportunity team member is inserted. Trigger code: trigger OpportunityTeamMembertrigger on ...
0
votes
0answers
19 views

Trigger not able to auto forwards records between two connected orgs

In both the orgs S2S is Enabled. Required objects are published and subscribed. This trigger is written to auto forward Records between two orgs. Same Logic is working for other objects.Please ...
0
votes
1answer
44 views

Having trouble writing Apex trigger on custom object to update a lookup fields

I have a trigger that maps information from one Custom Object (Agents) to another Custom Object (Trident Contracts). I am able to update Seller Agent Name in the Trident Contract Mapping with the ID. ...
0
votes
2answers
50 views

Fire Trigger Only When Stages Moves to Closed Won

I have the trigger class below and I would like it to fire only when an Opportunity Stage is changed to Closed Won. Can anyone help me figure out how to do this? I have an if statement, but it fires ...
0
votes
0answers
6 views

Update a custom field from the value present in the Case milestone

I have a requirement where I have to copy the "time remaining" value from the Case milestone and paste it in a custom field in Case object as soon as a Case is created. The problem I am facing is we ...
0
votes
0answers
15 views

Issue in trigger that is used for auto forwarding records between two salesforce orgs

In both the orgs S2S is Enabled. Required objects are published and subscribed. This trigger is written to auto forward Records between two orgs. Same Logic is working for other objects.Please ...
0
votes
2answers
34 views

Update a field when receiving a 2nd line item

I have a custom object. When receiving a second line item on that custom object I want a check box field to be updated to true. I have tried using workflow rule but I couldn't find any relation for ...
0
votes
0answers
26 views

Updating Picklist value trigger

I need some help creating a trigger Aim : Every time a task is created which meets criteria ( See below) then change the status from “Not started” to “Completed” The trigger should only fire if it ...
1
vote
1answer
43 views

Can we write trigger on LoginHistory object

I want to copy login history data in custom object when new entry added to login history. If trigger is not possible then is there workaround for the same
0
votes
0answers
27 views

Trigger for new complaint managing system

I am trying to make a trigger for Complaint case management i want if a case is lodged via web to case or email to case it should find the Contact details of the related person in Salesforce if ...
4
votes
2answers
136 views

Why does this trigger class work when editing individual child records but not when mass loading child records?

February 26 Update: Still hoping someone can help me with this? Are there any takers? February 23 Update: Still have issues. The updated helper class code is below (this is exactly what I have in my ...
0
votes
1answer
36 views

Trying to clone Attachment to new record via trigger Code not working

I'm trying to clone an attachment on an opportunity to a custom case object via a trigger. My code is creating the case but not cloning the attachment. Is there anything I can do to get this to ...
1
vote
3answers
37 views

Deploymenterror - Too many SOQL queries: 101

I have a new trigger to update summary fields from child object to parent object for a lookup relationship. I tested the trigger before trying to deploy. there is no issue. But I get the govener limit ...
0
votes
1answer
36 views

Cloning on trigger is inserting record twice

we have a approval system and when every step is approved it updates Revision number. There is a trigger on the change of Revision Number, which is responsible for cloning the the existing record and ...
1
vote
2answers
121 views

how do i create trigger on attachment?

i want to create trigger on attachment object , but i am not able to find it in setup. can anybody suggest way how to do it? i am assuming it from Developer console? Thanks in Advance.
0
votes
2answers
27 views

Parsing Ids from a string to create detail objects

I am building a Flow that takes a user through a wizard to create a custom contract object with detail objects that represent the products on that contract (stored as a junction object). An issue I ...
2
votes
1answer
44 views

Generate Unique Key Using Trigger

I have already asked a similar question that was initially answered: Generate another ID by encoding the Salesforce ID The suggestion seemed to have fixed the issue but after extensive use and ...
1
vote
1answer
82 views

Relationship advice: Many-to-many

So I have a custom object Campaign__c which I need to relate with the Opportunity object. This will be many-to-many, so I've created a junction object called Campaign_plan__c with lookup (also tried ...
1
vote
2answers
31 views

I need to check every owner of an object involved in a trigger permissions

I have an object called Albaran__c, (it's set on private sharing mode). I have a trigger that shares every record involved on the trigger with the owner of the Account we do reference on the field ...
1
vote
1answer
36 views

Apex trigger stuck on 0% test coverage; can't

I'm blanking on why my trigger is indicating 0% test coverage. I feel like I've treated it like my other triggers, but it is no different than it was when I didn't have a test class at all. Any ideas? ...
0
votes
0answers
11 views

Helper Method Opportunity Stage Name

I'm about to create a helper method to my trigger (see below) but unsure of the parent-child relationship of contract and opportunity (I mean that right way to query and/or call a certain field (i.e. ...
1
vote
2answers
35 views

Need help understanding line of code where a method accepts a list as an input parameter. Where is the list created?

With reference to the line of code (method createContact) below I am wondering where List candidateFromTrigger is created? This doesn’t seem to follow the create new list syntax public void ...
-1
votes
3answers
61 views

System.LimitException: Too many SOQL queries: 101 Stack Trace: Trigger.TAFieldUpdate: line 4, column 1

I have a new trigger and when I try to deploy I get the above error. I know this due to SELECT statement. I tried with List object but still got that error. Thanks in advance Jay trigger ...
0
votes
1answer
43 views

Trigger validation error message on Submit for Approval (Approval Process)

I have recently encountered an issue, which I do not seem to be able to resolve. I have set up an approval process that fires up if my PickList__c is evaluated true to the following value (or entry ...
0
votes
1answer
34 views

Trigger to clone object is throwing error

Apex trigger is throwing following error when tried to clone the record, Although there is no id inserted but still I'm getting complain about id. **Validation Errors While Saving Record(s) There ...