A trigger is an apex code, that can be executed before or after DML operations
1
vote
3answers
36 views
Initial field of expression must be concrete Sobject
`trigger AccountReplicate on Account (after delete, after insert, after update) {
if(trigger.isInsert)
{
for (Account acc:trigger.new)
{
AccountOne__c ac = new AccountOne__c();
ac.Fax__c = ...
2
votes
0answers
28 views
How can I create a new Apex Trigger using the Tooling API?
I'm trying to create a new Apex Trigger using the tooling API. However, I keep getting the same error for TableEnumOrId
Here is the code I am using:
List<ApexTrigger> apexTriggersToCreate = ...
2
votes
2answers
46 views
How to access a VF page as PDF within trigger/scheduled APEX
I have run into yet another problem due to restrictions placed by Salesforce.
So apparently we cannot make a call to a Visualforce page using getContent() from within a Apex trigger.
Currently we ...
0
votes
0answers
19 views
How to write a trigger that blocks the entire calendar?
Problem: If we selects the "All Day Event" checkbox on the event, vs physically blocking out a specified time (ex. 7 to 4), the system doesn’t stop overlapping appointments.
Can any one help me how ...
1
vote
2answers
23 views
Trigger Test Class and Code Coverage
Need assistance to identify what's needed to obtain better coverage, which is currently 62%. Lines 12, 13, 17, 18, 23, 27 are all not covered. To note: I have not included any references to Contact__c ...
2
votes
2answers
43 views
Account SOQL traverse
I have a usecase,were i need to traverse account hierarchy
say i got an Account A,then i need to check whether it has a parent id,
if it has a parent id--then need to get its grandparent and till the ...
0
votes
1answer
35 views
Too many SOQL limit
I have a method where It updated the records. When I used the below trigger and try to update from account detail page.it is updating as expected.
but when try to update using saveme method , I am ...
2
votes
1answer
18 views
control trigger execution
I have 2 triggers:
The first:
trigger AutoProduct on Opportunity (before insert,after insert) {
for(Opportunity newOppt : Trigger.new){
if ...
0
votes
1answer
16 views
Apex trigger to update field and activate workflow
I am new to Salesforce and recently learned I cannot schedule workflows to run on certain dates, but must manually (or programatically) edit the record to activate the workflow. After some research ...
2
votes
2answers
44 views
Recursive trigger
This is my trygger on Opportunity object.
trigger AutoProductupdate on Opportunity ( before update,after update) {
static boolean already=false;
if (already==false){
for(Opportunity newOppt : ...
0
votes
0answers
21 views
how we can block posts, comments and Likes in a group whith trigger? [duplicate]
Hi,
I want block posts, comments and Likes in a group whith trigger where group.Name.conatins('inactif')
thx
1
vote
0answers
20 views
CampaignMemberStatus records only testable with seeAllData flag?
I wrote a trigger that creates some CampaignMemberStatus records against a Campaign automatically, and noticed that when I tried to test my logic any queries that I run for CampaignMemberStatus ...
-3
votes
1answer
45 views
Disable comment and like in posts whith trigger?
how i can use trriger to disable comments ans likes in a posts of an group
trigger groupInactif on "?" (befor insert)
thx.
0
votes
0answers
11 views
Does partial Lead Convert failure cause the rest of the batch to not run in bulk?
I'm seeing a really strange issue when I perform a Database.convertLead() function call. It seems like if one of the leads fails to convert, the rest of the leads will cause triggers to run in ...
2
votes
1answer
42 views
Questions regarding lookup, contacts, and custom objects
In reference to a previous question located here, I have a new problem.
Our marketing department had an issue with assets being tied to a particular contact record as it was causing issues with ...
0
votes
3answers
50 views
Validation in Trigger
I have a custom object which stores the ranges for the mobile numbers and fixed line numbers.
Mobile = 477.100.001 - 477.100.999 - This is one single record with FirstPhoneNumber & LastPhoneNumber ...
0
votes
0answers
34 views
How the group can view the Standard and Custom object Chatter feed post?
In the screenshot no-1, we can post anything via chatter feed also we can able to share the post to Group which we created. Then all the group members can view the post. But in the screenshot no-2, ...
0
votes
2answers
34 views
Apex Triggers and Custom Objects
I have a custom object named Trip. I am trying to create an apex trigger that will execute after any trip is created, that will create an event with some of the info from the trip. I am new to apex ...
2
votes
2answers
54 views
Lead assignment rule in a trigger
The objective is to have assignment rules fired on a Lead record creation. It seems the rule can be assigned only when using "update" DML in an "after insert" trigger. Why does another DML must be ...
1
vote
1answer
33 views
Set Product for new opportunity lineitem
in a trigger i'am going to create a new opportunitylineitem for an opportunity:
OpportunityLineItem newOpptLineItem = new OpportunityLineItem();
...
0
votes
4answers
63 views
How to write workflow trigger for last opportunity activity?
I want to write a trigger workflow that checks whether an opportunity of type x and stage y has not had activity for the last 5 days.
I could however not find any date related fields when selecting ...
1
vote
1answer
38 views
How to copy standard Opportunity objects into a custom object?
I have a standard Opportunity object with the appropriate standard and custom fields. Now I have been asked to create a custom object that will have its respective standard and custom fields populated ...
2
votes
1answer
45 views
Contract / Warranty Creation from Asset
The code I am attempting to fix today revolves around Contracts and Customer Assets.
The idea being that when a customers asset is generated or updated the account manager will check off "Support ...
4
votes
1answer
46 views
Trigger on User
I'm trying to change a Users ProfileId after the login.
I am able to switch the profile but I like to do the callout from a Trigger.
trigger UserUpdateLastLogin on User (after update) {
for(User ...
2
votes
1answer
45 views
Update Trigger doesn't fire in testMethod
Basically, I've written a trigger that will update a custom field on an User object when the value of a standard field changes. The trigger works when it is "triggered" via actions made by me on the ...
4
votes
2answers
36 views
New record causes to change in a lookup field in different object
We have two custom objects: Obj1 and obj2. Both objects have lookup fields linked to Account. I want "status" field in obj2 to be updated when a new record created for obj1.
Is it possible without a ...
2
votes
1answer
37 views
How to update an object with a trigger, as it's being updated
So let's say I have an sObject User:
Standard Fields
TimeZoneSidKey
Custom Fields
Time_Zone__c
When a user updates TimeZoneSidKey I want to automatically update the custom field Time_Zone__c for ...
3
votes
1answer
30 views
Creating Sharing Rules on run-time(While opportunity is being saved/edit) using apex code
Is it possible to create sharing rules at run-time? If yes then please explain how can we do that in save method/trigger?
Actually i need to bypass role hierarchy setting and for that i need to ...
7
votes
2answers
61 views
Losing @ mentions in apex trigger on FeedItem
I have developped a apex trigger on FeedItem after insert. The purpose is to append an hashtag to the body of the post when certain criteria are met. Everything works very well except that any ...
2
votes
1answer
63 views
Best Practice with Triggers - To combine or not to combine
Just a simple question on best practices - Is it better to combine simple triggers or leave them separate.
For example, I've got a trigger that updates a field based off of another field, and then a ...
4
votes
2answers
40 views
How would one track field history for OpportunityLineItemSchedules?
Unforntunately Salesforce does not support Field History for OpportunityLineItemSchedules. A workaround would be to duplicate Salesforce's Field History object and update it using a trigger. (I have ...
1
vote
2answers
67 views
Trigger Hel(p) Code Coverage 0%
As a followup to my previous posts (Again, many many thanks) I am still having trouble with the trigger.
The code seems to function and I created a test class and the code itself is 100% covered.
...
1
vote
1answer
35 views
Test Class update to Opp Owner causing DML Exceptions
I've been pulling my hair out trying to resolve a problem with a test class for a trigger that fires on update of Opportunity. When the Opp Owner is updated, the trigger updates the Owner of related ...
2
votes
2answers
49 views
Help with Triggers / Classes for Case Creation Part II — Test classes
Thank you for all the help on my other question. I was so happy to see a community that doesn't have trolls.
So the good news is that the code compiles with no errors.
The bad news is that I have ...
4
votes
1answer
69 views
Is there a way to determine how certain account has been created?
As you know Salesforce accounts could be created either as a result of lead conversion or directly, by creating a new account using account creation form (and, accordingly, bypassing lead creation ...
1
vote
1answer
57 views
Help with Triggers / Classes for Case Creation based on Field Change in Customer_Asset
I am new to Salesforce and haven't coded in quite awhile, so please forgive my rookie mistake(s).
I am attempting to write a trigger to do the following:
Our company manufactures equipment that ...
1
vote
1answer
59 views
How do I populate two auto-incrementing fields in same Object
I've a trigger on a custom object Object_A__c. Now, I need to populate a receipt number id in a field receipt_id__c.
There are two types of receipts X and Y namely. I need to populate the ...
1
vote
2answers
93 views
Why should we use bulk triggers?
I am new to salesforce ,i need to know what is the need for going to bulk triggers?
what is bulk trigger??can anyone give detailed explanantion on this.
1
vote
2answers
123 views
Turning into Batch Apex using Database.QueryLocator
I want to turn my trigger code into a batch Apex, however, i am encountering a number of problems with it. Posting both the original and the batch codes. Please can anyone suggest what changes to add ...
0
votes
1answer
49 views
Making a Trigger Bulk Ready
I have a trigger that works just fine for single records and I am stumped how to make it work for multiple records. Any help would be appreciated.
trigger TSSEducationUpdate on Education__c (after ...
0
votes
1answer
83 views
Test class with custom setting
I' have written a trigger on lead, very simple.
I'am using the custom setting for the first tine to avoid hard coding or query to get ids.
I haven't experience testing custom setting.
I have a ...
2
votes
2answers
48 views
Need help with an Apex trigger
I have a junction object with two master detail relationships. One to contacts and one to a custom object named program. I created the following trigger to avoid duplicates but im having A LOT of ...
1
vote
1answer
50 views
Trigger to update field on existing records with same owner of insert
New to writing triggers, I'm trying to set one up that adjusts a field on existing records with the same Owner as the one(s) being inserted.
I have an End Date field that I want populated when a new ...
5
votes
2answers
85 views
Trigger Old Context Variables (oldMap, old)
According to the documentation, Trigger.old and Trigger.oldMap are only available in update and delete Triggers.
Are these variables null otherwise, or are they just empty? Would ...
1
vote
1answer
64 views
Trigger to send email
I have been working on our Opportunity page to add a custom checkbox if the opportunity is conditionally approved. What I would hopefully like to do to sew this up would be to use a trigger to send ...
3
votes
2answers
54 views
Trigger only updates on odd numbered input and not even
trigger trig_Opportunity_CreateOppOwner on Opportunity (before update,before insert) {
List<id>OppsID = new List<id>(); //List that will hold all id of all new Opportunities owners
...
2
votes
1answer
68 views
Does a VisualForce page embedded in a page layout have to finish executing before the page will load?
Thanks for reading my question.
I am looking to create a trigger on the OpportunityContactRole which is unfortunately not supported (I'm curious as to why, if anybody has insight on that, but that is ...
3
votes
1answer
84 views
Trigger based on Record Type + Default Value + Lookupfield
I have a simple trigger that sets the default value on a lookup field on Object B from Object C.
trigger UpdateQuestionSet on Job__c (before insert, before update) {
for (Job__c questions: ...
2
votes
1answer
50 views
deleting the previous records in leads and creating new records using trigger
i need to create a record but before creating thr record i neeed to delete all the old records that is having status closed converted...my code is
trigger deleteRecords on Lead (after insert){
...
4
votes
2answers
90 views
Did anyone restrict users changing their timezones?
I want to know if there is an easy way to restrict users from changing their Timezone. I wrote a trigger to do it for now, but I was wondering why Salesforce didnt allow us to write a Validation Rule ...