Stack Exchange Network

Stack Exchange network consists of 174 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [before-trigger]

The tag has no usage guidance.

0
votes
1answer
27 views

Ignore validation on before update/insert trigger?

I have a before insert/update validation trigger which I would like to be able to ignore when doing mass updates via data loader. Figured if I just add criteria of "checkbox field = true, ignore ...
0
votes
0answers
21 views

Trigger in working as expected in inline editing , But it is not not working when I click the edit button

Hi Folks I have a requirement to copy the case contact id to the task (WhoId) Field. Logic I implemented. 1: Check the task whatID is not blank and the whatId starts with 500 (Case Prefix Which ...
0
votes
1answer
22 views

Prevent Record Update Synchronously via External HTTP Call

I'm integrating Salesforce with an external system, and updates to records in Salesforce need to be kept in sync with the system. If the request to the external system fails, the update in SF should ...
0
votes
1answer
27 views

Updating records when related record is inserted

I have written at shipment insertion to update the shipment's expedited checkbox to be true, and then in the after trigger, it should update all the packages that have the newly created shipment to ...
0
votes
1answer
24 views

Update existing AccountContactRelation in before insert trigger

I have a custom field on my AccountContactRelation object, called SurrogateId__c, that has to be unique across all AccountContactRelation. I have the following code that is called upon before insert ...
1
vote
1answer
22 views

How to test or replicate : System.QueryException: Non-selective query against large object type

In our org, there are 220k existing user record, Based on this previous code : public static void assignOwnerId(List<Inventory__c> invList){ List<User> userList = new List<User&...
0
votes
0answers
25 views

Trigger.new does not contain new value

I have a trigger where I want to lookup values in another table and populate a field. Why doesn't trigger.new contain the new value? The debug shows a null value even though I'm setting the ...
2
votes
1answer
34 views

Failure setting lookups in triggers when upserting multiple records of different types very quickly

I have an integration app that polls records of different types from an internal database every few seconds and upserts them into Salesforce. I have two pollers that run independently from one another ...
0
votes
1answer
62 views

Before update trigger is not working

I have two objects, which is used to populate the field value from product object to quote lineitem object. Both the objects have unique field name (CPQQuoteLineItem__c --> Product_Code__c, product --...
0
votes
1answer
21 views

Issue on creating auto number field

I need to create an auto number field on custom object in packaging org. I'm not able to create it now because it's throwing an error while creating it: you cant able to create auto number field ...
-1
votes
2answers
65 views

Is it possible to prepopulate field using a before insert trigger?

trigger MyTrigger on Benifit__c (before insert) { Set<Id> lookupIds = new Set<Id>(); for (Benifit__c b : Trigger.new) { if (b.company__c != null) { lookupIds.add(...
-3
votes
1answer
48 views

Apex trigger, return string, calling methods and code correction needed

Please explain what is wrong as I have problems writing methods, and correct the code if you can. Error: Compile Error: Variable does not exist: a at line 11 column 16 trigger tokenGenerator on ...
0
votes
2answers
32 views

Create list of records in Before and delete the list in After Context

I need to write a trigger on Case object where I need to delete the placeholder records and relate the case to existing records. I need to prepare the list of placeholder in before context and delete ...
0
votes
1answer
27 views

Random String Generator without duplicate values

What needs to be added (an SOQL query perhaps) in the 'else if' statement which checks the value within the c.Name column and tells if the generated random string already exists, and if so add break/...
0
votes
1answer
20 views

Can a Random String Generator create duplicate values, if so how to stop it?

I want to know whether this code can create multiple instances of the same random number by any chance? Can i make this specific field to not have same values within salesforce it self? trigger token ...
0
votes
2answers
39 views

add error method returning a null pointer exception

In a before insert trigger I added an addError message, but the error message is not showing, instead I get a NullPointerException. This is my code: trigger ValidateNIF on Account (before insert, ...
0
votes
0answers
28 views

Passing a validation function in JavaScript to apex

I have a function written in javascript to validate a field and i need to transform that function to a before insert trigger. I'm a bit of lost in how to do this. This is part of my function: ...
-2
votes
2answers
213 views

update field with a trigger in custom object from pricebookentry

I have a custom object custom__c with couple of custom fields that needs to determine the price of the product. Custom_Child__c is a lookup field that gets the product. Price_Book__c is a lookup ...
0
votes
1answer
31 views

OrderTrigger: execution of BeforeUpdate caused by: System.NullPointerException: Attempt to de-reference a null object

I got stuck at one place on one of my requirement on which I am working on. My use case is as follows: SCENARIO 1: Close Opportunity when Upgrade Order is cancelled GIVEN a a person account record ...
0
votes
2answers
34 views

Test trigger before insert

I'm trying to test a test a trigger that adds an error if the field Active__c is set to true on CreditInfo_Eval_Rules__c (son of CreditInfo_Fields__c) and the field Used__c is updated to false. I'm ...
0
votes
1answer
34 views

SObject row does not allow errors: error updating record

i'm getting an error from updating or saving a record on the following trigger: trigger ActiveSave on CreditInfo_Eval_Rules__c (before insert, before update) { for(CreditInfo_Eval_Rules__c ...
0
votes
1answer
67 views

Using Maps instead of nested for loops in APEX

Hi i'm really new to Salesforce development in the following code I'm trying update existing record to inactive but, not the coming record on two different conditions. I'm a bit confused in the last ...
1
vote
1answer
26 views

How to test a change OwnerId by groupQueue.Id?

I have a trigger. If a user who creates a record isn't 'Manager' (UserRole.Name) - record's OwnerId change to GroupQueue.Id. I have a correct test method for scenario, where user-creator is 'Manager', ...
0
votes
1answer
31 views

State and country:There's a problem with this state, even though it may appear correct. Please select a state from the list of valid states

During the state and country activation for my instance, some state fields were set to undefined value. I guess it could not be mapped with any state. Even when I go into that record and try to update ...
-1
votes
1answer
40 views

If condition is met trigger will fire and clone the record to Salesforce Standard Object

TriggerHandler class: public static void onBeforeUpdate(Map<Id, Apttus__APTS_Agreement__c> oldMap, Map<Id, Apttus__APTS_Agreement__c> newMap){ List<Apttus__APTS_Agreement__c> ...
0
votes
0answers
14 views

HTMl Email Template with letterhead in triggers

I created an email alert in a trigger.it's not displaying images(custom html).how could i send email alert with HTML template with letter head.I dont think it doesn't support.is it? below is my code. ...
0
votes
1answer
45 views

Event and EventRealtion

I am trying to create an event and upon creation of Event i am creating EventRelation to add attendee. While creating Event i am prepopulation some fields in before insert. If i am prepopulation Type ...
2
votes
1answer
469 views

APEX Lock and Unlock a Record

I wanted to lock and unlock records based on a check box. I know that you can do this stuff via a validation rule but I think that is difficult to maintain if adding fields. I wrote an apex trigger ...
0
votes
1answer
35 views

Fire the Trigger only if record is being entered through classic UI not from the communities

I've a requirement that the Trigger should fire only when the Lead record is being entered through Slaesforce classic UI, Trigger should not be fire if the record is being entered by communities or ...
2
votes
2answers
81 views

Query becoming non-selective with null values

In the query I asked here - Confirm if sub-query is selective? , is there a chance of the top level query becoming non-selective if conAccMap.values() has null values? Below is the query: [SELECT Id,...
0
votes
0answers
16 views

Can you use a FeedItem trigger to hide Entitlement Feed Items to change visibility?

I found a idea on the Salesforce community that I need to implement. https://success.salesforce.com/ideaView?id=0873A000000lIYcQAM So I am asking if anyone has had any luck on using a trigger on ...
3
votes
1answer
71 views

Confirm if sub-query is selective?

I have a query in a before-update trigger that looks like following: [SELECT Id,(SELECT Id,Active_opp__c FROM Opportunities ORDER BY Days_from_Last_Stage__c ASC) FROM ...
1
vote
2answers
96 views

Why is my flag not working on maximum trigger depth exceeded

I have written a trigger for purchases if the purchase contains several of the same purchase detail items they should be summed up and merged as 1 purchase detail. When I use a before insert I get in ...
0
votes
1answer
68 views

How to write a trigger handler with trigger new [closed]

I am having some trouble to translate my trigger to a trigger handler how do I deal with the for(Invoice__c record:Trigger.new) part? Trigger: trigger UpdateAutoNumber on Invoice__c (before insert) ...
0
votes
2answers
60 views

Is it possible to executive Trigger before the lead assignment rules?

I Just want to know is there any way that we can executive trigger before the lead assignment rules. My Case: I have one before insert trigger in the lead, here in this trigger I'm checking company ...
0
votes
1answer
39 views

using the trigger framework for before update

I am using the SFDC trigger framework to force a particular field of the Order Object to be always the same. for example, if the the user enters on the field Status 'Active' I want to automatically ...
0
votes
0answers
21 views

Cloning Old Record Versions for a Parent Lookup

Composer__c object has a lookup relationship to the Song__c object. Song__c has a lookup relationship to the Song_Usage__c object. Song_Usage__c has a lookup relationship to the Event__c object. ...
-4
votes
1answer
67 views

How to capture first response on case via trigger?

I need to create a way to capture when the first response. I then need to measure how long time between when the Case was opened and when it was first responded. I created two fields: ...
0
votes
1answer
35 views

How do I stop my Trigger test from firing the Trigger twice?

I've got a trigger in place to count how many times a field has been updated: trigger IncrementClosedCounter on Opportunity (before update) { Opportunity[] oldOpp = Trigger.New; Opportunity[] ...
2
votes
1answer
62 views

Logic written in AfterInsert does not finish when beforeUpdate is called

We are creating OpportunityLineItem through Apex, now in isAfterInsert we are creating a Test object record whose Unique_Key is same as OpportunityLineItem unique_key. Now attaching the 'Test' to ...
0
votes
2answers
227 views

Fire Validation Rule from Apex

Is there a way to fire an existing Validation Rule from apex. Specifically, I want to fire the rule during a "before delete" trigger.
1
vote
1answer
55 views

How write tigger Insert & update other records same object with update query

I have this trigger where I insert a record. On the insert I want to check on birthdate and set a checkbox on true for the record with the oldest birthdate related to same Household/Huishouden__c. ...
0
votes
2answers
363 views

Invalid loop variable type expected SObject was Relatie__c

I am trying to make an trigger handler from which I took the logic from the trigger and placed in the handler. Before i can save my handler I get the error: Invalid loop variable type expected ...
3
votes
1answer
47 views

DMLException handling in a Before trigger context?

I got 99% of the way through refactoring a trigger from "after" to "before" when I noticed one little thing I'd overlooked when judging whether or not to do it: My trigger copies data from "holding ...
0
votes
2answers
42 views

Trigger handler - query separate object based and update record

I have a before insert trigger I'm struggling to design properly in a bulk manner. Here is what I would do in a non-bulk fashion - my challenge is that I'm not using the ID of the trigger object in my ...
1
vote
1answer
118 views

Custom Validation using Trigger throwing System.FinalException: SObject row does not allow errors

I am trying to addError on the opportunities based on one condition. But getting System.FinalException: SObject row does not allow errors error while saving the record. Below I have given the code ...
0
votes
1answer
34 views

Trigger that saves all the activities and events of a contact before a contact is deleted [closed]

Trigger that saves all the activities and events of a contact before a contact is deleted. When a contact is deleted all the history related to that contact is deleted.
0
votes
1answer
52 views

Apex Trigger not recognizing with Start Sync button is clicked

Background: Our company works in print media and when we sell ads for our magazine, our reps fill the fulfillment information out at the Quote Line Item object. Our accounting software can only ...
0
votes
1answer
334 views

Check For Special Characters in Emails

I'm having a business requirement of searching special characters in Email Field(before @domain.com)in a trigger. For Ex: if a email is like this (t#@est@gmail.com).it should be able to identify the'#...
0
votes
1answer
252 views

Throw error message and capture it in error log custom object

there is a requirment where when data is upserted in bulk from external system, we need to check for certain criteria, if it does not match, we should prevent the insert/update and log the error in ...