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

The tag has no usage guidance.

-3
votes
1answer
42 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
29 views

Update records only if the Values are changed- Before trigger [closed]

Here is the scenario. Am calling a REST API which returns a list of data that am trying to create as a record. But I don't want to update the old Records whose values are the Same. (Say I have 100 ...
0
votes
1answer
16 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
0answers
29 views

Test class for Portal User creation

Name: PortalUserCreation Usage: This trigger is used to send mail to Portal User which are created from Self Registration Object trigger PortalUserCreation on ...
0
votes
1answer
17 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
32 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
24 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: ...
-1
votes
2answers
121 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
30 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
30 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
27 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 ...
-2
votes
0answers
34 views

FIELD_INTEGRITY_EXCEPTION, The time trigger value calculated by the Apex class 'XX' must be a positive integer.: []

public with sharing class CCT_ChatterFeedItemTriggerHandler { public static boolean isChatterFeedOperationExecuting = false; public void OnBeforeInsertUpdate(list<FeedItem> lstFeedItem){...
0
votes
1answer
45 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
25 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
35 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
11 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
32 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
289 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
70 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
11 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
95 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
43 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
42 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
31 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
18 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
56 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
33 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
59 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
121 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
53 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
263 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
45 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
39 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
110 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
33 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
47 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
279 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
204 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 ...
1
vote
1answer
188 views

Check parent field is null before inserting child record

As per my requirement,I need to check whether phone field of account object is null before inserting contact.If it is null,I should not allow user to create contact.I created trigger for this scenario,...
0
votes
1answer
64 views

Before update trigger is not fired after setting recursive method

I wrote a method inside my triggerhandler class to avoid trigger recursion. But even after that , before update is not getting called. I'm updating a datetime field(FieldA) from Process Builder. And ...
1
vote
2answers
39 views

In Before Trigger update would like to revert the entered values in Task except whoid

Requirement: After Task record is created then any update should not happen except contacts change (WhoID). I have written simple code in Before Update Trigger but enable to get the right syntax for ...
0
votes
1answer
27 views

I cannot delete a contact due to “System.NullPointerException: Attempt to de-reference a null object”

I have this trigger: trigger deleteContactReceiver on Contact (before delete) { List<Contact> con=Trigger.new; GDPRContact.deleteContactURN(con); } Invokes: public static void ...
-1
votes
1answer
112 views

Test Class for Before delete with Parent / Child related records

I have a Trigger that prevents a Service Agreement record to be deleted when it is currently associated with a Job record. Trigger SAJobsDeletion on Support_Contract__c (before delete) { try{ ...
1
vote
2answers
43 views

Apex class in trigger populates lookup based on string input

I am writing a trigger on my Case object to run (before insert). I am receiving the following error: System.DmlException: Insert failed. First exception on row 0; first error: ...
1
vote
1answer
33 views

Marking the Old Version of a Record After Trigger

This is more of an implementation question than code review. I am currently using the 'clone' standard button that triggers changes on the new cloned record. However, I also have to mark the old ...
2
votes
1answer
125 views

Lead before update runs on insert

I have a fresh dev org, with nothing at all in it other than this one trigger that is below. When I create a new lead, this trigger is ran. (ie, I put the new leads name as John Smith and Company as ...