Questions tagged [trigger]

A trigger is a feature of the Salesforce platform consisting of Apex code that executes before or after DML operations.

Filter by
Sorted by
Tagged with
0
votes
0answers
26 views

Apex - Approval Process - getting INVALID_CROSS_REFERENCE_KEY when calling Approval.process()

The class below has a method that runs on an After Update Trigger for a custom object. It attempts to automatically Reject the approval process when a picklist field (Work_Sub_Status__c) on its Target ...
1
vote
1answer
19 views

New Line Apex Trigger on Contact Page (Not Visualforce)

For this trigger: trigger CompileQuickNotes on Contact (before update) { for( Id accountId : Trigger.newMap.keySet() ) { if( Trigger.oldMap.get( accountId ).Log_Notes__c != Trigger....
-1
votes
0answers
17 views

Create a Hierarchical custom setting “TriggerSetting“. Create fields for all triggers developed in your system [closed]

Create a Hierarchical custom setting “TriggerSetting“. Create fields for all triggers developed in your system.This custom setting should be used to enable/disable any trigger from your org.
0
votes
1answer
38 views

Trigger an API call after status change in real-time

Our client would like to manage their opt-outs and -ins in a real-time manner and apply them in their customer database via an API call (most probably REST). So as soon as a subscription status ...
0
votes
0answers
7 views

Can't create trigger on entity-subscription object? [duplicate]

I was going to try to write a trigger on the entity_subscription object. It doesn't show in the sObject list when creating the trigger. Does that mean it can't be used for a trigger?
0
votes
0answers
13 views

Email to follower when Follow button on a record is clicked

I have a follow button on a custom object's record. When a user clicks the follow button, I want to send him an email indicating that he is now following the record. Are there ways other than ...
1
vote
2answers
40 views

SOQL Query Exception Non Selective Query in after insert Trigger

I am loading contacts records and when my after insert triggers runs I am getting the following error: System.QueryException: Non-selective query against large object type (more than 200000 rows)...
0
votes
1answer
40 views

Trigger to Increment the Number value when new Lead is created when Lead Country is india

My requirement is that when i create a lead with country as 'india', there is a custom field named 'India_Auto_Number__c' where it should update as 1, and again when i create a lead with country name '...
0
votes
0answers
22 views

Trigger on Lead Object not working [duplicate]

I have a requirement in which I have to create a custom lookup field on lead object which selects the account Account__c and during the lead to account conversion I have to map the field with 'Parent ...
1
vote
2answers
213 views

Code Coverage Failure trigger deploy on production

i have a code for trigger: trigger SendDisbursement on Opportunity (after update) { if (!System.isFuture()){ for (Integer i = 0; i < Trigger.new.size(); i++) { if (Trigger.old[i]....
0
votes
2answers
37 views

Why would you ever use workflow field updates if custom validation rules are in place? [closed]

I have been researching on what is the better of the three (Triggers/Workflow/Process Builders) to make field updates or to perform any action which can be performed by all the three tools. However, ...
0
votes
0answers
19 views

insufficient access rights on cross-reference id while updating records through community portal

As a portal user while i am updating case records getting "insufficient access rights on cross-reference id". Thanks in advance!
0
votes
0answers
15 views

Approval process test class unanimous approval required

I have a trigger that grabs approval comments and updates a custom field on an opportunity record. I am able to get 100% code coverage on test class when approval process requires one approver. ...
0
votes
1answer
18 views

How to create Box.com user from Salesforce Community User record?

I am looking for a way to create a user within Box.com if the user does not exist in Box.com after a Salesforce Community User record is created. How can I create a user in box.com if one does not ...
0
votes
1answer
45 views

Trigger Compare Old and New AccountOwner of a Contact

I am having trouble comparing the old and new owner of the Account associated with the contact to achieve #6 of the requirement. Can someone please suggest how I satisfy condition #6 in the logic. ...
3
votes
3answers
58 views

Can a trigger with error ruin the batch it was fired from?

Consider I have a batch class which updates 50 records of Task. The batch class ran successfully and updated the Task records.Now the Task object has a trigger that runs on after/before update. Due ...
1
vote
0answers
79 views

Get Multi select picklist and update corresponding category using custom metadata type

We have a Custom Metadata Type which shows the relation between a product of interest and categories. When a product of interest is selected we would like the corresponding categories to be selected. ...
0
votes
1answer
46 views

Map lead custom field (Account__c) with Standard Account field 'Parent Account'

I have a requirement in which I have to create a custom lookup field on lead object which selects the account Account__c and during the lead to account conversion I have to map the field with 'Parent ...
-1
votes
0answers
22 views

Age of GRC Approval (in days) should calculate when: [closed]

Issue: Age of GRC Approval (in days) should calculate when: Kit Review Status = Approved Date calculation is captured from Kit Review Status date to the current date. Calculation should STOP ...
-1
votes
2answers
40 views

Metadata and apex triggers [closed]

I have a requirement as follows: Create metadata and fields in this metadata the fields should be equal to the Number of apex triggers present. The fields created in metadata should be of type ...
-1
votes
0answers
24 views

Trigger to update the fields in the same object

i am stuck with the following trigger, my Requirement is that, when i create a new lead, the Values which are present in the Formula field, needs to be updated in the normal Custom text field, Now ...
0
votes
1answer
21 views

How to pass the parameter from trigger to validation rules?

I have a trigger on Contract Object, whenever the Contract record is updated the contract section in the associated opportunities will also get updated with the latest Contract data but while updating ...
-2
votes
0answers
19 views

Email Message Object or Case Object Possible to Email Alert…??? How can we Achieve Can we Please Help Me [closed]

I am Newly in salesforce Support Process Team... when ever email is send case will be created(Email To Case) and sub case is created. when ever sub case is created Pearent case status will be ...
0
votes
3answers
35 views

Trigger not updating last login from user to account object

I created one trigger on the User object which will update the last login to account if the account name matches with user.Name field. but somehow my trigger is not at all updating the LastLogin ...
-1
votes
1answer
52 views

Need superscript of # in apex

I have one string which needs to change with Superscript string str="ABC#"; I want add replace superscript with #. please suggest Let me Explain with Example Suppose I enetered a string **My Name ...
0
votes
0answers
20 views

Email Alert possible to Email Message object ? if it is possible ? how can we achieve in salesforce? [closed]

Setup-->Home-->workflow -->Email alert--> New email alert -->Object (Drop down field ) In that Object drop down field we required to list the "Email message" Object also
0
votes
1answer
23 views

Recursive Before Update Trigger Overwriting Saved Value with Null

I have written apex code so that when a new opportunity contact role is added to an opportunity and the contact has certain data, then two fields are updated on the opportunity, a datetime field and a ...
3
votes
1answer
112 views

Value Of Object After Insert Remains The Same

I've a simple conceptual doubt - Would really appreciate if someone would explain me the reason for this behaviour: I'm inserting a new contact from console and following is the snippet: Contact c = ...
0
votes
1answer
25 views

Update OpportunityLineItem before insert/update

I have built a trigger to update Opportunity Line Items discount based on quantity before insert/update. There are custom fields to define the quantity tiers and discount to be assigned. The code is ...
0
votes
0answers
47 views

Verifying Marketing Cloud API calls

So I'm new to the Dev. Forums, and trying to learn as much as I can while studying for my MC admin and developer certs, so forgive me if this question isn't clear. In Marketing Cloud we have a lot of ...
2
votes
1answer
30 views

Trigger can created on UserServicePresence while Salesforce doc says it is not supported. Can we package the trigger as well?

Trigger on UserServicePresence object can be created after we enable omnichannel. Can we package this trigger? As target org can be having omnichannel settings disabled. Salesforce doc says trigger ...
-1
votes
1answer
17 views

Test Class For Http callout Post [duplicate]

Kindly Provide me a feasible solution to write the test class for this below code` public class ActiveCampaign { @future (callout=true) public static void createUser(String Email, String FirstName, ...
1
vote
1answer
44 views

Account Trigger on owner change to restore ownership of contacts not owned by the new owner

I am having issues getting sucess with my account trigger. Would really appreciate someone taking a look. I can't even get a compile :( The requirement I am trying to code for is this. If I have ...
1
vote
2answers
35 views

Migrating Sandbox to Production Apex Trigger Error

I recently put an Apex Trigger into production. Here is the code: trigger FlagMLSTasks on Task (after insert) { //if mls alert subject Task t = [SELECT Id, Subject, CreatedDate, WhoId FROM Task ...
0
votes
1answer
52 views

Before Trigger on Contact update

My requirement is very simple. Whenever a contact filed (Building_Number__c) is updated, update the related account field (block_number__c). I have written code below code for that. My questions are ...
1
vote
1answer
77 views

APEX trigger lookup field value in onther custom object

This is what I have: trigger ComplaintInitialize on Complaints__c (before insert, before update) { for(Complaints__c Complaint : Trigger.new) { if(Complaint.RecordType_Name__c == '...
1
vote
1answer
61 views

Apex Class + Trigger to populate Lookup field

I have an Apex Class: public with sharing class Lookup { public static void findOpportunities(List<Custom_Object__c> records) { Set<Id> OppsIds = new Set<Id>(...
3
votes
0answers
67 views

Platform Event Trigger won't execute in subscriber org but in scratch org

In my Managed Package, I have a trigger for the Platform event Notification__e. The publish behavior is Publish Immediately. When I publish an event via Workbench or Developer console in one of the ...
-2
votes
2answers
59 views

Trigger not updating as logic [closed]

In below code user__c is lookup to user, but o.owner.id == s.user__c is not taken when saving the record. public class OpportunityTriggerHelper { public static void ...
-1
votes
1answer
37 views

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

I have tried to write a trigger on custom object Project(), which is having lookup to asset. an asset can have many type of projects including "Collocation", what i am trying to achieve is: to ...
5
votes
2answers
116 views

DML operation simultaneity from different users

If I have a trigger on Account for example , What happens if several users update different accounts on the same time (user 1- Account a, user 2 - account b, user 3 - account c)? Is there one trigger ...
0
votes
2answers
31 views

How to write a test list of the Trigger [duplicate]

I am very new at the development. I finish writing the Trigger but have no idea with the test code. I trying to write the test code but get 0% of code coverage. Here is my Trigger and test code. ...
0
votes
2answers
44 views

Trigger and its test class

I am new to Salesforce. I have written a trigger to update contact based on account field. The Trigger code is below. trigger Update_contact_based_on_acc on Account (before update) { List<...
1
vote
0answers
32 views

Create dynamic triggers based on user selection from managed package [duplicate]

I have a requirement where I need to create two triggers inside a managed package. So, when the package is installed, the admin has a choice to either use the default objects available in the package ...
3
votes
1answer
44 views

Does locking of account lock related contact during insert?

I have a WSDL Apex service that consumes XML and creates a series of objects. XML received and parsed, queries for and finds a single account "Potential Customer" to relate potential customer ...
1
vote
1answer
28 views

iterating list values to update multiple fields

Though the below code is working fine, since its not the right practice to hardcode index numbers so is there any alternate approach for the below code. - thanks List<Contact> cntList = [...
0
votes
0answers
52 views

Break a list of id's to multiple list into equal number of records [duplicate]

I have created a list of id where i am adding record id of a custom object. List<Id> validProjectId = new List<Id>(); validProjectId.add(project.id); Now that this list has suppose 1000 ...
0
votes
1answer
27 views

After Insert trigger behaviour if insertion execution fails

I have a custom object named 'shift_cancellation__c'. This custom object records are being populated by parsing an email. I have a class named 'shiftCancellationListener' that parses the emails and ...
0
votes
1answer
53 views

APEX CPU Limit Exceeded

I am currently receiving an APEX CPU Limit Exceeded error when trying to save work orders. This is happening with any field updated. The error received is RG_WorkOrderTgr: System.LimitException: Apex ...
0
votes
1answer
41 views

Code Coverage=0%

my developer createed the following trigger and Apex Test Class. For some reason, the coverage is 0%. I need to deploy it ASAP and he already left for the rest of the week. any help is highly ...