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
Make your voice heard. Take the 2019 Developer Survey now

Questions tagged [trigger]

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

3
votes
1answer
103 views

Apex class invalid for community user but not standard

UPDATE: this might be a Spring 19 only issue. Will try to confirm this. If I create an opportunity with a standard Salesforce license, no problem. But if I try the same operation as a community ...
-4
votes
0answers
24 views

Apex Test class help! on junction object [duplicate]

trigger name application finding difficult to write the test class help would be appreciated trigger applications on Job_Application__c (after update) { set<id> candiadteIds = new set&...
4
votes
1answer
36 views

Weird Behaviour of Bulk ContentDocumentLinkTrigger in Test Context

I know that ContentDocumentLink triggers are not bulkified by Salesforce. I was expecting that behavior and was writing test classes accordingly. It looks like, ContentDocumentLinkTrigger doesn't ...
-2
votes
0answers
27 views

Test Class for Apex Trigger: Need help to write a test class for the following Trigger: [duplicate]

I am new to Apex and don't have much experience with test classes. Can anybody please suggest as to how to cover this trigger? Which points should I keep in mind or share a sample code which can help ...
0
votes
0answers
30 views

How to parse JSON String through apex [duplicate]

I want to get 'guid' and 'attachednotes'The attachedNodes is in different format. I think it is string array, but I am getting an error. { "messageHeader": { "triggeredBy": "manual", "...
0
votes
1answer
28 views

How to limit record creation on multiple objects

I am working on the requirement where I have to setup the limit on number of records created on 10 custom objects. So I have created one object called Limit__c which contains available_limit__c and ...
-1
votes
1answer
49 views

Apex Trigger After insert

For any account if we are inserting contact, then for the first contact primary__c check box becomes true, when we insert second contact then secondary__C check becomes true irrespective of primary__c ...
-1
votes
0answers
24 views

Not able to cover this class. help [duplicate]

Can anyone please take a look at my test class and figure out why the class is not getting covered. i am stuck on 27 % Here is the trigger: trigger checkActiveContacts on Contact (before insert,after ...
0
votes
0answers
34 views

trigger not working on update on picklist values

I am working on a trigger which will count the child records to parent basing on some picklist value conditions. If picklist field values= "son, Daughter, Husband, Wife, Partner" then I need to count ...
0
votes
1answer
49 views

i want to update the password into ***** after inserting the record.am acheivinng it using before update how can i do it using before insert [closed]

please bare with me am new to triggers. lead and account are the two objects. by using before insert i have to update the fields like lead object: name,password into account : name,password. my ...
0
votes
2answers
31 views

Bulk data loader operations:: System.LimitException: Too many SOQL queries: 101

I am getting an error while performing data loader operations on the Leads object as I get this error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY:LeadTrigger: System.LimitException: Too many SOQL ...
0
votes
4answers
45 views

Trigger counting twice on child records

I wrote one trigger which will count the number of child records and update it to parent object field. If I create 2 records then count is giving 4 instead of 2... Please help me to overcome the ...
1
vote
0answers
47 views

Apex trigger Causing issue

I wrote an Apex trigger and when I try to delete a record then its giving me the following error. "There's a problem saving this record. You might not have permission to edit it, or it might have been ...
0
votes
1answer
64 views

update case status for multiple order updates

Need help to modify a trigger to update the Case status if Order status changes. below trigger is working but seems if for only one Order status change. need to modify the trigger if ALL Order records ...
0
votes
2answers
30 views

Fire workflow rule from trigger

Is it possible to cause a workflow rule to fire from a trigger? I would like to send an email to a group when the Owner field is changed to a specific value on the PSR object. But I'm getting the ...
1
vote
1answer
44 views

RecordType name in IF

I am struggling with how to select record type in Apex. I have been given some examples, but I still don't get it - sorry if it already has been answered somewhere - I am very new to this, so I guess ...
1
vote
2answers
36 views

Need help with test class for code coverage on AccountContactRelation Object

I've been working as an admin for my org for the last few months. After my move to Lightning, we needed to use the AccountContactRelation object to be able to mark a contact as the primary contact on ...
-1
votes
0answers
34 views

Record Type in Apex [duplicate]

I am struggling with how to select record type in Apex. In the following example, the code never puts 'A' in RT__c field (always 'other'). There are 2 record types 'A' and 'B' (names & developer ...
-2
votes
1answer
34 views

Account Sharing Error: INSUFFICIENT_ACCESS_ON_CROSS_REFERENCE_ENTITY

this is apex sharing code, but the problem is this when I'm creating acc, entering parentId of acc which I have created as demo user, error public class ManuallyShareAccount { public static void ...
0
votes
1answer
29 views

Is UserInfo.getUserId() always the current user where bulkifying needs to be handled?

I know you must Bulkify your code. Does this mean you have to expect UserInfo.getUserId() to be different users? I.E. Can the same trigger can be called on multiple records for multiple users in the ...
0
votes
0answers
35 views

Case trigger to match my account Trigger

Very new to Triggers and hoping this is a simple replacement of text in the code we already have working in the Account object that was built when we had a Dev support. What I'm trying to do is make ...
-2
votes
1answer
40 views

recursive trigger on junction object

I'm getting an error while updating status how to avoid it trigger applications on Job_Application__c (after update) { set<id> candiadteIds = new set<id>(); List<...
0
votes
0answers
23 views

Case milestone conclusion by the user doesn't seem to trigger the process builder?

I'm working on a service system on which the case has a field called "observations". When the case's status change the system is supposed to copy its content to a big object related to the case record,...
1
vote
0answers
33 views

Messaging.renderemailtemplate() fails with error: System.EmailTemplateRenderException: UNKNOWN_EXCEPTION: java.lang.NullPointerException

I am trying to render an email using the method: Messaging.renderemailtemplate(), by passing three parameters: templateId,whoId ( user ) ,whatId ( Custom Object ) from a Trigger. The insertion of ...
-4
votes
2answers
45 views

how to call discount field from opportunity on totalprice field on related opportunitylineitem [closed]

set<id> opps = new set<id>(); list<opportunity> lst = new list<opportunity>([select id,discount [select id,totalprice from opportunitylineitem ] from opportunity where Id IN : ...
-1
votes
1answer
94 views

TRIGGER to update related records on Junction object

My scenario is One candidate can have a multiple Job application, custom objects are candidate__c(lookup to job application) Job_Openings__c(lookup to Job application) Job_Applications__c(junction ...
0
votes
1answer
30 views

I'm getting errorError: Compile Error: Variable does not exist: i at line 7 column 5

trigger InsertContacts on Account (After Insert) { if(Trigger.IsAfter) { system.debug('new Account Record is'+ Trigger.new); List<Contact> conList = new List<Contact&...
0
votes
1answer
26 views

Assign case to the least occupied person in team [closed]

I have a requirement to assign the cases based on the user's capacity in a specified group. There are 20 users in a team. I need to check the capacity of the user whose capacity is less than other, ...
2
votes
1answer
43 views

How can I change the status of Trigger MetaData using Apex Programming(Tooling/MetaData API)

I am using this code to update metadata for trigger. public void createMetadataContainer() { HttpRequest req = createHttpRequest(endpoint+'/MetadataContainer','POST'); req.setBody('{"...
0
votes
1answer
96 views

Exception in @Future Method - System.QueryException: Record Currently Unavailable

I am facing error in one of future method (calling from trigger handler). This error occurs when integration event submit these record in bulk but when i am doing this from UI i do not get this error. ...
-3
votes
1answer
36 views

how can i write code to avoid same email of listed contacts [closed]

List <contact> con = new list<contact> map<id,contact> cont = new map<id,contact> For (cont em : con) { con.put(em.email,em) } You have a list of Contacts. From this list, ...
0
votes
0answers
20 views

Queueable method is not returning the updated values in test class

I have a trigger which passes the list of objects to a queueable method, the queueable method performs the DML on the related parent/child objects. In my test class when I insert a record, the ...
-3
votes
1answer
61 views

error as Method does not exist or incorrect signature: void writeStringField(String, Object) from the type System.JSONGenerator [closed]

trigger CM_FieldMappingTrigger on Campaign (before update) { //dynamically get the fields from the field set and then use the same for comparison in the trigger. Map<String, Schema.SObjectField> ...
1
vote
1answer
31 views

AggregateResult throws error: System.ListException: Row with null Id at index: 0

I have this Apex SOQL query: Map<Id, AggregateResult> results = new Map<Id, AggregateResult>([ select accountid id, min(id), min(Partner_Admin_Sequence_Number__c) Integer from ...
1
vote
1answer
56 views

Error: Future method cannot be called from a future or batch method

I have a managed packaged that I recently updated and it threw an error for a future method I have that sends information to a third party. The error I received was: Future method cannot be called ...
-2
votes
2answers
32 views

Test Class for Logicless Trigger

I have a trigger that calls another class and doesn't have much code in it aside from this: List<Account> accounts = new List<Account>(); if (Trigger.isBefore) { if (Trigger.isInsert) {...
0
votes
0answers
10 views

Null result on parent Account field [duplicate]

I would like to compare a field on the Opportunity to one on the Account to validate them. My string AccountClassif = o.Account.Account_Classification__c; is debugging as NULL when it has a value. ...
1
vote
2answers
26 views

Change Primary Contact on Insert

So I managed to change the Primary Contact for a specific account on Update, but I can't figure out how to do it on Insert. I'm guessing it should be very similar to the update trigger. Could you guys ...
0
votes
1answer
19 views

how to compare emails with trigger in two objects

Good morning, I'm new to the apex trigger world and I have a problem. I need to create a trigger that compares me to the emails of leads and if it coincides with an email of "Candidato_wifi". Do not ...
-1
votes
0answers
15 views

I have a requirement to update “SSO workflow” object related contact field, when an associated contact is inactivated

SSO_workflow__c is lookup to contact and account. On contact i have one field called partner_admin_sequence_number__C field, which is having values like 1,2,3 etc. Each contact with partner admin seq ...
3
votes
2answers
30 views

Why does default Profile based default record types not work in DML Upserts?

I have an integration which inserts Person Account records into my Salesforce org. Sometimes the integration doesn't include a LastName (if the user hasn't provided one) which causes the integration ...
1
vote
1answer
23 views

How to set ParentID field on Account record related to contact in a Trigger?

I have a trigger that is firing on before insert on the Contact object. I am trying to set the parent ID field on the Account record that the Contact is associated with. I can't seem to access the ...
1
vote
3answers
54 views

How many times a trigger is fired when a record is updated?

Could someone explain me how many times a single trigger is fired when a single record is updated? I cannot paste the whole debug log because of it's size this is just a part of it. 12:35:37.830 (...
1
vote
1answer
28 views

Replacing Process builder with an Apex Trigger. Should the process builder be inactive during trigger deployment?

We have an active Process builder which runs in Afterinsert context on CPQ Quote creation. Due to certain inefficiency and enhancements, we have replaced it with Apex Trigger. However, during Trigger ...
1
vote
1answer
23 views

need to throw an error on specific record from list

I have below method and error is coming beacuse of some validation/trigger is on account and need to catch the exception If i am runnning this from Ui for one record this will throw an exception as i ...
1
vote
1answer
41 views

How to use the isUpdate() trigger handler on lookup relationship?

I have a custom object Hire_Form__c that has a contact lookup. It has the following fields: First Name Last name Email Phone Status (In Progress , Completed , Rejected) Candidate (Contact Lookup) ...
2
votes
1answer
38 views

Trigger not updating Lead.State before update/insert (state/country picklist use case)

We are using the Salesforce State/Country picklist and the integration values used for US States are state codes, e.g. CA, WY, AL, etc The salesforce AppExchange sends the leads to Salesforce and it ...
0
votes
2answers
33 views

Updating Apex failed: DmlException in (unrelated) Test

I am trying to update the code of a Contact Trigger handler using the Force.com IDE. However, deploying does not work because of an error in an unchanged 3rd-party class. Even if I uncomment all ...
0
votes
1answer
35 views

Avoid duplicate lead name creating instead of lead name , update all details using Trigger

This trigger is basically fired on before insert & before update. I am trying to automatically convert lead to Account,Contact & Opportunity. My condition is when an Same Name Lead is inserted ...
0
votes
1answer
74 views

Trigger Exception on data Loader

I have written a trigger to create/update a contact when account is created/updated. Every account will have one contact associated with it. When i try to load the data from data loader in to account ...