Preface: this post is part of the Write Your First Trigger From Start to Finish series.
There are only two places you can write code in Salesforce:
You can follow along in either version! If you want to eventually deploy into your normal “production” org though, you’ll want to use a sandbox.
To open up the trigger coding UI in either version, navigate here:
Note: every object in Salesforce has a “Triggers” section, even custom objects!
Next, copy over the code from our simple trigger example and… your code is now active! Go ahead and create a new user to test it out!
Don’t want to create your own environment? Log in to mine!
Username: learn@sfdc99.com
Password: Click here to reveal
Next post: Example: How to write a simple Apex trigger!
i want to a time field on a object and that time field is automatically filled with current time of system. i do it by taking time datatype and some formula but its showing different time ..im also changing the timezone from the setting but its not taking system time
NOTE:we have to display only time in that field not date.
please help me,any one have solution then please ping me.
thank you!
Hi,
I have retrieved and deployed the below apex class (Opportunity_Test) but unable to see the apex class in my developer edition where the deployment status is success.
Opportunity_Test
ApexClass
How to find this Apex Class in my salesforce instance? Why i am not able to find this class?
Thanks in Advance.
hi david…
its mahesh i want to learn salesforce pls insist me to get some resources
Tell me what resources you need that aren’t already on sfdc99 and I will try to find them!
Sir I want some of the basic codes and their descriptions …..
Hi David,
I am new to SFDC. I am failing Administrator WI15 exam on 1st trial, So please help me how to clear Administrator-WI15 exam in 2nd trial.
Haven’t passed that one yet myself!
hi david,
i am new to salesforce while now i am practicing with developer edition ,can u show me path ,How to deploy triggers using sanbox to production??
and how can i find sanbox??
Go through these one by one =)
https://www.sfdc99.com/beginner-tutorials/
I have Interview next so I have some Important question with Answer. I have Java background and new for SFDC.
Plz share Interview question.
I’ll have a post on this, I get this question a lot!
But not soon unfortunately!
Hi David,
I am new to SFDC.Taken the coaching outside.I am failing in the interviews.So please help me how to overcome this problem.
Interviews are all about preparation. Know everything about the company you’re interviewing for, and even the people who are interviewing you. I used to memorize every single person’s hobbies before going in to my first interviews!
Nothing beats knowing the platform inside and out beforehand too!
I’ll have a post up soon with interview tips!
David
I scheduled an interview in this week.So how to prepare and what to prepare..It’s a great a help gor me…
This is a big topic with too many variables depending on the position and company!!
My short advice: don’t pretend to know something if you don’t know it!
Hi David,
What is the execution order of workflows and triggers?Which comes first??
Check this post out:
https://www.salesforce.com/us/developer/docs/apexcode/Content/apex_triggers_order_of_execution.htm
Thankyou David :)
Trigger comes first then Workflow
Just fyi , the flow is as mentioned below
Validation Rule
Triggers
Assignment Rule
Auto-response Rule
Workflow rule
Escalation Rule
at last Roll-up summary fields
the login id and password is not working
Updated!
Hi David,
I am not able to get 75% code coverage for my test class. Can you please help me get 75%-100% code coverage for my below test class.
@isTest(SeeAllData=true)
global class QuoteToUpdateTest1{
static String CRON_EXP = ‘0 0 0 15 3 ? 2022′;
public static testMethod void QuoteToUpdate_Test() {
System.debug ( LoggingLevel.ERROR ,’QuoteToUpdate_Test — Start’) ;
Test.startTest();
User user = [SELECT Id FROM User WHERE IsActive = true LIMIT 1];
System.debug ( LoggingLevel.ERROR ,’QuoteToUpdate_Test — before quoteUtilTest.quotes[0]’) ;
Quote__c testQuote= QuoteUtilTest.quotes[0];
System.debug ( LoggingLevel.ERROR ,’QuoteToUpdate_Test testQuote=’ + testQuote) ;
/* Approval.ProcessSubmitRequest req = new Approval.ProcessSubmitRequest();
req.setComments(‘Submitting request for approval.’);
req.setObjectId(testQuote.Id);
Approval.ProcessResult result = Approval.process(req);*/
// Schedule the test job
String jobId = System.schedule(‘ScheduleApexClassTest’,CRON_EXP, new QuoteForUpdate());
// Get the information from the CronTrigger API object
CronTrigger ct = [SELECT Id, CronExpression, TimesTriggered, NextFireTime FROM CronTrigger WHERE id = :jobId];
// Verify the expressions are the same
System.assertEquals(CRON_EXP , ct.CronExpression);
// Verify the job has not run
System.assertEquals(0, ct.TimesTriggered);
// Verify the next time the job will run
System.assertEquals(‘2022-03-15 00:00:00’,
String.valueOf(ct.NextFireTime));
Test.stopTest();
}
}
Srinath,
Two things you need to do!
1. Remove the SeeAllData=true annotation! Create your records from scratch!
2. I need to see your trigger =)
David
Hi David,
I can’t create “new” from the triggers page, using your login listed.
Hey Brian =)
You’ll actually need your own (free) environment to do so!
https://events.developerforce.com/signup?d=70130000000EjHb
I locked it down so I wouldn’t have to clean up a bunch of code =)
David