Tagged Questions

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

learn more… | top users | synonyms

2
votes
0answers
9 views

Can a Journey Builder Trigger compare one attribute to another attribute?

Let's say my subscribers have two attributes, Attribute_A and Attribute_B I want to create a Trigger expression in Journey Builder that checks if Attribute_A is Equal To Attribute_B Is it possible ...
1
vote
1answer
22 views

Trigger to change Contact on Case after update

Scenario: When a new Case is created with a specific recordtype I want to change the Case Contact to a default Account Contact instead of the Contact initially set when case is created. (These cases ...
0
votes
1answer
15 views

which event of trigger used to update field of child object?

I have two objects in which Parent is A and Child is B. My Trigger is on A then from that trigger i want to update field of B. In this scenario, which Event of Trigger achieve this? Thank you..
3
votes
1answer
42 views

Too many SOQL Queries - NPSP burning my governor?

I've running some custom code within the Non-Profit Starter Pack (NPSP). A big part of that code is a REST interface that imports data from an outside source. I have triggers attached to the output ...
1
vote
2answers
7 views

Error when using an OR within an IF statement with 'contains' method

Getting an error with the following code snippet of "Save error: expecting a right parentheses, found 'OR'" . It works if I use only the first contains, but then errors when I add the OR and second ...
3
votes
2answers
84 views

Check whether any field has change in Trigger

I know how to compare fields before/after a trigger. But how can I know whether any field has changed or not (or that a user has 'edited' an object without actually editing anything). It seems a bit ...
1
vote
2answers
64 views

How do I test an apex trigger that sends an email

Trigger is: trigger emailtemplate on opportunity(after update) { List<opportunity> oList = Trigger.new; List<opportunity> nList = trigger.old; ...
0
votes
1answer
35 views

fire an apex trigger on opportunity while cloning a record

trigger to copy Opportunity Team when an Opportunity when the opportunity is cloned. That can we copy the child records when we are cloning ...
0
votes
1answer
21 views

how to test trigger using test class? [on hold]

trigger totalamount on Opportunity (after insert,before delete,after update) { Set<Id> accid = new Set<Id>(); if(trigger.isInsert || trigger.isUpdate){ for(Opportunity ...
0
votes
1answer
24 views

Am updating status of order to “activated” using trigger but its throwing error “System.FinalException: Record is read-only: Trigger.UpdateStatus: l”

trigger UpdateStatus on Order (after insert,after update) { List<order> ord=[Select Id,Opportunity__c,AccountId,EffectiveDate,CurrencyIsoCode,Status,TotalAmount from Order]; { for(Order o1 : ...
0
votes
0answers
9 views

book object have price field (currency) under this object

book object have price field (currency) under this object we click the save button the value is entered in the price field is 10% lessthan the actual price.this is applicable for both creating and ...
-1
votes
1answer
27 views

System.FinalException: Record is read-only

I have two questions. Firstly, is the following code correct to update the field report__C which simply displays the email address of the person who created the case. Secondly, when i tried to test ...
0
votes
1answer
41 views

Trigger issue: If case.priority changes then contact .priority changes too

trigger prioritycheck on Case (before insert, after update) { Set<ID> setacc = new Set<ID>(); for(case c:trigger.new){ setacc.add(c.accountid); } Map<Id,List<Contact>> ...
0
votes
2answers
42 views

what does this statics means in Trigger?

Hi currently i'm support a former SF developer in my company. I am pretty new in SF and I found that some of the trigger has this statement from my former SF developer :--> statics.runAppProdTrigger ...
0
votes
2answers
36 views

Apex Trigger for Creating a New Account Record when Custom Field on Custom Object is UpDated

G'afternoon, I have spent the last week trying to write this code in my Dev Sandbox and keep getting random errors. This is my first attempt at writing an Apex Trigger so I apologize if it seems ...
0
votes
1answer
26 views

Apex Trigger To Update Owner On Master Record Based On Picklist Value On Detail Record

I have a scenario where I am trying to create an Apex Trigger that updates the Owner on a master record based on the selection made on a picklist in a detail record. My master object is: Label: ...
1
vote
1answer
23 views

How to write a trigger to fire a task to a public group whenever an article is created(as draft) in the 'Article management' tab.

How to write a trigger to fire a task to a public group whenever an article is created(when they are in draft) in the 'Article management' tab. This is to send a task to the public group/team to read ...
1
vote
2answers
19 views

Populate OppLineItem field based on Opportunity Stagename Change

I'm trying to write a trigger that would populate a custom field on the OppLineItem when the parent Opportunity stage is updated. The field would be populated with a value from the Product. What ...
0
votes
0answers
32 views

Trigger on Opportunity to send email for change in stage by any User other than Owner of the record

My requirement :Develop a trigger to send email alert to Opportunity owner incase opportunity stage is changed by any other user. Email alert should have information about old stage name, new stage ...
1
vote
1answer
36 views

Apex trigger not working

I have tried to set the name field of the Volunteer Job object to the case number or an auto increment number and neither seems to be working. I have tried to use a trigger: trigger AddCaseNumber on ...
1
vote
1answer
12 views

Dereferencing a Null Object error

1) This method "ConverttoInventory" is called via Custom Button on Page Layout. 2) The following below is a helper class whose static method "ConverttoInventory" is called with "Merchandise Id" ...
1
vote
1answer
23 views

Apex Trigger - Query on Execution

I would like to do understand the following trigger execution. trigger MerchandiseTrigger on Merchandise__c (before insert) { Merchandise__c[] m = Trigger.new; for(Merchandise__c mer ...
0
votes
1answer
21 views

Traverse Parent Object on Map Get Method

I'm looking to retrieve the string value for the Inventory_Stage__c field in the following logic. The code is incomplete, but I'll post the relevant stuff of what I have. Any help in doing this would ...
1
vote
2answers
50 views

Updating OpportunityLineItem fields issue

I've written a trigger that updates some fields on the Opportunity Product object with Product values when the Opportunity reaches 95% probability. The trigger works when I edit and save the ...
2
votes
2answers
48 views

Bulkify Unique check Trigger

I have a trigger on a custom object (Contact_Communication_Method__c) that checks if a Contact already has the specified Communication_Method_Type__c. I am having a hard time changing the logic so ...
0
votes
3answers
56 views

Assertion failed, expected null

I'm currently trying to test my trigger but it keeps expecting null instead of date.today(). Can anyone help me? Trigger: Trigger UpdateLastSurveySent on Case (after insert, after update) { ...
1
vote
1answer
159 views

Best Practice on Triggers

I have the following trigger logic built in Contact object during Create event. If Mobile Phone is given and Home Phone is not given while creating a contact, then set the Mobile as Home Phone ...
3
votes
1answer
36 views

Best Practices for Validate field in Salesforce

Hi, This is my scenario, - Object Name: Contact . - Field: -Status__c (Picklist) contains: Active ,Inactive or NULL -StatusDetail__c (Text) The requirement is whenever Status not null , ...
0
votes
1answer
33 views

How can I communicate a trigger exception to user in a bulk upsert for each record?

I am performing a bulk upsert with a large batch (sometimes as much as 3000 records at one time). I am splitting the list of 3000 into 5 batches and performing an upsert using the Bulk API. When I ...
1
vote
1answer
27 views

How Can we create a trigger that updates a counter for closed won consecutive opportunities?

We are thinking to have a field under Contact Object that counts the number of consecutive won opportunities. If the Opportunity has the stage "Failure" the counter must be updated to 0 but if it has ...
0
votes
1answer
56 views

Please help me with below test coverage

I have below trigger. And i have one test class. Trigger is Covered 76%. i want to make it more than 90%. The code which is not covered is at line numbers : For Trigger 1 :14,17,25,26,27,32 For ...
0
votes
1answer
33 views

Retrieving Record from Top Level of a Nested For Loop

Still very much a trigger noob, so if there's a more efficient way to accomplish this, please let me know. Basically, this trigger should be creating a new 'In' inventory transaction every time an ...
0
votes
0answers
13 views

on insert/update standard [closed]

On Lead Insert/Update ensure that standard mailing address is same as custom mailing address and vice versa. Below are the custom fields created. If you insert/update lead standard email address ...
6
votes
1answer
83 views

Is it possible for two users to update separate records in the same transaction?

This requires a little context... I want to create a trigger that only fires when one record is being updated. It's a trigger that shouldn't be fired with bulk data manipulation. I've set it up so ...
1
vote
1answer
30 views

Custom Object Creation Trigger failing in Test only due to null Opportunity.Account.Name value

We have written a trigger that creates a custom object Opportunity Labor upon the insertion of an Opportunity. It works quite well in all aspects in the Sandbox, though fails during Apex testing due ...
2
votes
0answers
37 views

Sharing Records

I have an org that was recently updated to API 32, which broke some triggers that create Sharing Records. This code worked previously to the update to API 32. public void ...
2
votes
1answer
35 views

writing a trigger to mention reporter of a case

i have a tough time with Salesforce. How do i go about writing a trigger to specify the person who created the case as the reporter in the "reported by" field? this is code i have written trigger ...
0
votes
1answer
39 views

System.ListException: Duplicate id in list in Trigger

I get System.ListException: Duplicate id in list error in my trigger code. i haven't used single list in code. i used Set and Map in all places. Following is my trigger. trigger ...
1
vote
1answer
48 views

Rollup Summary to Calculate Weighted Average

As a child (master-detail) to my opportunity object, I have a custom object 'Transactions'. Each transaction has its own interest rate, transaction date, and amount. The opportunity has a term (in ...
0
votes
0answers
17 views

Invalid field isActive for SObject User in trigger (before update)

Can you please help me figure out why is the following code giving this error: 'UserBU : UserBU: execution of BeforeUpdate caused by: line 9, column 21: Invalid field isActive for SObject User'. The ...
0
votes
1answer
26 views

Able to perform DML operation on Read only object from trigger running with sharing

I have a trigger which runs with sharing. All I am doing in this class is updating or inserting another sObject on afterInsert or afterUpdate. Trigger is running in system context Profile/user used ...
1
vote
3answers
37 views

Unit test for trigger SOQL query that is uncovered

I'm having an issue finishing up my unit test, and I think it is related to the SOQL query in my trigger. The trigger itself checks to see, upon Lead creation, if a Contact exists with a matching ...
0
votes
1answer
33 views

Trigger to Update picklist value based child records picklist value

I have two custom objects Sale__c and Project__c. Both Sale__c and Project__c have different status in a picklist. Sale__c status is broken into two picklist Status__c and Status Detail__c ...
2
votes
2answers
39 views

Code Coverage 70% but I can't figure out how to make it to 75% or 100%

I am new to triggers. I will admit that but this is my first trigger and I really want it to work! My problem is that I still am receiving only 70% Code Coverage when the trigger works fine in ...
2
votes
1answer
18 views

Chatter Answers trigger not available in Eclipse - no access to trigger I know is there

I need to correct a known issue with Chatter Answers and one of the triggers that needs modification (chatter_answers_question_escalation_to_case_trigger) is unavailabe in Eclipse, i.e. I can't access ...
1
vote
1answer
32 views

Accessing lookup fields within trigger context

I have a custom object Customer with a few fields. One of the fields is a Lookup field that refers to a standard object Account. I'm writing a trigger that should fire before each insert/update. The ...
0
votes
0answers
29 views

How to write a trigger to send an email notification to author whenever a thumbs up/ down voting or a comment is given on a Published content?

How to write a trigger to send an email notification to author / designate whenever a thumbs up /thumbs down voting is done on a Published content? This following trigger doesnt work.It doesnt fire ...
0
votes
0answers
9 views

How to write a trigger to send an email notification to author / designate whenever a thumbs up /thumbs down voting is done on a Published content? [duplicate]

How to write a trigger to send an email notification to author / designate whenever a thumbs up /thumbs down voting is done on a Published content? This following trigger doesnt work.It doesnt fire ...
0
votes
1answer
30 views

APEX trigger error on Account Level Only

I'm new to coding and my developer friend and I have this APEX trigger to update a custom field on opportunities, based on recently created tasks. However, we can't create a task on the account ...
2
votes
0answers
31 views

Code coverage is 70% and I get a DUPLICATE_VALUE issue

Code coverage is 70% and when I dive into the problems I get a duplicate error. Please help I am new to writing triggers. Thank you ahead of time! Problem on several Lines Message: [object ...