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

learn more… | top users | synonyms

1
vote
1answer
16 views

Trigger to add a Community User on ticket submission [on hold]

Anybody know how to do this? I'm not too familiar on how this process would go about being accomplished. Any help would be greatly appreciated!!
0
votes
2answers
39 views

Too many DML rows: 10001 issue

I have a trigger that works perfectly in my sandbox. When I try to deploy, I get the following error message: receiving_Tests.receiving_Trigger_Tests(), Details: System.LimitException: Too many ...
0
votes
0answers
12 views

Sync Track trigger not working

This might be not directly a salesforce issue. I work in Veeva. There is sync tracking custom object in Veeva where records of User syncronization from Ipad is stored. I have to run a after insert ...
0
votes
1answer
24 views

Compile Error: Loop must iterate over a collection type: SOBJECT:FeedItem

I am new to Apex and I have the following code to call a function each time a new Chatter post is created: public class MLPost { public static void MLPostCreate(FeedItem post) { for ...
1
vote
0answers
19 views

Apex Trigger from Managed Package - throwing error in community

We have installed a Rio Inventory+ Managed Package into an Enterprise edition Salesforce instance. (Appexchange link: https://appexchange.salesforce.com/listingDetail?listingId=a0N30000009xLvGEAU) ...
1
vote
1answer
11 views

Sync object not getting keyset

I have a custom object of Sync Tracking that allows to keep track for Users , when they are doing a sync from their ipad to salesforce. Now I need to write a trigger on that object, Sync Tracking ...
0
votes
1answer
17 views

How to update Custom look up field to user in Case with Account ownerId which is lookup to user using Apex Trigger

trigger Example123 on Case (before insert, before update) { public List <Account> lstAcc = new List<Account>(); public Id accountOwner; /* For (Case c : Trigger.new){ ...
-1
votes
1answer
28 views

After delete trigger SOQL returns no rows

I need help I'm losing my mid. I have a working trigger and I'm writing a test class. My data is isolated ( no @seeAllData=true) I create a master and children objects in my set up. I insert the ...
3
votes
1answer
36 views

Why does this code throw an error when trying to create a Person account?

Code trigger CreatePerson on Contact (before insert) { RecordType personAccountRecordType = [SELECT Id FROM RecordType WHERE Name = 'Person Account' and SObjectType = 'Account']; ...
1
vote
0answers
16 views

Is it possible to make this workflow happen with Triggers? [duplicate]

We're trying create a trigger that will fire when a new contact is added to SF (that contact is created via the Hubspot connector). Is the workflow below possible through triggers / Apex code? (I'm ...
1
vote
2answers
37 views

Best Practice for Automatically Setting Name Field on Object with Trigger

I plan on setting the Name field on an object automatically. I will be using a trigger Before Update/Insert to concatenate a few fields into the Name field. The problem is that, by default, ...
0
votes
2answers
42 views

Help me to Get Bulkifying trigger [duplicate]

My Trigger is here. Invoice is custom Object which have Look up relationship with Account. Help me with bulkifying this Trigger. trigger InvAmountUpdate on Invoice__c (After Update) { ...
4
votes
2answers
49 views

Does one use savepoints in triggers?

It's not clear to me. Suppose I write an after update trigger on opportunity to update some related accounts and then contacts. Now I lets suppose that I had luck with the accounts but the second ...
0
votes
1answer
23 views

Rollup via Lookup Issue

I put together a trigger that will perform a rollup summary (SUM) on a record that is associated via lookup. The trigger works perfectly if I want to include all the lookup records in the calculation. ...
2
votes
1answer
36 views

checking FLS in triggers

I've seen loads of code examples of triggers and helper classes. They never check for object or field level permissions. I wonder if this was done for code clarity or is this something one does ...
0
votes
0answers
36 views

How does the following example code exceed the SOQL limits of 100?

I was reading about Trigger and Bulk Requests best practices here which quotes: If more than 20 records are pulled into this request, the trigger would exceed the SOQL query limit of 100 SELECT ...
-1
votes
1answer
25 views

How to allow a trigger to show error to user but still allow record to save?

I have a additional_Contacts fields on case object if this is null and user trying to save the record apex trigger should show error message.after showing the error message user stil want to save the ...
0
votes
2answers
42 views

trigger to populate Contact lookup on custom object

I have a custom object, Deal_Reg__c. On this object, i have a Contact lookup field, Submitter_Contact__c. I would like the trigger to populate this Submitter_Contact__c field. The trigger will fire ...
-2
votes
1answer
28 views

Explanation of a code

Can anyone explain the following code: for(opportunity opp : trigger.new) { opportunity oldOpp = trigger.oldMap.get(opp.id); }
0
votes
0answers
15 views

trigger to delete object__share record after update/deletion of another record

I have 3 objects in play: Clinical_Study__c, Clinical_Study_Team__c, and Clinical_Study__Share. Clinical_Study_Team__c records work like Opportunity Team records where whenever a user is added to the ...
1
vote
0answers
29 views

Skip/bypass approval process

I want to skip/bypass an approval process by using some other VF page/apex class/trigger, is it possible ? what kind of framework should I think of ? Basically I want the record to be editable, even ...
0
votes
0answers
37 views

Trigger causes Null Pointer Exception

I have created a trigger, and when I test it in my application, I get the following error: CreatePolicy: execution of AfterUpdate caused by: System.NullPointerException: Attempt to de-reference a ...
0
votes
2answers
22 views

Variable does not exist in Trigger

I have a problem with my code. This is a Trigger on Opportunity. When the Opportunity is closed and won, we create a new Policy__c from that opportunity. The Policy__c also has a related list, called ...
1
vote
1answer
48 views

Ending position out of bound exception

I have below trigger that is getting below. I want just the letter after '-' to be in uppercase. Compile Error: execution of BeforeUpdate caused by: System.StringException: Ending position out ...
1
vote
1answer
14 views

Assign user from profile id when certain condition matches

I have a criteria where i need to select and assign user from particular profile when an 'if' condition matches in a trigger. Issue is the profile contains lots of users. I can select any user ...
1
vote
0answers
14 views

Parent case field to be auto filled when child case is closed

I have a scenario when any child case is closed, two fields in the parent case needs to be updated. If there is more than one child, the parent will be updated with the most recent child case that ...
0
votes
0answers
20 views

trigger to change case owner based on case type [closed]

I have one custom field called Case type on case. I have created Queues based on Case type. I created picklist values -- caseType1, caseType2, caseType3. I created queus -- caseType1Owner, ...
1
vote
1answer
45 views

Split fails in the trigger

My code in unable to split hyphen. PLease have a look to my statement if I am wrong here. trigger ACCOUNT_AFTER_INSUPD_NAME on Account (before insert , before update) { /*List<Account> acc = ...
3
votes
2answers
68 views

Find ' Mc'/' MC' in Name field and make immidiate next letter capital in trigger

I have below trigger. After forming Name field I need to search ' mc' / ' Mc' / ' MC' and make immidiate next letter capital. Also convert the character after space/hyphen/apostrophe to uppercase. Can ...
4
votes
2answers
93 views

How to avoid soql inside For loop in trigger

I am new to Programming and want to update count of opportunities grouped by final stage on Account whenever the final stage is updated. I want to achieve it using Trigger instead of RollUp summary ...
0
votes
3answers
44 views

Exception on after insert,update trigger

I am getting a final exception on below trigger while creating data . Also I need to put a check for Ispersonaccount. Only if the concerned account is a personaccount , the trigger would work.Can ...
0
votes
1answer
16 views

Trigger on Account Name Init caps

I have a requirement to make First Name , Middle Name and Last Name fields as initial caps and then form the Name field by concatenating them. Can someone suggest a way out?Please find my trigger ...
0
votes
2answers
26 views

Can this Trigger be improved?

I am very new to both programming and Apex. I have written one Trigger on account to update contact SLA fields whenever the SLA is updated as 'Bronze' on account. My code coverage is 100%. Please ...
2
votes
1answer
38 views

An Opportunity Trigger working in Sandbox (no data) but fails in Production :(, please help!

Thanks again for all the help I have received from the past, this community is awesome! :) I have written the code below and for some reason it works in Sandbox but fails in Production when I try to ...
1
vote
1answer
37 views

how to test trigger that modifies Opportunity of converted Lead

I have a trigger that runs when a lead is converted, and populates a field on the converted opportunity. Now I'm trying to write a test class for it, but can't figure out how to access the value of ...
1
vote
1answer
31 views

How to write test class for try catch DMLExceptions?

This is not a big issue for now because I was able to write test classes that covers the rest of my triggers, but I'm noticing that for some of my triggers in the developer console that lines like ...
2
votes
1answer
25 views

Trigger if a date from a date field has been selected three times

I am creating a trgger that will fire an error when a particular picklist value has been selected three times. This works and the error message displays. I now need the error to display if a date ...
1
vote
1answer
19 views

Trigger to send email based on Multi-Select Picklist

I have an object called Project__c. It has a multi select picklist field called "Markets__c". So a Project can have multiple markets. On the other side, Contact object has a field called "Market__c". ...
1
vote
3answers
44 views

Updating Lookup field using Trigger

I have posted a question before, but I think my code is completely wrong and I have started in the wrong direction. This problem should be so simple... So, I have the following setup: Account: - ...
0
votes
1answer
18 views

Trigger to copy related list

I am completely stuck on how to get started with this. My application works like this: I create an Opportunity, when the status is set to closed won, a contract is created and a renewal policy is ...
0
votes
0answers
10 views

Trigger to update Lookup field

I have a lookup field relatedOpp__c on Account. I am in the process of writing a trigger that automatically populates this field based on some criteria. The setup is this: Account: relatedOpp__c ...
1
vote
1answer
31 views

Trigger to update converted Lead's Opportunity with information from converted Contact

I'm having an issue with a trigger, and can't seem to figure it out, so I'm hoping someone can help me. Basically, I wrote a trigger that runs when a lead is converted. It is supposed to populate a ...
-1
votes
5answers
43 views

Problems with Trigger

I have created a trigger on my custom object Policy__c. I want to update fields on Opportunity whenever certain fields are updated on Policy__c. Opportunity has a lookup to Policy__c called ...
1
vote
1answer
24 views

I need to write a bulkify trigger for this trigger how should i regret as bulkify for this?

trigger objAobjBnameaddedinobjC on Object_C__c (before insert) { for(Object_C__c c : trigger.new) { Object_A__c a; Object_B__c b; a = [select id, name, Type__c from Object_A__c where ...
0
votes
0answers
24 views

Trigger to update fields / unexpected token

I have just written a trigger, and I get an error "Unexpected token ; on line 2" . I really cannot understand why, and I have been looking at the code for hours now and cannot see what's wrong. Can ...
1
vote
1answer
21 views

when i set with condition status then in case comments should update with some information posted pic see?

See this image i got error api name of internal comments is comments but it shows as invalid sobject
1
vote
2answers
45 views

What are the best practices for Triggers

My requirements are: Upon creation of Accounts there is a trigger that creates a contact with specific record type Organization Donor Proxy I wanted to create another trigger on Account after ...
0
votes
0answers
13 views

Formula field in Campaign Member Section

I don't know if this is possible to do with formula but lets try. I am trying to develop a formula that will give me the times opened from certain lead that is under campaign. What i am trying to ...
0
votes
1answer
31 views

Count number of child records using SOQL Aggregate

I am new to this and I hope someone can help me with this. What my aim is to count the number of AVTRRT__Job_Applicant__c records with a date value on Last_Activity__c field on ...
1
vote
1answer
30 views

How to create a trigger that, on opportunity creation, update lookup field on account(s)

I am new to triggers and I'm working on a trigger that will On new Project create, No other criteria Actions: Follow the Account lookup field on the Project to update the Account.“Most Recent ...