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

learn more… | top users | synonyms

2
votes
2answers
11 views

Problem trying to generate test class for trigger part 2

So I encapsulated the objects within the test, but still having an issue that doesn't make sense... To recap, the trigger is: trigger RecruiterAppReview on Application__c (after update) { /******** ...
2
votes
1answer
17 views

Problem trying to generate test class for trigger

I'm new to this process and struggling with a simple trigger. I created a trigger to create a task based on the status of an application. I have it working in the sandbox, but when I tried to create ...
1
vote
1answer
22 views

Help with triggers to update a picklist value in cases from the asset name

I'm looking to create a trigger that will populate a picklist field from the asset name. Like If asset name starts with X, then set value Y. I tried with field updates but it won't fire until i save ...
1
vote
0answers
17 views

Trigger question about object SignupRequest

I'm having a question about some tutorial I've been reading. I'm trying to create my licenses through a web-to-lead, following this article ...
1
vote
2answers
39 views

Trigger based on record type to show the result as

Here I want to show if we select the status as 'offer letter' then triggered out 'hired' in record type or else 'not hired'. trigger trg_update_recordstatus on positions__c (before insert,before ...
2
votes
1answer
29 views

Pulling parent data from Trigger context variable

I have written below code in my Opportunity after update trigger Map<Id,Opportunity> newOpptyMap = Trigger.newMap; Map<Id,Opportunity> oldOpptyMap = Trigger.oldMap; ...
2
votes
1answer
24 views

Trigger to automatically convert lead to person account and match on PersonEmail

We have an Apex trigger that automatically converts a lead to a PersonAccount. We want to make sure that if there is already a PersonAccount with an email that matches that of the lead that we merge ...
1
vote
1answer
28 views

Displaying information from one opportunity onto another opportunity?

We utilize our instance to manage deal flow in an economic development firm. We currently use Opps with the Record Type of 'ESP Services' to identify companies that we are working with, and then use ...
5
votes
2answers
42 views

Trigger on Case EmailMessage

I have a customer that wants to have a field on the case updated when a user sends an email from a case. For simplicity sake, let's just say we need to put some string into a custom field each time ...
5
votes
3answers
64 views

Order of execution managed vs. non-managed code

Does managed package trigger code always execute before the org's user defined trigger code? (i.e. Is the before insert logic of all managed packages that are installed in an org executed before the ...
2
votes
2answers
39 views

Can we use global variables in triggers to get informations

Can we use global variables like $Profile, $setup, $Label in apex triggers and apex Code? Thanks in advance.
1
vote
1answer
22 views

Determine activity type (completed) on Lead object

I have a custom field on task and event called Type with values as Call, Voicemail, Email.. I have a custom field on lead object, called last activity type. Now I want to populate this field on the ...
2
votes
0answers
31 views

Approval process order of execution

What is the order in which the approval process and triggers execute? I have a trigger on a custom object and there is an update when the user submits the record for approval. Will the DML update ...
1
vote
1answer
23 views

Track field completion on Standard Objects

I want to be able to track record level % completion in terms of fields populated. For e.g on one Account record , I have 50 fields that needs to be populated and the user has only entered for ...
4
votes
1answer
39 views

Does 'pnet' in a user's Id have any special meaning?

I am working on an app and in one of the triggers there is this exotic bird: if( UserInfo.getUserId().indexOf('pnet') != -1 ) { return; } Looks terribly hard coded or is there a general rule ...
4
votes
1answer
37 views

QueryException: Non-selective query (it is selective)

I am trying to query a Custom Object called Lead_Assignment__c based on some criteria. Original query below: List<Lead_Assignment__c> leadAssignments = [ SELECT Segment__c, Queue_Name__c, ...
6
votes
3answers
50 views

Peculiar potential rounding issue in trigger

We have a formula field on a layout that performs a simple calculation. List Price * size_factor * type_factor the actual code is IF( Unit_of_Measure__c = &quot;Subscription&quot; , ...
2
votes
1answer
31 views

Contact Sharing based on child object

I have a number of Contacts in the system, and a child object, Company Profile, with a lookup to Contact. This object has a picklist, "Area". The idea is that each Contact should be shared with as ...
6
votes
1answer
110 views
+50

Attachment trigger not firing, is this a bug?

The Attachment Trigger is not firing for before insert and after insert events when attachments are added via the UI (Related to Tasks) in Winter 14 Sandbox, is this a bug? I've reviewed the known ...
2
votes
1answer
35 views

Getting error message when trying to execute trigger stating incorrect type

Error:Apex trigger ContactTerritoryUpdate caused an unexpected exception, contact your administrator: ContactTerritoryUpdate: data changed by trigger for field Territory: id value of incorrect type: ...
2
votes
2answers
65 views

Trigger on ContentDocument

I'm trying to write a trigger on ContentDocument to align file access rights to the different user. I can align file access rights to the user when I upload a new version of the file. But to align the ...
3
votes
4answers
67 views

Delaying Trigger until all related records are inserted?

I'm working on an app that integrates with an external web service, so saving a record in SF will fire an insert trigger that sends the new record data to the web service. We're working with 3 custom ...
0
votes
1answer
23 views

To write a test method to issue a SOQL query to get related data for records in the Trigger.new and Trigger.old lists

my trigger code is: trigger candidateTrigger on Candidate__c (before delete) { for (Job_Application__c jobApp : [SELECT Candidate__c FROM ...
6
votes
2answers
77 views

Trigger .isExecuting Clarification

So I have been wanting some clear cut answers on this for a while and most of the documentation that I can find is fairly vague. Mike Leach has an excellent post explaining the best practices in ...
1
vote
2answers
37 views

Dummy Update to existing data

I have a deployed a trigger to production and i need to run the trigger to update the existing records.Is there any way to run the trigger for existing data other than pulling the existing records ...
1
vote
0answers
29 views

OpportunityLineItem trigger when SortOrder is saved

I'm trying to access OpportunityLineItem whenever the SortOrder is changed. However the trigger for update actions doesn't fire when I hit the save button from the page where we sort the Opportunity ...
2
votes
3answers
71 views

Trigger to update field in another object

Here's the trigger I created to update a list of service orders related to a Case when a field is changed in that particular Case. System.debug shows the Order Status value set to 'Closed' but it is ...
1
vote
1answer
18 views

SF2SF trigger sharing not working

I'm trying to share with a Connection new Accounts. I used the trigger examples to create the following trigger: trigger SendAccountsToConnection on Account (after insert) { ...
0
votes
1answer
43 views

Trouble with Trigger: wan to update child object field (which update via formula from other object)

I'm new with triggers and am having trouble with making one work. I have a child custom object called "Actividad" which has a formula field "Actor Principal Indicador" that gets updated from its' ...
1
vote
2answers
66 views

How to delete product share from a trigger

I have created a product share between app admin and sales rep in my apex trigger. Now I want to delete the product share from that code. How do i do it? Code as below: the code which i tried is ...
0
votes
1answer
51 views

trigger to prepopulate a new case with value from it's parent account (trigger not working)

Hi could someone point out what I'm missing in this trigger. Thank you. trigger getTargetDateFromAccount on Case (before insert,after insert) { Set<id>accountIds = new Set<id>(); ...
1
vote
1answer
97 views

SELF_REFERENCE_FROM_TRIGGER error when updating child record?

Im confused becauyse this trigger code is working in the sandbox and was working in production yesterday but today im getting Error:Apex trigger sendDAP1Invites caused an unexpected exception, ...
2
votes
2answers
65 views

Is it possible to trigger on Sandbox creation?

Is there an operation when creating/deploying a Sandbox org that would allow you to develop an Apex trigger to send an email out to administrators? If not through a trigger, is there another way to do ...
0
votes
0answers
47 views

deploy error - trigger to create task based on lead comments field update

trigger to create task based on lead comments field update hi i am test a trigger which is able to create a NEW task based on lead comments field been changed, the trigger works now, and i need help ...
1
vote
1answer
33 views

How to get Lead Owner profile from Trigger

I am looking for a solution to get the Lead Owner profile name from Trigger.new , instead of doing a seperate query on "User" record to get the profile.
2
votes
1answer
52 views

Help with Trigger

Below is the trigger code but i am getting error: Compile Error: unexpected token: 'List' at line 12 column 2 trigger onUpdateOfObjectB on Object_B__c(Before insert,before update) { ...
4
votes
2answers
80 views

Batch @future calls?

Im trying to build what seemed like a simple SMS messaging application using Twilio's api and running into a few strange momments. So I have an SMS object that stores the messages and i wrote a ...
-2
votes
1answer
63 views

Why am I getting a compile error in my trigger?

Background I'm looking to write an apex trigger that will look at newly created leads, and assign them to a campaign based on a custom field in the leads, but I'm getting stuck with this compile ...
1
vote
1answer
62 views

APEX unit test error - cannot reference converted lead

i create the trigger and unit test for convert lead process, the trigger seems work, but the unit test code has error. here is the trigger code trigger ConvLeadtrigg02 on Lead (after insert, after ...
2
votes
1answer
76 views

APEX trigger unit test error - Assertion Failed for field update

error msg: Assertion Failed: Expected: 2000 test comments after change, Actual: 28888 test comments before APEX Trigger - it check the existing lead and if comments_c field been modified, will fire ...
3
votes
2answers
45 views

Innested Soql Queries

This is my soql query,i'm getting in one soql information about account and related opportunities: list<account> listaccounts= select id,name,(select id from Opportunities where ...
2
votes
1answer
56 views

adding time to date fields

so im building an app that will run for a certain time from a start date to an end date so i have a start_date__c and end_date_c and i have a pick list duration_c which allows the user to select the ...
1
vote
2answers
31 views

Account Roll up of contacts meeting certian criteria

I need to know at the account level how many contacts under this account match certain criteria. In this case, its whether or not a custom checkbox field is checked. So for instance, if under Acme ...
1
vote
1answer
36 views

Apex trigger causing lead auto-response rule to fail

I have an issue with an auto-response rule that isn't working in our live environment (but does work in our sandboxes). The lead auto-response rule doesn't fire even though the simple criteria is ...
1
vote
1answer
112 views

Trigger to update parent value when ALL child record values are updated (Custom Approval Process)

There is a need for a custom approval process at my company and I'm stuck on how to create this trigger. I have a parent object called Bids with a child object related called Approvals. I want to ...
1
vote
1answer
66 views

Site.createPortalUser() in Contact Trigger throws “System.TypeException: You are already logged in.”

I need to automatically create a customer portal (CP) user whenever a CP admin (ie, CP user with delegated external user admin rights) creates a contact in the CP. The CP admin logs into the portal ...
1
vote
1answer
91 views

Access Field on Lookup Relationship in trigger

I have a Lookup relationship to another custom sObject, and I want to access: sObject.sObject1__r.Name However, sObject__r.Name is undefined in the context of the trigger. If I attempt to run this ...
5
votes
3answers
111 views

Triggers and custom exception

I am new to Apex and not very sure about exception raising and handling/. Here is my use case i need to check whether owner has been changed and a box is checked. and if condition is true should not ...
0
votes
2answers
105 views

Exeception on After Insert, Record is read only

I'm writing a trigger for new opportunity products to populate a field Product_Category__c (on opportunity lineitem) getting the value from Product_Category_new__c (on Product). This is my trigger: ...
1
vote
1answer
35 views

Composite Keys on Trigger

I want to know the best way to accomplish this task, I have these 3 Objects Suscripcion_Detalle_c, Direccion_Entrega__c and Paquete_Detalle__c. What I need to do is every time there's a new ...