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

learn more… | top users | synonyms

0
votes
0answers
9 views

if i change account recordtype the related contacts of check box set to be true

my scenario is.. on Account object have two record types nmaed rec1 and rec2, have a sendemail checkbox on contact object.. when i change the rec1 to rec2 to on account object the related contacts of ...
0
votes
0answers
9 views

Trigger to update 5 fields when new Chatter Files are Uploaded

I am kind of new to the Trigger world of Salesforce and am having an issue figuring out how to update a few text fields whenever a Chatter File is uploaded to the record. Sounds pretty simple to me ...
0
votes
0answers
10 views

Time Dependent Workflow for Changed field

I need your assistance asap. I am trying to write a workflow rule (or trigger, or process flow,etc.). I need a workflow that recognizes a change in a field on a Customer Account record and depending ...
0
votes
2answers
23 views

am new to salesforce need clarification on apex triggers [duplicate]

Am new to salesforce have clarification on apex trigger.Can we use trigger.new & trigger.old in both before & after triggers.Please explain. Thanks, Karthik
1
vote
2answers
327 views

What is wrong with this trigger?

Trigger Noob here trying to finish my first trigger... thanks for bearing with me! Why am I getting the following error when trying to save this trigger? Compile Error: expecting a right ...
2
votes
2answers
22 views

Converting Apex Trigger to a Class

Please excuse any misstatements or blunders in my comments as I'm VERY new to Apex development. However, I've found code for a trigger that allows me to copy/clone attachments from a custom object ...
0
votes
0answers
33 views

We have multiple triggers on an object,how to findout one trigger is in use or not [on hold]

We have multiple triggers on an object.We have one requirement,How to find out one trigger is in use or not eventhough it is active .Please help me on this.
0
votes
0answers
15 views

After insert update current custom object fields with standard object

I m new to salesforce.i have custom object Lease__c , i wanna update the account name and owner field from opportunity.In lease__c i have lookup for opportunity field.how to write trigger for Lease__c ...
1
vote
1answer
29 views

Trigger to add active user with standard profile to public group

trigger wen user record is inserted/updated..check if user is active or not.. profile should be standard user..and if both conditions meet..then add user to a particular public group trigger ...
0
votes
1answer
24 views

On Trigger: System.LimitException: Too many SOQL queries: 101

I have issue with the below code when executing gives the error "System.LimitException: Too many SOQL queries: 101". Is there a way to optimize the below code? As per the error log, it happens when ...
1
vote
2answers
40 views

Trigger Not Firing - When Child Updated, Update Field on Master

Have two custom objects, Master and Child. Child has a lookup to Master. Trigger is saving, but not firing when I update the Child: trigger updateMasterName on Child_Custom__c (before insert, ...
0
votes
2answers
14 views

Trying to assign lead to existing account owner

I am stuck on this trigger.. i am trying to match Leads with existing accounts using a custom "domain" field. If an account exists with that same domain then i want to assign the incoming lead to the ...
0
votes
1answer
47 views

Code Coverage Issue on trigger

I have a trigger and an apex class, When i deploy them from staging to production I get the following error. What Should i do ? I have a week experience in salesfroce. Issue Code Coverage Failure ...
0
votes
1answer
16 views

System.TypeException: Cannot call test methods in non-test context

Hi i have a test class but it gives following error error : Line: -1, Column: -1 System.TypeException: Cannot call test methods in non-test context Code @isTest public class testclass { ...
0
votes
1answer
22 views

how to replicate reverse relationship using custom object in trigger to handle insert, update and delete

I have a custom object called Account Affiliations which is a junction object between two accounts. Below is the schema of the object. Object Name: Account_Affiliations__c Custom fields: 1) Account ...
0
votes
1answer
31 views

Delete Account's Contacts when Account field F has value X

If I have a picklist field named AccountStatus on the Account object with 2 picklist values: Active and Inactive. When the AccountStatus is highlighted Inactive then all the Contact records looking ...
0
votes
1answer
15 views

Changing lead owner to existing Account Owner

I have formula field called "domain__c" on Lead object which comes from the email field. I also have a domain field on Account object. I want to change the lead owner to the person who owns the ...
0
votes
1answer
9 views

Salesforce CRM Content User

Is there a API name for "Salesforce CRM Content User" checkbox on user object? I want to set it as True in my trigger for all new users but i can't find out its api name.
0
votes
1answer
31 views

In Trigger custom Checkbox is not working properly

Once the new user is created in Salesforce I want to send welcome email to the user automatically. for the above process, i have created custom check box"Welcome_Mail__c" in user detail page. If i ...
0
votes
1answer
30 views

Error: Too many SOQL queries: 101 on loop

I am trying to solve the error that reads "System.LimitException: Too many SOQL queries: 101" on my code when trying to load some data. After going through system logs and searching them, I suppose ...
3
votes
1answer
107 views

Deployment Test Failure - Too Many SOQL Queries: 101 but Query isn't in a Loop

First: I know this question has been posted many times so I apologize for making a new one, but I read over a lot of the old ones and they almost always seem to be that the SOQL query is inside of a ...
0
votes
0answers
21 views

How to update the field values from account object while creating leads

I have a lead related list in account page. I need to assign some of the field values of account into leads. But the value is not updated. Please help me through this. Code : public static void ...
0
votes
1answer
19 views

UPDATE — UPDATE FAILED — ERRORS : (SELF_REFERENCE_FROM_TRIGGER) Object is currently in trigger therefore it cannot recursively update itself

I have two objects Account & Patient. Patient having look up relationship with Account. (One to one relationship) Some fields are common in both. In my case user can update those fields from both ...
0
votes
1answer
22 views

Populate record name automatically

I want to populate the name of a record by concatenating the values of two other fields, is this possible? I attempted this by using a before insert trigger, but since the system validations(checking ...
0
votes
1answer
24 views

Are the exceptions to be added mandatorily in an Apex Trigger?

I have written a Trigger on Lead which updates the Owner of Lead to Contact Owner or Account Owner or a Queue. First checks for Contact (if criteria is true) then assigns to Contact Owner. If first ...
1
vote
1answer
19 views

Validate Contact name on Quote object

How do you validate if the Contact name field is left empty or not on Quote? I do see that, its a lookup field and using the code as below on trigger always return false. for (Quote objQuote : ...
0
votes
1answer
11 views

Cross-Object Apex Update [duplicate]

Trying to update a Lookup ID of an object related to Opportunity. New to Apex and I'm missing something pretty fundamental I believe. trigger UpdateABC on Opportunity (after insert, after update) { ...
0
votes
0answers
24 views

Trigger to Update Lookup on Related Object

Scenario: Have custom object - ABC Object ABC Object has a lookup to Opportunity Process Builder creates an Opportunity when an ABC Object record is created Process Builder updates record ID of ABC ...
-6
votes
0answers
32 views

how can i move the following trigger into apex class?

how can i move the following trigger into apex class? Trigger: trigger validDiscountpercent on Opportunity_car_set__c (before insert,before update) { decimal d; set<id>oppids=new ...
0
votes
1answer
25 views

How to write a trigger on campaign members to update a custom field in lead object as lead score

trigger newLeadscore on CampaignMember (after insert,after delete,after update) { Map<Id,CampaignMember> campaignLeads = new Map<Id,CampaignMember>{}; List<CampaignMember> ...
-8
votes
1answer
33 views

trigger !! opportunity stage to “CLosed won” -->Automatic mail to the emailaddress specified in opportunitycontactrole [on hold]

Requirement on trigger -- my requirement is if we change the opportunity stage  to "CLosed won" ,   based on email address present in  Contact role in  opportunity line item  we need to send an ...
3
votes
2answers
73 views

concatenate values within APEX Trigger

I am have trouble with line breaks and string literals: I cannot get the below to compile: newD.Additional_Information__c = recTypeName + '\r\n\r\n' + recTypeName == ...
1
vote
1answer
41 views

Create case with no accountId although contact has related account

When creating case, if contact has accountId, Salesforce is automatically relating my case to that account which I would like not to happen. If account is selected on the case and contact has account ...
0
votes
2answers
43 views

how to get Product name using product2 from opportunitylineitems

here is my code in which i am trying to get the product name from opportunity line item but its returning back NULL value. can anyone please help me to get that product name. I can get id from ...
0
votes
1answer
34 views

how to get product2 [duplicate]

here i am trying to fetch name from opportunitylineitem but its fetching null, don't know how to solve this problem. Can anyone please help me out. > for(OpportunityLineItem o : oli) > ...
4
votes
2answers
36 views

Cannot get Unit Test to pass in order to push trigger to production

I'm having difficulties creating a Unit Test for an Apex Trigger to pass so I can push the trigger into production. I'm hoping someone can help me or point me in the right direction to where I'm ...
0
votes
2answers
37 views

How do I set a user lookup field equal to the owner using a trigger?

I have a field called Account_Manager__c on my Account record and I am trying to set it equal to the Account Owner when certain rules are met. I got the concept to work when I was just updating a text ...
3
votes
1answer
35 views

Why is my Update trigger executing before Insert trigger?

In the attached debug screenshot, you can see that - according to the CODE_UNIT_STARTED and FINISHED lines, the execution seems to be going like this: Record A is inserted CODE_UNIT_STARTED: ...
1
vote
1answer
24 views

Send alert from idea object when idea gets 100 points

Can i force sales force to alert management whenever an idea gets 100 points. as far as i know it does not support workflows, neither triggers. at least that's what documentation says.
2
votes
1answer
36 views

Data Loader and after update triggers running twice

I have a scenario. I am updating some Opportunity records through Data loader which causes after update trigger to run twice and cause issues. It shows that some WF Field update runs again and then ...
0
votes
1answer
20 views

Null pointer exception only While loading data from Data loader (bulk upload)

I am facing issue "Null pointer exception Attempt to deference a null object" while loading data from data loader. But when creating individual record it is not throwing any Error. Here is my code : ...
0
votes
1answer
45 views

How to bulkify trigger when loading so many records records at a time?

I have trigger which will create new Lead record when ever a record is inserted in the Custom object. The issue is my trigger is working only when one record is inserted. It is storing the same value ...
1
vote
1answer
22 views

System.listException while inserting data into account

i have written a trigger on account to create contact automatically but it is working fine in the case of updating only,while inserting in account i am getting the following error this is my code: ...
0
votes
2answers
42 views

Trigger to create an attachment

I have a requirement where an attachment has to be auto created whenever a record on Object A is Created. The attachment is a child to Object A. And the attachment type is ".docx".I dont have a ...
3
votes
2answers
59 views

Apex trigger runs OK while editing Account, fails in DataLoader

The trigger in question reassigns cases from the updated account to another account given a criteria defined by a single custom field in those cases. Basically, if "Case.ReassignTo__c" has a value, i ...
-4
votes
0answers
18 views

How to assign the task in apex trigger [closed]

trigger CreateTaskWhenNewLeadGenerate on Lead (After insert , After Update) { Set<Id> LdIdSet = new Set<Id>(); for ( Lead Ld : Trigger.New ){ if ( ...
0
votes
0answers
16 views

How to get related attachments when cloning a case record?

Here i need help, when cloning a existing case record i want to attach all the attachments automatically of existing case record to new cloning case record. Thanks in Advance.
1
vote
3answers
22 views

How are records batched from Time-Based Workflow updates

Wonder how Salesforce handles batching records in relation to execution context. For example, if I have a static variable that tracks the records being processed by a trigger: trigger MyTrigger on ...
0
votes
1answer
21 views

FeedComment trigger - update parent case when chatter post receives a reply

I am planning to implement this trigger on the FeedComment object, as this object is not available for use via Lightning Process Builder. I'm looking to update the case when a certain type of user ...
0
votes
1answer
21 views

Once Lead is closed no update the record [closed]

Can someone help me in writing the code for the following logic. Once the lead status is closed the lead last modified date should not be updated.