Anyone can learn how to write Apex no matter what their background is!
Follow this guide in order and I guarantee you will become a Salesforce developer.
how can get filter list of custom object in trigger.new.
If i want to get mycustomer records of mycustomer__c object that is created today and do before update operation only on that customers using trigger.
please guide
can you help me regarding this scenario.
—> Create a schedule class that runs every hour to check hoe many accounts, contact, opportunity, cases were generated and deleted in last one hour. Collect all this data and dump in one custom object. Create a report to show acc, contact, oppty and cases count with respect to time. Create a dashboard that could overview in one look.
HI David, just wanted to check if this course is relevant even now. Also I am not able to see the link from Chapter 8. Can you please add the link from 8th part of 8th Chapter Object Oriented Programming. Thanks
Hi David, hope you don’t mind me asking why has Chapter 8 has been unwritten? Is there any other sites I can get more learning in replacements for this chapter?
When contact record is inserted/Updated create account record same should be populate in contact and also create opportunity
record and tag opportunity to contact and account.
If name in the contact record updated, update same name in opp and account as well
Your blog is very interesting. Your level of thinking is good and the clarity of writing is excellent. I enjoyed so much to read this post. I am also a blogger, you can follow my blog here how much to make an app
Thanks for your post. We are professionally managed job vacancies information related platform where we are trying to connect employer with job seeker. So that employer can hire best candidate and at the same time candidate also get best job opportunity. Both of them can excel and achieve their mission and vision https://magic-job.com
I am finally going through Apex Academy through PluralSight. I passed the first course but with challenges :-) Best way to learn though, right?
Now I am going through SOQL but getting an error when I run the first script to create Accounts and Contacts – I will try to debug but I thought I’d let you know anyway:
System.DmlException: Insert failed. First exception on row 222; first error: DUPLICATES_DETECTED, Use one of these records?: []
Thanks again for all you do and I hope you and your family are safe and healthy.
I am going to start salesforce admin like sale process ,services process and marketing process so can you help me,
i would like to know some details, please guide me related admin.
Hi
I’m new to Salesforce and Apex. I don’t have a Java background instead I have NodeJS (functional programming) background.
Can you suggest how I can learn Apex from scratch without a backgroud of object oriented programming?
hi there.. i used to have a post of yours saved where it gave you links to the SF Admin course flash cards and also 4 or 5 exams and which to take in order as some of the study materials were similar. But its missing now
David sir, please make new videos on pluralsight related with integrations or more advanced apex. Please sir. You are our role model! We all want to learn more from you. :)
– create a brand new dev org
– write the HelloWorld trigger
– In LEX, go to the Leads tab, and navigate to all Leads.
– Click on a Lead to view it. (DO NOT EDIT IT).
Sorry… the one in Apex Academy – The Absolute Beginner’s Guide
If you have a brand new dev org (I mean BRAND NEW), and you stay in LEX, and you follow my instructions above… the trigger fires on the Leads WITHOUT editing the record.
I have also noticed the same. The trigger runs without needing to edit any record as there are some backend process (duplicate check ?) getting triggered
can you please help me with this question..,
I have two objects one is a standard object i.e Account and the other one is a custom object and their have a look up relations .I have created 3 text fields as A,B,C in custom object.Now when I concatenate b/w A and B , the result should get displayed in C.when u type the value manually in field C ,it should throw the error.So which type of trigger is used and how wil u write the code?
Hi David. Thank’s for sharing this information. This sales force tutorial are very easy to understand for a beginner like me. congratulations for this amazing and very helpful website. It really really helpful for me.
Hey David
I have defined two variables (currency fields actually ) as follows:
Set targetprice = new Set();
Set floorprice = new Set();
Then I try to update them ( the field CPK_Target_Price_c is type currency (16,2)
List prodmaster = [select ID, CPK_Target_Price__c,CPK_Floor_Price__c from Product2 where Id IN: product];
for (Product2 prodrecord :prodmaster){
prodrecord.CPK_Target_Price__c = decimal.valueOf(targetprice);
prodrecord.CPK_Floor_Price__c = decimal.valueof(floorprice);
I get the following error on compilation
Method does not exist or incorrect signature: void valueOf(Set) from the type Decimal
I am preparing for google coding interview. Could you please help me with what kind of apex algorithms will be asked. If you can give some sample coding questions asked for a telephonic interview that would be great.
Hi David
I want to thank you for helping new apex code like me. I like the away you teach on pluralsight , you style of article writing . it fun to watch and easy to understand and very easy to pick up, less jargon , alway to the point. I was one of the audience member to see you get gold medal of honor (golden hoddy in salesforce) last year . I personally like to thank you for your help to make me a SaleForce developer in less then 2 years . Please keep continue your nice article and video tutorial (specially salesforce lightning) .
Please keep writing!!!
looking forward to reading more.
I’ve just started out on the apex academy and created the first trigger below in a brand new lightning org. The trigger fires on new lead record and existing record. When I open an existing lead record without updating it, the name field automatically changes to hello world. On creation of a new record too, the name changes to hello world. Any guidance will be appreciated.
trigger HelloWorld on Lead (before update) {
for (Lead l : Trigger.new) {
l.FirstName = ‘Hello’;
l.LastName = ‘World’;
}
}
Hope you doing good. I am learning Salesforce Development and I am doing Apex Academy Courses from pluralsight. As we know Mavensmate is not available. Please could you help which is best tool available today to write code.
Login to your org >> Click on your name in right upper side of the page >> Click on Developer Console. In the file tab, when clicked ‘New’, you may want to chose whether you want to create a Class, Trigger, Visualforce Page, etc.
Dear All,
I am getting Product_Purchase_Date__c variable not found error. I am using my own developer org for the learning purposes. Is there any way to import the demo code used in the Apex Academy into my org.
Hello I am learning salesforce developer I have 2 assignments of salesforce developer one is generate 4 generate number and display 3 maximum number and second is circular right shift array by n position please help me I don’t understand how I could do this
I’m trying to populate the email address using apex on outlook can you tell me how to update the subject and content of the saved template on the same and avoid hitting the limit of sendemail in salesforce. By using any code or creating a class that does allow us to send emails from the third party client and not the original configuration of Salesforce.
Hi David, I started learning with Apex Academy at Pluralsight and am hooked to it. It’s great!
However, in the Secret Information in Case Decription Trigger,( a part of the course Apex Academy: Fundamental Salesforce Coding Techniques ) whenever am trying to create a new Case, am getting the following,
Execution of BeforeInsert caused by: System.NullPointerException: Attempt to de-reference a null object: Trigger.WarrantySummary: line 8, column 1
My code is an exact copy of yours.
Thanks in Advance.
I had the same issue, it is because of the Warranty Summary trigger you wrote you have told it to run off of the new fields you added
Product_Purchase_Date__c
Product_Total_Warranty_Days__c
So on this new trigger it is causing the other trigger to run but the values are not being inputted e.g ‘null’
I fixed this by adding :
David, I’d like to jump in and start learning but am hesitant on where to start. Should I begin with the beginner tutorials, or proceed with Apex Academy?
I am learning this apex tutorial and its really helpful.I was wondering if you can post from module 8 of chapter 8 to rest of the chapters that would be really great.
Is Mavensmate not available anymore? I am learning Apex using your training course and wanted to try along, but could not find mavensmate to install. Looks like it is not supported anymore. Which other tool do you recommend me to try? I am completely new to coding so want to find something not too complex. Could you please suggest?
Thanks,
RC
Thank you David for the quick reply, I will give it a try.
Just want to let you know that I really appreciate how you are helping beginners like me to get started with coding. I am enjoying your course and hopefully will learn to code soon!
Best regards,
RC
Hello David. Many thanks for effort you put in helping other to learn Apex!
In the Absolute Beginner’s Guide to Coding in SFDC video, you (subliminally) strongly advise to use the MavensMate editor to write code. This tool is unfortunately no longer managed by its creator.
Hi David. Thank’s for sharing this information. This salesforce tutorial are very easy to understand for a beginner like me. congratulations for this amazing and very helpful website. It really really helpful for me.
Hi David,
How to update 2 lacs records usng batch class which is getting data from third party application using REST API?
As I know their is 10000 records limit in in one API call and able to update upto 10000 records but unable to get idea for hitting multiple calls so that it can fetch data and update in our sfdc database. Can you please help me out in this case? If you want code then I can aslo share with you. Thanks in advance
To pass this challenge, create an Apex class that inserts a new account named after an incoming parameter. If the account is successfully inserted, the method should return the account record. If a DML exception occurs, the method should return null.
The Apex class must be called ‘AccountHandler’ and be in the public scope.
The Apex class must have a public static method called ‘insertNewAccount’.
The ‘insertNewAccount’ method must accept an incoming string as a parameter, name the account after the parameter, insert it into the system and then return the account record.
The ‘insertNewAccount’ method must also accept an empty string, catch the failed DML and return null.
After reviewing the salesforce help forums, My code reads as follows :
public class AccountHandler {
public static Account insertNewAccount (String accName){
Account asd = new Account(Name=accName);
try{
insert asd;}
catch(Exception e){
return null;
}
{
return asd;
}
}
}
While submitting the challenge, I get the following error;
Challenge Not yet complete… here’s what’s wrong:
There was an unexpected error in your org which is preventing this assessment check from completing: System.NullPointerException: Attempt to de-reference a null object.
Ive looked into it, and our org is using Files Content so it explains why attachments aren’t working. However from my research, the contentDocument objects don’t have a relationship to the parentID of the object. It must be there somewhere though or how could they tell which files are linked to which objects??
I think for this you’ll need to query ContentDocumentLink object and get the LinkedEntityId field that gets you the ID of the Record your file is associated to.
Hi David,
Me and my CTO have been working on an issue and not getting any resolution. I have created a trigger on after update of Account wherein if there is a change in Master Contract field on the account it should be passed to all the Open opportunities. The trigger is working fine by itself. But when we try to Book an Opportunity it is throwing a flow error. It does not throw a flow error if i disable the trigger. Here is a snapshot of the log. Not sure if my trigger is causing the flow error or not or we need to update the flow. Your help would be appreciated. Thanks.
12:25:46.905 (15172851002)|CODE_UNIT_FINISHED|Workflow:Opportunity
12:25:46.798 (15178844006)|FLOW_VALUE_ASSIGNMENT|4544777de95ef40176a3662bf72a15c17ddea4c-6b43|myRule_10_A1|true
12:25:46.798 (15178888896)|FLOW_BULK_ELEMENT_END|FlowRecordUpdate|myRule_10_A1|2|376
12:25:46.798 (15178913194)|FLOW_ELEMENT_BEGIN|4544777de95ef40176a3662bf72a15c17ddea4c-6b43|FlowRecordUpdate|myRule_10_A2
12:25:46.798 (15178918762)|FLOW_ELEMENT_DEFERRED|FlowRecordUpdate|myRule_10_A2
12:25:46.798 (15178925163)|FLOW_ELEMENT_END|4544777de95ef40176a3662bf72a15c17ddea4c-6b43|FlowRecordUpdate|myRule_10_A2
12:25:46.798 (15178935380)|FLOW_BULK_ELEMENT_BEGIN|FlowRecordUpdate|myRule_10_A2
12:25:46.798 (15193198030)|EXCEPTION_THROWN|[EXTERNAL]|System.LimitException: Too many SOQL queries: 101
12:25:46.798 (15193562042)|FLOW_VALUE_ASSIGNMENT|4544777de95ef40176a3662bf72a15c17ddea4c-6b43|myRule_10_A2|false
12:25:46.798 (15193609220)|FLOW_ELEMENT_ERROR|Too many SOQL queries: 101|FlowRecordUpdate|myRule_10_A2
12:25:46.798 (15193791920)|FLOW_BULK_ELEMENT_END|FlowRecordUpdate|myRule_10_A2|0|0
12:25:46.798 (15228076994)|FLOW_START_INTERVIEWS_END|1
12:25:46.794 (15228154057)|WF_FLOW_ACTION_ERROR|09L0j0000000All|300150000008pnP|Error executing flow: Account_Updates, FlowDefId: 300150000008pnP, FlowVersionId: 3010j00000055KL
12:25:46.794 (15228172139)|WF_FLOW_ACTION_ERROR_DETAIL|An unhandled fault has occurred in this flowAn unhandled fault has occurred while processing the flow. Please contact your system administrator for more information.
12:25:46.794 (15228305416)|WF_FLOW_ACTION_END|09L0j0000000All
12:25:46.794 (15228326557)|CODE_UNIT_FINISHED|Workflow:Account
12:25:47.232 (15232395159)|FLOW_VALUE_ASSIGNMENT|4540777de95ef40176a3662bf72a15c17ddea4c-6b47|myRule_8_A2|false
12:25:47.232 (15232457836)|FLOW_ELEMENT_ERROR|The flow tried to update these records: null. This error occurred: CANNOT_EXECUTE_FLOW_TRIGGER: The record couldn’t be saved because it failed to trigger a flow. A flow trigger failed to execute the flow with version ID 3010j00000055KL. Flow error messages: An unhandled fault has occurred in this flowAn unhandled fault has occurred while processing the flow. Please contact your system administrator for more information. Contact your administrator for help.. For details, see API Exceptions.|FlowRecordUpdate|myRule_8_A2
12:25:47.232 (15232562170)|FLOW_BULK_ELEMENT_END|FlowRecordUpdate|myRule_8_A2|0|0
12:25:47.232 (15251343939)|FLOW_START_INTERVIEWS_END|1
12:25:47.251 (15251399464)|WF_FLOW_ACTION_ERROR|09L0j0000000B0M|30015000000PQI6|Error executing flow: Contract_Updates, FlowDefId: 30015000000PQI6, FlowVersionId: 3010j0000004udl
12:25:47.251 (15251417739)|WF_FLOW_ACTION_ERROR_DETAIL|An unhandled fault has occurred in this flowAn unhandled fault has occurred while processing the flow. Please contact your system administrator for more information.
12:25:47.251 (15251503745)|WF_FLOW_ACTION_END|09L0j0000000B0M
12:25:47.251 (15251520352)|CODE_UNIT_FINISHED|Workflow:Contract
12:25:47.273 (15273579228)|FLOW_VALUE_ASSIGNMENT|3897777de95ef40176a3662bf72a15c17ddea4c-6df4|Activate_Master_Contract|false
12:25:47.273 (15273646484)|FLOW_ELEMENT_ERROR|The flow tried to update these records: null. This error occurred: CANNOT_EXECUTE_FLOW_TRIGGER: The record couldn’t be saved because it failed to trigger a flow. A flow trigger failed to execute the flow with version ID 3010j0000004udl. Flow error messages: An unhandled fault has occurred in this flowAn unhandled fault has occurred while processing the flow. Please contact your system administrator for more information. Contact your administrator for help.. For details, see API Exceptions.|FlowRecordUpdate|Activate_Master_Contract
12:25:47.273 (15273717532)|FLOW_ELEMENT_END|3897777de95ef40176a3662bf72a15c17ddea4c-6df4|FlowRecordUpdate|Activate_Master_Contract
12:25:47.273 (15297623601)|FLOW_ELEMENT_ERROR|The flow tried to update these records: null. This error occurred: CANNOT_EXECUTE_FLOW_TRIGGER: The record couldn’t be saved because it failed to trigger a flow. A flow trigger failed to execute the flow with version ID 3010j0000004udl. Flow error messages: An unhandled fault has occurred in this flowAn unhandled fault has occurred while processing the flow. Please contact your system administrator for more information. Contact your administrator for help.. For details, see API Exceptions.||
12:25:47.273 (15297646743)|FLOW_START_INTERVIEW_END|3897777de95ef40176a3662bf72a15c17ddea4c-6df4|OpportunityBookingWizard
12:25:47.314 (15314901632)|VF_SERIALIZE_VIEWSTATE_BEGIN|06615000003GWkr
12:25:47.314 (15318139590)|VF_SERIALIZE_VIEWSTATE_END
12:25:47.320 (15320607889)|CUMULATIVE_LIMIT_USAGE
12:25:47.320 (15320607889)|LIMIT_USAGE_FOR_NS|(default)|
I have a doubt in Salesforce Email tracking. Please give me some solution..
We want to send mass emails to multiple customers. This part we have done successfully to go to Contacts tab => Tools => Mass Email Contacts.
After that we have to find the customers who have opened or clicked that email and send another email to only those customers who have opened or clicked.
I have a doubt. Can you please resolve this issue?
We want to send mass emails to multiple customers. This part we have done successfully to go to Contacts tab => Tools => Mass Email Contacts.
After that we have to find the customers who have opened or clicked that email and send another email to only those customers who have opened or clicked.
So the problem is I’m trying to fetch related Account Name from Contact , So I’ve written SOQL as
“SELECT Id, Account.Name FROM Contact” — Which is running fine in Workbench BUT while putting into my Trigger . It’s fetching on AccountId and ID value.
Following is my Trigger.. (I’m just printing the values to know whether values are coming out as required or not)
Trigger ContactTrigger on Contact( before update){
Hello David,
Are you still using Mavensmate ?, I’m also using it because you said its the best out there. After its new version update, are yo having issue with it ? Like During unit test it doesn’t show Class coverage or Trigger coverage or any other test result. Am i missing here something ?
Hey Alok! I use dev console for smaller things and MavensMate for bigger ones. Haven’t experienced your issue but you can always do the test portion from Salesforce.com!
I am new to SalesForce and trying to learn from your videos in PluralSight. I have experienced with MavensMate download. It’s look like the site is no longer available to download.
Is another way to download it? I am using Windows.
Hi David
Another of your fans here .. really love your style.
I am looking forward to the ‘Integrations’ chapter of your sfdc99 guide or apex academy.
There is lot of stuff online but your method of communicating is just what I need.
I need to work on some integrations as a part of my job , do you have an estimate on when that chapter will be up ?
Any other links to courses on it which have a similar style (obviously not as good as you :-))
Hi David,
I have started learning through Apex Academy and going through ‘Power of SOQL topic’.
I have a doubt in using workbench as I am on ‘free developer edition’ and therefore don’t have any sandbox/production User/Passwords.
I am unable to follow you on the course since you are using workbench for SOQL.
Please guide me on how to proceed.
I am trying to deploy trigger and class through mavnesmate from one dev org to another.
When deployment is complete metadata results shows as success , but the deployment fails , i am not sure how to debug the issue , because i dont see deployment failure message on the deployment status page in dev org.
I am going through ‘Apex Academy’ part 2 , i have created trigger ‘CheckSecretInformation’ and trying to create a case and getting the below error message , but when i deactivate the ‘WarrantySummary’ trigger i am able to create a case without any problem:
Error: Invalid Data.
Review all error messages below to correct your data.
Apex trigger CheckSecretInformation caused an unexpected exception, contact your administrator: CheckSecretInformation: execution of BeforeUpdate caused by: System.DmlException: Insert failed. First exception on row 0; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, WarrantySummary: execution of BeforeInsert caused by: System.NullPointerException: Attempt to de-reference a null object Trigger.WarrantySummary: line 4, column 1: []: Trigger.CheckSecretInformation: line 35, column 1
I know this is late, but I wanted to share what I discovered with anyone else that ran into this error while working through Apex Academy. David put together this great course, and I’m actually pretty excited to have this ‘additional homework’ ! It felt awesome to finally figure it out, and it drove home some of the concepts.
Ok, to the point:
The WarrantySummary trigger is expecting values for fields in the trigger for each case that is created. As both commenters mentioned above, they are adding a Product Purchase Date to the case THEY are adding, but what about the child cases that the new CheckSecretInformation trigger is creating?
So when David replied with “Product_Purchase_Date__c is an empty field!”, he was referring to the child case created.
Follow his instructions on wrapping an if (myCase.Subject != ‘Warning: Parent case may contrain secret info’) around the WarrantySummary trigger and BOOM.
Hi David,
Could you please give me a brief about multi-tenant architecture and how the data from different organizations is stored into Salesforce and how do they ensure the data security for different organizations.
Thanks in advance!
im newbie to programming knows html css and making responsive.I want to learn more skills in javascript.Its good to become a salesforce developer to get proficiency in javascript .I couldnot grasp some differnces how salesforce works anyone please answer
Loved the tutorials, hope you keep writing more of these!
I’m new to Salesforce, but it’s guys like yourself that make me want to push myself to learn as much of it as efficiently as possible.
I am trying to replicate user login history object as a custom object. The reasons are the User Login History is not available in the front end and the data is only stored for the last 6 months. Also, Login Date fields are unavailable in any formula fields. I have created the custom object and created all the API Fields. I am planning to implement a Schedule Class which runs every 30 mins and query the last 60 mins of login data. How does this sound ? Do you recommend any other solutions ?
Thanks David and will keep you posted. I am following your blog from few months which is very useful.
Does all the above Beginner tutorials are included in Apex Academy ? I would like to purchase Apex academy from plural sight and I can see only 3 courses available. Any ETA on the rest of the courses please ?
Does all the above Beginner tutorials are included in Apex Academy ? I would like to purchase Apex academy from plural sight and I can see only 3 courses available. Any ETA on the rest of the courses please ?
Technically there is no finish line for the Apex Academy, so you could be waiting forever!
Honestly the best thing to do would be to make your decision based on only the current line-up. Many tutorials on this site are totally free so if you’re on a budget there’s no need to pay for anything. If your goal is to learn as quickly as possible, then you should consider the Academy =)
Hi David,
i am working as a software tester.I wanted to become a sales force developer.My target is November to get sales force developer.Can you please give some suggestions.
Hi David, this is so cool.
I am working in a call center as IT support doing a bit of programming in C# .Net, SQL SSRS.
The main software we use has just integrate Salesforce in our calls and reports management.
This sounds like a huge opportunity to get to a step forward in my career.
I have read all the answers on this page which respond well to the questions I was having about how to develop in Salesforce.
I will get my hands dirty with coding right away.
If you have advices or recommendations to help me get my learning process smoother, don’t hesitate to alert me.
Again Thanks for bringing to particular light to us.
thanks for your awsome viedos and grt salesforce explanations. really i get more knowledge to learn by number of times.i really appriciate. for that.. david.
Hi, thank you so much for all you are doing. You are a great teacher. I am doing your courses in Pluralsight and I am loving it. I wonder, when will your 3rd course come out? Which day of August?
I really can’t wait
Hi David,
We are nearly at the end of the first half!! any clue as to when?
I have been waiting for this videos for too long, haha… I am having sleepless nights.
Thanks a lot and for all your effort.
I have a quick question. Do you suggest to use the “apex-lang” Utility code library for force.com provided by google. I checked the details and it has a huge and comprehensive list of utility classes. I think we might be using only 10% of the utility classes in any project. So wanted to know the best practices you suggest.
I would like to get some idea, what you do in your project when it comes to creating and reusing utility classes which can be used across multiple projects. Do you copy the classes in all project VS use “apex-lang” third party library or create a managed or unmanaged package of your own developed utility classes.
Hey David!!
I just can’t wait for the next class of Apex Academy. Thank you so much for helping millions of Salesforce aspirants. I have gone through first class of Apex Academy end number of time and each time I learn something new. So when can we expect your second class! I am getting impatient as I know this is going to be a blast. Can’t wait!!
The salesforce development experience is by far the worst I have ever encountered. This is truly awful. Any developer who likes to code with the half-baked apex, the laggy VisualForce, and the lamest javascript framework ever (Lightning), is NOT a real developer. Try out some real languages people and get a job you don’t hate. Look at this if you don’t believe me…
As you may have also noticed, Salesforce StackExchange has quite a good SE community (better than the regular StackExchange in my experience).
Most of the people I often see complaining are usually poor programmers. Is Apex the best language in the world, no. Obviously there are much better, which has a lot to do with the maturity and money behind the language. But, it is a real language.
From my personal experience, there are two things that set it apart: Very simple to setup and that it enforces you to test everything.
Just finished Chapter 1 Quiz and creating Trigger and Class. Moving on to next section. Thanks. Very helpful and encouraging to listen in on the Webinar.
Hi David! Just passing by to thank you again for the free access to the Apex Academy.
Also, if this is not too much, may I request for you to do a video tutorial on how to install Mavensmate in Windows OS.
I’m having a nightmare with this, I believe I’ve followed the steps on your tutorial vid, but for some reason it isn’t working on my end, there might be different steps needed for Windows OS? I’m not sure. I did repeat it a couple of times, uninstalled and re-installed everything, I also did my part and searched for tutorials online on how to install Mavensmate on Windows, but still I’m not getting anywhere…
I had problem too with file read error due to the folder path settings under Windows 10. I changed the path to like this ‘C:\\path\\to\\your\\workspace’ and it worked.
I am a Salesforce admin but new in coding. I am starting to learn APEX and obviously, using your videos to learn. I have my own SFDC dev org and trying to test a sample trigger but having troubles with it. Would you be so kind if I ask on how to correct this? I kept on watching the slide but I still get one more error.
trigger SAMPLE on Account (after insert) {
for (Account acc : Trigger.new) {
Case SAMPLE = new case ();
Case.subject = ‘Sample for my first Trigger’;
Case.status = ‘working’;
Case.description = ‘testing’;
}
}
Error: Compile Error: Expression cannot be assigned at line -1 column -1
I tried to copy yours but same error. What should be the build of the code? If I understood it, first line should be like:
trigger on {
– am I right or just blabbering? Sorry.. I really wanted to learn apex badly.
Please try using Sample instead of case after you have created instance for case.
Like:
Case SAMPLE = new case();
SAMPLE.subject = ‘Sample for my first Trigger’;
Hello David, I have 10 years of experience as a IT systems Administrator, in order for me to get started with Development side of the business does it require for me to get started with the Admin cert or can I start working on the Development side ? although I have very minimum knowledge of programming ? Thank you in advance..
Hi David, Thanks for this usefesul blog. Just a comment to add, It will be very useful if you include tasks which will require use of all (at least as much as you could) aspects of Apex triggers & visualforce controllers. This will help in gaining complete understanding.
Hi David. Thank You very much for your effort. You have written a very good material for a non-tech person like me to understand how to write APEX. I am eager looking fwd to content of chapter 9.
Hi David.. i am yur big fan. When you will complete full content of chapter 8 and 9. I am eagerly waiting for this. Please do it asap if you get chance. Thanks in advance
Hey David, first of all lemme tell u….you are fantastic dude. Would you believe the Salesforce support recommends your website for new bees … This is incredible, keep the good work going !!!
I am having one requirement, but didn’t find any solution for that till now.
Its little complicated and tricky, and quite difficult to explain, let me try to explain you, and hope you will tell me the appropriate solution for that.
I am using new Salesforce console view, to view my cases. In that when I open my record, that will become a Primary Tab, and Details & other related list will become its Sub Tabs.
So what my requirement is, that I want to connect two machines(desktop/laptop) on my desk, and on 1st machine, I want to view the details of Case(which is sub tab) and drag and drop related list data(other sub tabs) into 2nd window, so that it will be visible on my 2nd machine.
I am new to coding and I want to know basic difference between (Function & Method) are they both same.
For ex: database.add() is a function or method.
If they are both are different, then where do we use Function and methods in Salesforce.
Hi David, well I need to read the rest of your tutorials – could you please release them! I am really looking forward to continue studying using your website. Thank you, Sinan
David, Thanks for coming back to support the entire community of budding developers. Salesforce should thank you for your contribution to increasing the developer community (by encouraging and hand holding them to be developers). We are excited and motivated again!! Let the lessons keep on coming!!!!! God bless your for the selfless service you are doing!!!!!
I have some problem, please help me.
I want to integrate salesforce app to Salesforce app. Is it is possible to integration Salesforce to salesforce.
For example:- 1 Salesforce app data to send another salesforce app data.
How can i insert Multiple endpoint URLs remote site srttings through Apex class ,can u send me sample code for that.please its need urgent.this is my mail id nagarajuu.c@gmail.com
Hi could you please give the piece of code regarding the Custom Login Page.
1. remember me check box(should save the username and password in the browser)
2.When username and password is empty error message should display without using
Hi,
Please solve my problem.
How to send email id and password send to personal Email id (like – Gmail or outlook ) and user Login In those email id and password use. and then log in page and use
This is a Code…..
Note: all fields are required.
Controller Code……..
public with sharing class CommunitiesSelfRegController {
public String firstName {get; set;}
public String lastName {get; set;}
public String company {get; set;}
public String email {get; set;}
public String password {get; set {password = value == null ? value : value.trim(); } }
public String confirmPassword {get; set { confirmPassword = value == null ? value : value.trim(); } }
public String communityNickname {get; set { communityNickname = value == null ? value : value.trim(); } }
// it’s okay if password is null – we’ll send the user a random password in that case
if (!isValidPassword()) {
ApexPages.Message msg = new ApexPages.Message(ApexPages.Severity.ERROR, Label.site.passwords_dont_match);
ApexPages.addMessage(msg);
return null;
}
String profileId = null; // To be filled in by customer.
String roleEnum = null; // To be filled in by customer.
String accountId = ”; // To be filled in by customer.
String userName = email;
User u = new User();
u.Username = userName;
u.Email = email;
u.FirstName = firstName;
u.LastName = lastName;
u.CommunityNickname = communityNickname;
u.ProfileId = profileId;
u.CompanyName = company;
Hi David,
Please help me,
How to create a Register Page and login page in visualForce and controller page and email and password send to personal Id like Gmail & Twitter ID for verification, Please tell how to create a code…… Please help
Thank You So much for such a good website on salesforce. I am a Salesforce developer who was struggling to code, but your tutorial has given me confidence that I can surely do better.
From what I understand, merge fields are used mainly for email templates. So it will automatically update the field with the object-field’s value (ex. Greeting this will be replaced by the actual customer’s name. Cross object fields are mainly used for creating workflows. Same function, works for related objects, must have master object.
‘Thanks David’
Thanks for your wonderful site providing immense guidance to people interested in Salesforce CRM.
Reading many of the comments, I appreciate your replying to most of you. Inspired, I also wrote my queries and unfortunately, I was among the few chosen by you not to be replied. May be you are busy or just skipped it by mistake or on intention. Assuming that you might have just skipped, I have hope you will do reply sometime on my last message. And today I am writing again this note to only say you thanks.
I have started learning Java and getting introduced to Salesforce with hopes of someday learning it to be proficient in this. Your site is one key resource in my kit of Salseforce CRM learning material and I am hopeful to achieve good lengths in my career and Salesforce knowledge using this. Ending the message in exactly same words of thanks.
‘Thanks David’
After a decade of development experience using VB6, ASP3, VB.NET, C# – I am assigned to work with a SF team & hence am expected to learn and work using APEX.
Searching through the various available sources, fortunate to have traced this site – for do find it interesting as well as is building confidence in me on learning APEX. Yet, I do have few queries where I need your advice / opinion:
a.
SF/APEX is like beginning something new for me despite my decade long experience.
I am confident I can do this
Yet, I a, not sure on what are the future possibilities I can look for once I learn this (in terms of career).
b.
Until now, I have often been working as Developer or Project Lead, and my future plan is to work in Project Lead, Project Manager in some big brand organizations like google (where you can guide better about).
What will be my prospects to work with such big brands if I excel myself in learning SF.
c.
I really loved your site – and it has added to my confidence, inspiring to learn it well enough to be listed among experts and also attain certification.
At some stage I would wish to then invest time to give back like you and begin a site like yours (distant dream for now) – I hope you will not dislike me for this aim.
My query here is what kind of career path I can draw here for myself – from a beginner to excelling enough to write a site for this – to getting a job with google, etc. and to be a certified developer.
d.
I am confidently hopeful of an honest answer from you on this, hence asking.
Do you see SF to stay in high demand and reward high pay for next few years – asking you from your current experience and vision.
e.
I would wish to learn and excel in SF knowledge starting now – to be proficient enough to begin a site like yours for helping others, be able to switch to big brand companies for job and achieve certifications in SF with my attained knowledge.
My final query here is – will my previous knowledge and experience help me in learning APEX (and is it mandatory to learn Java for same).
+.
This is an additional query – just something out of curiosity. After SF what field you have chosen in your career path.
And will your having shifted focus there still keep you available for any guidance or queries we post to you here or on twitter.
Hope that you will do read my long post and will do reply, for it will be really helpful for me and my career confidence.
common.exception.ApiQueryException: sObject type ‘user__c’ is not supported. If you are attempting to use a custom object, be sure to append the ‘__c’ after the entity name
why i am getting this error
What is the context of your error ? The exception message seems to be pretty clear, the sObject called in your code is not supported by the type.
If you want a clear answer, you should ask a clearer question.
BR
String contID = req.requestURI.subString(req.requestURI.Lastindexof(‘/’)+1);
List cc = new list();
List ac = [select name,(select FirstName,LastName,Email from contacts) from account Limit 10];
//return ac;
sampleExample rs = new sampleExample(ac.firstname ,ac.lastname ,ac.Email );
Error: Compile Error: Initial term of field expression must be a concrete SObject: List at line 25 column 41
last line erreo came ples give any ideas………
Hello Ali,
You are getting an error because you are trying to call directly fields that are held in a list object. If you do want to instanciate a new object, you could use the list as parameter or transfer the list in another variable that you could use afterward.
Look at the anonymous code below to get the big picture :
List acc = [select name,(select FirstName,LastName,Email from contacts) from account Limit 10];
for (Account accs : acc) {
System.debug(‘The name of the related Account is : ‘ + accs.name );
for (contact c : accs.contacts){
System.debug(‘The childs are’ + c.FirstName + c.LastName);
}
}
String contID = req.requestURI.subString(req.requestURI.Lastindexof(‘/’)+1);
List cc = new list();
List ac = [select name,(select FirstName,LastName,Email from contacts) from account Limit 10];
//return ac;
sampleExample rs = new sampleExample(ac.firstname ,ac.lastname ,ac.Email );
Hi David,
What an amazing website. Iam new(just 1 month) to salesforce and have no knowledge of coding, But looking at your website makes me hopeful to become a good developer.
I have a requirement where in I have to convert the created date to Julian date(keeping the leap year in mind too) using http://www.fs.fed.us/fire/partners/fepp/DODprogram/juliandate.htm
I was wondering if we have any formula for Julian dates?
HELP me through this . Task is to implement a trigger on contact This trigger should check that
1.related account must not have more than 10 childs.
2.Update child count in account through trigger whenever a contact is created or update or deleted.
3.While creating a new record in contact it should not allow duplicate record which have email and mobilenumber.
I Have Just small dought consern of SalesForce, is it necessary to had awareness on C# or any other .Net Related technologies For becoming a SalesForce Developer.
Just joined the Austin Developer Group in their Challenge to be a Developer by the end of 2015 using your system. I’m on the Fast Track because I’m not currently working and am making much more progress than I anticipated because the material is not dry like so many others. Can’t wait for you to come visit!
What a great website! I first started by stumbling upon your youtube video, then linkedIn, and now this site. You’re the man! Thanks for making such a great resource!
Hey David – Was wondering if you have ever posted anything about writing a class for Batch Apex? Either way, would you please point me towards your recommended direction? Thanks again for this site that you have created… If it wasn’t for this, I honestly don’t know where I would begin to understand any of this.
I don’t see hyper links from Chapter 8 – Object Oriented Thinking, Example: How to prevent triggers from running twice and the following chapters 9, 10, 11,12, 13 and Visualforce.
You are doing a brilliant job in helping people out with their salesforce skills. I was wondering if you had ever thought of conducting your own webinar coding sessions. I watched your Dreamforce session where you explained the fundamentals of triggers and it was awesome! I understood the basics of triggers so much better. I know this is too much to ask nevertheless I wanted to give it a shot. Thanks a bunch David! You are awesome!
I am a working professional having exp of about 8.5 years in Software Testing in Banking domain.
also I have worked on CRM product as a test analyst. then I discovered this world no#1 CRM product-Salesforce and I decided to switch my career path to Salesforce Dev. My current company is Salesforce partner and have pojects on salesforce
My current company is Salesforce partner and have pojects on salesforce. Will my testing background be considered in my new role? or I will be treated as fresher completely.
Please suggest.
David, thank you for creating this website. I’m an experienced developer but I had to write a complex trigger in Salesforce … And I know absolutely nothing about Salesforce! Your tutorial made it so easy and explained everything in such a no-nonsense way that I have gone from totally-confused to completely-enlightened in just two hours of reading. This is not just for people beginning programming – I think this is absolutely great for even programmers new to Salesforce.
I looked for your email on your website so I could drop you a thank you note, but I couldn’t find it so dropping a comment.
I am getting the error message System.QueryException: List has no rows for assignment to SObject
MY TRIGGER is as follows:
trigger contactRecOwnerUpdate on Contact (before insert)
{
// This trigger sets the owner of the contact record to be the same as the
// owner of the account record
//
// Version 1.0
Map contactMap = new Map();
for (Contact contact : Trigger.New)
{
if(Trigger.isBefore)
{
if (System.Trigger.isInsert)
{
// Find the OwnerID of the account that the contact is going to be associated to
Account contactAccount = [select OwnerId from Account where Id=:contact.AccountId];
// Make the contact owner the same as the account
contact.OwnerId = contactAccount.OwnerId;
// Insert the OwnerId into the contact record
contactMap.put(contact.OwnerId,contact);
}
}
}
}
And MY Class is below:
@isTest
private class TestApexTriggers
{
static testMethod void apexTriggersUnitTest()
{
//Set up user
Profile supportUser = [SELECT Id FROM Profile WHERE Name=’U K Support User’];
Profile supportUserTL = [SELECT Id FROM Profile WHERE Name=’SENIOR MANAGER’];
User nordicTL = [SELECT Id FROM User WHERE ProfileId=:supportUserTL.Id and Alias =’ball’];
// The alias will change when the correct users are created
User nordicAgent = [SELECT Id FROM User WHERE ProfileId=:supportUser.Id and Alias =’rbows’];
// Get a list of all active record types within the system associated to Accounts
List accRTypes = [Select Name, Id From RecordType where sObjectType=’Account’];
// Create a map between the Account record Type Name and Id for for easy retrieval
Map accountRecordTypes = new Map{};
for(RecordType accRT: accRTypes)
accountRecordTypes.put(accRT.Name,accRT.Id);
// Get a list of all active record types within the system associated to Contacts
List conRTypes = [Select Name, Id From RecordType where sObjectType=’Contact’];
// Create a map between the Account record Type Name and Id for for easy retrieval
Map contactRecordTypes = new Map{};
for(RecordType conRT: conRTypes)
contactRecordTypes.put(conRT.Name,conRT.Id);
//Run As nordicTL
System.RunAs(nordicTL)
{
// Test Reseller create
System.debug(‘****** START Reseller Test *******’);
System.debug(‘Expected User: System Administrator’);
System.debug(‘Current User: ‘ + UserInfo.getUserName());
System.debug(‘Current Profile: ‘ + UserInfo.getProfileId());
System.debug(‘****** END Reseller Test *******’);
}
//Run As nordicTL
System.RunAs(nordicAgent)
{
System.debug(‘****** START Home Test *******’);
System.debug(‘****** Creating a list of resellers in the system *******’);
// Get a list of all Resellers within the system associated to Contacts
List resellersList = [Select Name, Id From Account where RecordTypeId=:accountRecordTypes.get(‘Reseller’)];
System.debug(‘****** Creating a map of name, id for the retrieved resellers *******’);
// Create a map between the Reseller Name and Id for for easy retrieval
Map resellers = new Map{};
for(Account resAcc: resellersList)
resellers.put(resAcc.Name,resAcc.Id);
// Test Home create
System.debug(‘Expected User: Support User’);
System.debug(‘Current User: ‘ + UserInfo.getUserName());
System.debug(‘Current Profile: ‘ + UserInfo.getProfileId());
// Test Contact create
System.debug(‘****** START Contact Test *******’);
System.debug(‘****** Creating a list of Home accounts in the system *******’);
// Get a list of all Resellers within the system associated to Contacts
List homesList = [Select Name, Id From Account where RecordTypeId=:accountRecordTypes.get(‘Home’)];
System.debug(‘****** Creating a map of name, id for the retrieved homes *******’);
// Create a map between the Home Account Name and Id for for easy retrieval
Map homes = new Map{};
for(Account homAcc: homesList)
homes.put(homAcc.Name,homAcc.Id);
I’ve recently completed the book: Apex Workbook.
This gave me fine idea of Apex and visual force.
Next, I’m thinking to start with book: Force.com workbook to learn Admin & functional part(which i already know a lil bit.).
M i going in correct path? Or please suggest me the next steps.
Wanted to first thank you for all the amazing work you’ve put into this website! You sir, should be knighted if you ever choose to visit us here in the United Kingdom!
I’ve been wanting to get into Apex coding for a while now but never quite found the motivation to really spend some time on it. I’ve just had an “eureka” moment (which you will find so small!) where I managed to use SOQL, a list and a DML statement to change a candidate’s first name in my dev org! Probably made me way happier than what it should have done…but small victories eh!
I’ll definitely be visiting your page daily as I continue my quest to become a decent Apex programmer.
When can we expect the Quiz for chapter 7 and more topics for chapter 8 and other new chapters. Eagerly waiting for new topics to be published. I am thoroughly enjoying all your articles and quizzes.
David,
you are doing such great work! When I stumbled upon your site, I felt like dropping everything else and jumping right into Salesforce which I’m going to.
I come from programming background (mainly Java, J2EE, SOA integrations) and do not have Salesforce background (yet) BUT I want to pursue my career in Salesforce. Where should I start? Admin? Admin Certifications? then Dev?
Watching your videos from Dreamforce feels like breath of fresh air! Hope to meet you at Dreamforce this year :-)
– SD
I recommend starting off on the dev side and learning admin along the way, only because you have a strong dev background and doing it the other way might bore you =P
hi david,
i am new to salesforce ,wen i am writing this trigger facing an error : Variable does not exist : name
trigger autocon on Account (after insert) {
list lc = new list();
for(account ac : trigger.new){
contact c = new contact();
c.firstname = ac.name;
c.AccountId = ac.id;
c.Phone = ac.phone;
c.MailingCity = ac.billingcity;
lc.add(c);
}
insert lc;
}
and i am preparing for DEV 401,plz suggest me what are things that i need to cover
Hi David,
I found your website one of the plentiful with resources of SalesForce.
What I actually come across is the situation to create a Lead and assign it to the Campaign using SOAP API in C# application.
I just know that in order to do so, first I have to create CampaignMember and then assign it to the Campaign.
But I could not find a good example to start with.
Can you please give me some code snippet so I can make my way for this?
Thanks
Hi David, I need help on these following scenario, I have created 2 Products One is Main Products (Coffee) Second one is offer product(Coffee offer). If I sale or do outward of second one (Coffee offer), stock need to deduct from Main product (Coffee). How can I do this. Please help me on this.
I was making an trigger between two object interview and position. Interview would have one look up which will go to Parent table Postion . What i need to do, i want to automatically generate the Interview date once user would select the position in interview. Postion will have one field start_end date.
trigger Interview on Interview__c (After insert, after update) {
for (interview__C interview : trigger.new)
{
If(position__C ! = null) — look up filled in interview
{
position__c start = [select start_date__c from postition__c where id := ] — (don’t know how will i relate the look up field with the position object detail)
// Means whatever record user will select from this reference , it would take that start end date so i can add it with 30 days which can automatically generate the interview date
interview_date__C = position_c.start + 30;
}
}
yes , i can do but if i need to make this den ?? in the query i need to take a common field which can relate to that or through standard field like ID we can related this ??
Currently I am working as QA engineer on salesforce.I am dev 401 certified and would like to switch in development.I am having total 1.6 years of experience in QA on Salesforce and knowledge of Java programming language.
Kindly suggest me how to learn apex and get into the development.
Dear David,
Are you going to add “Introduction to Apex Web Services” in chapter 11. Integration. I am trying to learn by myself but facing problems to understand webservices.
Please do add Chapters on Visualforce whenever you feel its required for us. :)
You are my GURU. Its becuase of you I have cleared an interview and get a Decent Job of Salesforce Developer. But I am bit nervous about how will I survive as a Developer cause I haven’t have much confidence on Developement APEX & Visualforce.
BTW.. Thanks a lot.. I am just following you blindly and I know i ll become a great Salesforce Developer one day. No one can stop me now.
I have a field API name as DiscountPrice__c,I don’t want this field to be seen in page layout, instead this field should be seen in details page with its Discount price value.How can I accomplish this?Help me.
David you are the super hero(guru) of Salesforce! I finished my Admin 201 certificate with your inspirations and comments in the blog.Now i am working on Dev 401 certification.Thanks for the inspiration!God Bless You with Millions of dollars and Good Health.
1. If any student have wife name populated, then automatically mark him as married [new field] = true.
2. User should not be able to insert/update if that teacher is not active.
3. User should not be able to delete a class if there is any student in it.
I have been going through your tutorials while preparing for my admin exam ( already have Dev 401 ). I just have a question RE: studying the correct way. I have been following your philosophy of your tutorials, going through Head First java and getting certified, however, there seems so many places to learn SF and its overwhelming. Sometimes I think I am not going down the correct path the best way. There is mention of Udacity, Pluralsight , TrailHead, learning VisualForce (do I dare), Lightning Components, developer workbooks. It’s just a little confusing. I don’t want to jump around a lot, but want to absorb as much as possible and complement my learning path.
Do you have any advice for me (and others) for taking the correct steps through a Salesforce learning path?
I want to start learning Salesforce. I do not have much coding knowledge. I have worked in dot net.
Do I need to have strong knowledge of Java, apex etc to be a salesforce developer.
Does Salesforce admin need coding knowledge?Please advise
Hi David, I have been struggling with coding for some time. Just started with your site, You are a boon and God sent for new aspiring coders, you have made a very hard task a fun task. When you do such selfless things in life, you accumulate good wishes and blessings (knowingly or unknowingly) from all your users. God bless!!
David, I’ve never been exposed to coding. I’ve been just a mere Salesforce admin and I was about to be canned because I do not know how to code. However, I created some simple triggers and run those on orgs after I came here, sfdc99 and studied. I still have a far, far way to go, but you’ve been my inspiration and motivation to learn. I really wish if I could treat you to a nice dinner or a beer if I were in your area! Hope to see you around next Dreamforce!
When i am trying to deactivate user get below error:-
You cannot deactivate a user who is receiving cases or notifications as part of your case assignment/escalation rules. Click here to view your case assignment / escalation rules.
User are not part of case assignment rules and escalation rules, but still i am getting error also i have deactivate all assignment/escalation rule but still not able to deactivate user.
Thank you for your guidance. I have bought the book, you suggested, but here am worried – will there be any conflict and confusion in learning both the Java and apex programming at a time alternatively.
I am Sandeep based out of Bangalore (India). I am very excited to see your site sfdc99, it has lot of inspirational information and stories of many achievers from non-developement background. I am on the same path. I have completed 6 years of experience in various IT domains ( mainly with server operations)and thought of looking for a different domain and that is when I heard of SFDC. I took training on ADM201 and DEV401 which helped me understand well about SFDC. I built couple of apps with guidance from training institute. Giving many trys in different companies am failing to clear the interviews( Usually getting rejected saying am good with admin stuff but not with developement). My feel is if I start working atleast as SFDC admin, I can parallelly learn coding which am currently doing. But in India there is no demand for admins. I am a Physically challenged person and getting it hard to get a job in SFDC domain as an admin. Kindly advise and help me with further steps. I really want to work in Salesforce domain as an admin at first and further grow as a developer with detailed learning.
If I was in your situation, I would learn the admin side first. This is best for long-term but will definitely slow your code learning in the beginning. It should take no more than two months of hard work to learn enough of the admin side of things.
After that, learn development but always remember that if you can do something without code, it’s better to do it without code first!
So stay on your path! Just know that you don’t need to go super deep in the admin side before you start coding =)
Hi All,
I work on remedyforce tool. I want to create a email service in which whenever a person sends email to that email service an incident(incident object) get generated. Please help me out
Hi David, I am loving your site and have just got a job as a Salesforce analyst with a view to becoming a Salesforce developer in time. I would love to see some exercises that I could try. Are you considering adding some to your site?
Hi David,
I am new to the salesforce and I am going to write a DEV 401 exam.
For that What are the topics Ive to learn?
I dono what to do learn and dont
HI David,
I have a question on how may users we can create with developer edition of salesforce. i have created two users with license selected as salesforce and after i am not able to select salesforce as license option.
Hi David, are aware of any workaround to fire a trigger from a mass-email? It’s a no-no to tell somebody to do their mass emails outside sfdc because the activity won’t fire a trigger.
You’ll want the trigger to fire on whatever record is saved as a result of the mass email – I believe it is something like an HTML email message or something like that!
The trigger is fire from the record saved as result of the mass emaiil (the task). My trigger runs on Task after insert and after update; it modifies Contact fields. When the Activity from a Mass Email is created, it doesn’t fire the trigger. I see in the documentation that Mass Emails don’t fire triggers, that’s why I’m trying to find a workaround.
Thanks for your posts! You have perfect success story.
I’ve shared your site with Russian Salesforce Community. Here https://salesforce-developer.ru/links
Thanks so much David for taking the time to create this website. I have no formal background in coding and have been trying for awhile to take my developer skills to the next level on the SFDC platform. Before I found your website, I could read some code and copy and paste it but I was really struggling with customizing and applying what I knew to our Org. A colleague of mine pointed me to this website and after reading some of the chapters and watching the webinars the light bulb finally went off, I get it now! The way you present and explain things makes it so easy to understand. Awesome work, can’t thank you enough!
I want to write some code/a trigger to do a lookup. I have a field on my client object that is a custom field. When I create a task related to that client, I want to be able to view some information from the client object on the task (i.e. pull in the phone number or alternate address) and they said I would need to write a trigger to do this. I’m a beginner, can you just point me in the right direction?
Hi David,
I am stuck in a problem. Help me out. I have a Object called residential in this there is a field called Budget Maximum and size maximum. Then the Total value Budget Maximum will be in result.. while i am making a formula then the value in Crores like 70 crore in Budget Maximum and 50 crore in Size maximum is running and total value in the case of Budget maximum is showing, but in the case of (100 crore + )in Budget Maximum and [(Max)-whatever after 100 crore+ ] in Size maximum is not working.. help me out .. what should i write in formula or is it good to make a trigger.? Help me out if trigger how?
question for you David. i see we can use eclipse for writing code but I’m getting pretty familiar with Netbeans. Do you know if there is a plug in connecting netbeans with force.com. I have tried google but can’t find anything.
It’s really confusing to know where to use constant or static when to use what, I know lot of theories in salesforce when coming to implementation, I lose everything how can I enhance that and know what to use when and where
THE Best tutorial for beginners. If a newbie just read through your topics, he would understand all the concepts without even actually working on it. I SIMPLY LOVE IT.
Now desperately awaiting tutorial on BATCH APEX, Scheduling and Future annotations.
If there would have been a rating system, I would rate you 10 out of 5 Dave.
hi david pls give the answer
question: “when ever custmer record is updated,before updating the record create new record in test object with old value of custmer record in salesforce trigger code”
Hi David
Thanks for everything. Got a question. In an apex class, how can I query for child records where the parent id is the same in two or more cases. Can’t do GROUPING BY in apex apparently, so I’m trying to figure out a for loop with something like size()
So – pseudo code something like
Find Id, start_date__c, completion_date__c, parentId where completion_date__c = null in customchild__c record where parentId has more than one customchild__c record.
It would be even better if I could group by parentId and grab only the customchild__c record from each group where start_date__c is the earliest
Hi David, I am from mainframes background and looking to move career from this to sales force. I came across your site and I am loving it. You had everything in detail . Even an amateur in this field can easily grasp the subject. Thank you so much.
I want to become a sales force admin, Should I still go through your Point 1 in Chapter 0 – The Basics or we should start at Point 2 , “The best way to quickly learn the non-coding, admin side of Salesforce”
The best site to learn Apex. I was able to bulkify my first trigger with the help of this site. And it was not an easy one. It had insertions and updations on one object and insertions into another object. Plus a master-detail relationship between both. And I’m glad I did it with your help. Thanks again David…
I need to write a trigger on user object that executes immediately after user login into salesforce. i.e. a field should get updated as soon as user login into salesforce.
hey david….i got a problem…i had a html code which is application for job.i had implemented that html code into visualforce page…i want to save that data on my org.i didnt created any object or anything for that html…..can u help me…?
Hello David, I’m trying to do the SOQL Query in the 2nd video but I’m getting an error that says: ERROR:
Parent relationship queries are disabled in Workbench: Account.Name
Due to issues rendering query results, parent relationship queries are disabled by default. If you understand these limitations, parent relationship queries can be enabled under Settings. Alternatively, parent relationship queries can be run with REST Explorer under the Utilities menu without issue.
Any idea why I’m getting that? I’ve tried with two different developer orgs and I get the same error on both.
David – first mazal tov on the wedding; second thanks for your generous interest in all of us trying to teach ourselves apex.
I’m stuck. I’ve written a trigger and some classes on the Opportunity Object. The code ‘works’ and in the sandbox the 8 methods say covered 100%. However, when I try to deploy it to production it’s 45%. The only other triggers belong to Marketo (appExchange) and they are all 100%. I’m happy to post the code, but I’d really like to learn ‘what I’ve done wrong’.
I already know some things in my test aren’t working as I want so I had to adjust.
Any suggestions on the best next step?
Most likely either…
1. There’s a validation rule in production causing an error in your test class
2. Something in your test class is hardcoded, and that value doesn’t apply in production
3. You’re using the @SeeAllData=true annotation, which often breaks test classes as they’re deployed
Basically something in your test class is breaking, and it only breaks in production because of some difference in production vs sandbox!
Thanks David
After looking at it again (and by the way, I’m totally self taught at all things computer so forgive bad habits):
1) I think I resolved one problem by some different hard-coding, but I’d really like to use variables. However, I’m not sure what the syntax is to do it in the following example [here’s my first bit of code]:
//data setup functions
private static Opportunity createTestOpps(String Name, String StageName, Decimal Probability, Date CloseDate, String Type) {
return new Opportunity (Name=Name, StageName = StageName, Probability = Probability, CloseDate = CloseDate, Type = Type);
}
//create String List for Opportunity StageName picklist values
List stNames = new List();
stNames.add(‘Qual’);
stNames.add(‘Needs’);
stNames.add(‘Rest’);
//create Opportunities
List newTestOpps = new List();
for (Integer i=0; i<10; i++) {
newTestOpps.add(createTestOpps('Trigger'+i, 'Qual', 0.01, date.Today() + 10, 'New Business'));
}
try{
insert newTestOpps;
} catch (DmlException e) {
}
______________________________________________
I would like to replace my String StageName with the variable stNames[0] but I'm not sure what to put instead of 'String'.
2) My trigger and class basically do this:
a) On insert of new opportunity or on update(change) of opportunity stage a custom object record is created and the start date populated to Today(). My testing confirms both of these scenarios work as expected.
b) If an opportunity already had one 'stage' record with an open 'completion date', and the stage is set to the previous opportunity stage value, then the trigger/class go back into that record and populate the completion date with Today() as well. This works in my sandbox. It also says in my test class that 8/8 methods are covered. However, my attempts to update the Opportunity StageName on the records I just created, thereby enacting the trigger/class to create a new record and close the old one are failing to activate the trigger/class. All I'm doing below is updating the value without activating the trigger/class.
//Update opportunity stage to 'Needs'
List firstTestOpps = [Select Id, StageName FROM Opportunity WHERE Id = :insTestOpps];
List updTestOpps = [Select Id, StageName FROM Opportunity WHERE Id = :insTestOpps];
PS – here’s another attempt to get at the new opportunity stage record but I can’t get further and find the updated Stage record (which should have a completion date) or the new Stage Record
//This gives us a frozen view of the opportunity as originally entered
List oldOpp = [SELECT Id, Name, StageName FROM Opportunity WHERE Id = :updOpp.Id];
System.assertEquals(oldOpp[0].StageName, ‘Qual’);
disregard stuff below. By system.debug – which is now my best friend, I’ve found that nothing I’m doing (tried a few ways), is successfully activating the ‘after update’ part of my trigger/class in my test class. I’m presuming I don’t know the way to have the Test class think it’s ‘saving’ a record so I can tell my test record that it’s now being updated and needs to activate the after update part of the trigger. Right now I can update the value in the field that’s supposed to trigger the trigger, but it won’t do it’s bit. (as I’m writing this, just got an idea, but in the meantime…)
…if you can help me figure this out, I would be really grateful.
Salesforce automation means ondemand customer relationship management system,
SalesForce Automation includes ,
* Marketing Automation
* Sales Automation
* Customer Support Management
In simple general words, let us consider a Product that we need to sell.
1) we will do compaigns (advertisments, emails, seminors etc…) to make every one know about our product. (marketing)
2) Then we will sell our product ( sales)
3) Once after selling our product we have to provide customer service if product have any problem ( customer support)
I have a query.
I need to develop a functionality where when user login in to salesforce, one field on user or account object is automatically updated or a PDF is automatically downloaded.
Approach :
1. Firstly, i will write a trigger on user object
2. I need to capture the login event how i will do that ? Could you please help me in this scenario.
If you are able to update a field upon login, then try to write a trigger on that particular updated filed (like when field is updated trigger will fire generating a pdf ).
I was reading few articles to understand the difference between abstract class and virtual class and I came across this http://share-salesforce.blogspot.in/2013/05/salesforce-apex-class-simpleregular-vs.html. The description for abstract class is bit confusing. The only possible explanation to have regular methods within abstract class is that they must be defined as static. Please tell me if my understanding is correct.
Also, can you please explain what’s your take on difference between the abstract and virtual class?
Great question but I honestly don’t know that topic well enough off the top of my head to give you a clear answer! I’d be shocked honestly if any Salesforce development interviews asked about that!
Refer Java documentation directly you will get better explanation.
Dont try to remember them. As hard you try to remember the difference between them that much soon you will forget.. Just go on!! your coding teach you..
Hi David, I have a requirement wherein I need to take the total of all expense line items for a specific category and add this expense total to a amount field in a different object.
1. I used a List to fetch the total from expense line items.
2. And then, fetched the current records from the other object into a map.
3. within a for loop, I get the current value from the map, add it to the total obtained earlier and build a list of objects.
4. Outside the for loop I fire a update DML.
Is there a better way to do this (especially step 2 & 3)?
Hi DAVID
i have 2 orgs.org1 have 10 opp__r object records with 10 child records each which accept duplicates and org2 will not allow duplicates i want to insert the org1 records to org2 without duplicates how?
Hi david ,
i have a validation rule when entering data from sfdc ui i want to fire?i dont want to fire when i am uploading data from external systems eg.ms crm, sybel crm…?how u can achive this?
hey David…….been a regular follower of your blog……….i’m done with all the lessons just wondering when would you start chapter 8 9 10 11…..awaiting your reply
Hi david, can you lend an ear? Can we chat via email rather than on-line. My company is HIPAA compliant and we are in the bay too! If you can provide a private email that would be helpful? Thank you =-) Our website is low key and we are not on facebook.
Hi David, I have a growing company and I am looking to utilize/create software that allows my customers to book appointments via an app or other. We need to provide real time updates on our availability and provide round-the-clock service for our 7 day per week revolving client base connecting to 1200 new customers monthly. We are drowning in a system that needs to go paperless and we need to provide better customer service with timely updates. Can you provide an email so we can connect? I just stumbled on saleforce site.
Thanks for reaching out Nichole! I probably can’t help you out with this one – but you may want to give the Salesforce sales a team a call to see if they can hook you up!
I am new to triggers and have never written in Apex, can you point me in the write direction or do you have sample code in order to update a standard picklist field with all the values from a custom picklist field, i’ve read that this is they way to go in order to update a standard picklist with a custom picklist. I attempted to do this with a worklow in order to do a field update but i am only able to select one of the picklist values and i need to pass all the values.
I have lead statuses that need to be dependent on phases but they are not dependent on phases(custom field) because that status field in SF is a standard field and i can’t use a workflow to update a standard field with a custom field. Our idea was to create a another custom field (lead statuses) this field will be used to create a workflow in order to have lead status dependent on phases and then use the custom field (lead status picklist) to update the standard field picklist.
I need advice. I have had experience administering some SAAS applications like SuccessFactor and Taleo but not Sales Force. I have a background in Computer Science but its been a few years since I last coded. I want to be Sales Force developer but need guidance on how to start. I have ordered Head First Java and started reading it. Is this the right way to start or should I start learning about Sales Force administration before starting with Java. Could you suggest some tutorials/books/videos to get started with administration or should I just continue with your recommended plan.
hey David…….been a regular follower of your blog……….i’m done with all the lessons just wondering when would you start chapter 8 9 10 11…..awaiting your reply
Hi David I have just got a job as salesforce admin.I am new to it.Since i have basic knowledge of java programming my manager has given me a project to develop customized dashboard.I dont know where to start.Please assist
I have just got a job as a salesforce admin and since i have basic knowledge of java coding my manager has given me a project to create customized dash board. I dont know where to start.Kindly assist.
Hi david,
I am new to the salesforce…So can you tell me the flow of sales objects(Campaign,Lead,Account,Contact,Opportunity,Product,Quotes,orders,Contract,cases and solution..)
No words to say, All I can say is I am a SFDC Developer & I’m In from today until I RIP. ~ Respect
My 2 Cents : Kindly add a forum to the site with Vbulletein or something that you find fit and also a way to create username & Pass so that all can be a part of the Salesport.
Your site has been most illuminating; I’m working thru it, the SFDC ‘Apex Workbook,” and “Headfirst Java” all at the same time, spurred along by an urgent project need here at work, where I need to use a trigger to perform a bit of calculation on a customized Opportunity. Normally I’d do this via a formula field or a workflow rule / field update pair, but due to intensive customization in our org, trying to do it with a formula field exceeds the per-object calculation limits, and when I do it using a WFR/FU pair it fails because the WFR runs before other values have finished being calculated – – users end up having to ‘save twice’ to get everything properly calculated on the Opp.
With the help of your tutorials, I’ve managed to build the following trigger; it works fine for individual records in our sandbox instance, but I’m still a little mystified about the whole ‘bulkification’ angle. As far as I can see I’m not making any SOQL or DML calls & the trigger runs before update only, so I don’t THINK I need bulkification, but I’m paranoid and would like to be sure things aren’t going to break later, say on a bulk Opp update done via DataLoader.
I could really use your help, oh SalesForce Sensei!
Can you tell me 1) Does the below trigger need bulkification, and 2) if yes, can you show me how it would work here?
trigger WarrantyCalc on Opportunity (before update) {
String WarrTypeStr1 = ’90 Day Standard-Response’;
String WarrTypeStr2 = ‘1 Year Standard-Response’;
String WarrTypeStr3 = ‘Box Sale-Mfg\’s Warranty Only’; // backslash escapes the sgl-quote char
for (Opportunity oppInLoop : Trigger.new){
if (oppInLoop.Warranty_Cost_Override__c != null) { // part I: Cost selection
oppInLoop.Warranty_Cost__c = oppInLoop.Warranty_Cost_Override__c; // If there’s a cost override, use it
} else if (oppInLoop.Large_Project_Flag__c == ‘No’ && // If project is small AND
(oppInLoop.Selected_Warranty__c == WarrTypeStr1 // If one of these types…
|| oppInLoop.Selected_Warranty__c == WarrTypeStr2
|| oppInLoop.Selected_Warranty__c == WarrTypeStr3 ) ) {
oppInLoop.Warranty_Cost__c = 0; // …cost is Zero
}else{
oppInLoop.Warranty_Cost__c = oppInLoop.Warranty_Cost_Select__c;} // Otherwise, use cost as calculated
if (oppInLoop.Warranty_Sell_Override__c != null) { //Part II: Sell selection
oppInLoop.Warranty_Sell__c = oppInLoop.Warranty_Sell_Override__c; // If there’s a Sell override, use it
} else if (oppInLoop.Warranty_Cost_Override__c != null) { // If there’s a Cost override,
oppInLoop.Warranty_Sell__c = (oppInLoop.Warranty_Cost_Override__c / 0.70); // Calculate Sell based on it
} else if (oppInLoop.Large_Project_Flag__c == ‘No’ && // If project is small AND
(oppInLoop.Selected_Warranty__c == WarrTypeStr1 // If one of these types…
|| oppInLoop.Selected_Warranty__c == WarrTypeStr2
|| oppInLoop.Selected_Warranty__c == WarrTypeStr3 ) ) {
oppInLoop.Warranty_Sell__c = 0; // … Sell is Zero
}else{
oppInLoop.Warranty_Sell__c = oppInLoop.Warranty_List_Select__c;} // Otherwise, use List as calculated
}
}
Thanks in advance for any input you can offer… the project is due next week!
You’re 100% spot on: no need to bulkify since you don’t have SOQL in your trigger!
Best way to check is to:
1. Test on individual records to simply make sure your code works
2. Use data loader to update 200 Opps at the same time to see if you get any errors
Hi David…I’ve been following your site since attending your webinars a month or so back…GREAT stuff to say the least! I do have a question however that i can’t figure out…I’ve written a few triggers in my Sandbox that work perfect, basically when a specific task is completed, the trigger fires and updates a couple custom fields on the Account object. I need to replicate the same action, BUT it needs to happen on an Event – when the date and time pass – but since Events are not “completed” and there is no field change per se…is there a trigger or method to update the custom field(s) on the Account when the Event is technically “completed”? I’m completely lost on this one…any help would be greatly appreciated. Thanks so much!!!
Two solutions:
(Easy) Use a time-based workflow
(Hard) Have a scheduled Apex job (using Batch Apex) to do a daily check of past events
(Medium) Have a time-based workflow update an Event after it passes. Triggers will run on this update
OK…I’d like to keep this as “Easy” as possible, lol… On my Event, the driver for the change is the “Subject” field, so on the time-based workflow would I set it to look at Events with an “End date” of let’s say “YESTERDAY” AND with the particular subject entered as a filter, then if it meets the criteria, have it update the custom field on the Account? Then have it kick-off say at 1:00am each day for the previous day’s entries? Does that seem correct? Sorry if it’s elementary…thanks again David!!!
I created the Custom picklist (Event_Status_c) with 2 values – Not Started and Completed. The default is not Started. I created a workflow rule that will update the custom field to “Completed” once the date/time passes…basically if the Event End Date is YESTERDAY it triggers the rule to run. Tested that and it works perfect…my problem is now with the trigger. Since I’m still a newbie to Apex and triggers, I tried modifying an existing trigger for the Event to update the fields on the Related To Account…below is that code:
trigger changeAccountStageEvent1 on Event (after update) {
List accsToUpdate = new List();
for (Event ev: Trigger.new){
if(ev.Event_Status_c==’Completed’ && ev.Subject==’Initial Sell/Needs Assessment’){
Account ld = new Account(Id=ev.WhatId);
ld.Stage__c = ‘Needs Assessment Completed’;
accsToUpdate.add(ld);
}
}
update accsToUpdate;
}
Problem is I keep getting this error – Error: Compile Error: Invalid field Event_Status_c for SObject Event at line 4 column 16.
Does anything jump out as being wrong in my code? Been battling this one for a while now…but I can’t give up, lol!!!
Hi David
I didnt get another place to post my query so doing it under your reply.
I am a admin and now getting in Development requirements.One such is as follows.
1)During the lead conversion process we have several picklist fields that need to be mapped to several objects(acounts, contacts and opptys) and SFDC standard functionality gives us ability to map it to just one.How can i achieve that.My understanding is a trigger but i am not familiar with writing one.
2)On a case page we have 2 lookups. account owner and project owner.So whenever the case record type is project, the case should be assigned to project owner and in other cases to account owner
Any help will be great..Looking forward for a reply.
Thanks
Hi David
#1 But those are picklist values and we need picklist to be retained.So if i just copy them i will have to maintain 9 Different Picklists.So one value is added in one picklist we will have to manually add them to 9 different places.
#2 Can i get a sample code by chance so i can work around it,I never got my hands on on trigger but now trying to learn them frm above tutotials and others.
Thnks for the help David.
Thank you for your great work. People like you are a true inspiration for our community. I am a Salesforce Admin trying to become a developer. The effort and time you put into this site will help my dreams come true. Once again, thank you!
The National_YTD_Sales__c lives on the opportunity but ultimately I want the value to end up on a Regional Quota object but I am just trying to get a trigger written and working and then worry about tweaking.
The following is my class but there seems to be an error. The error and class is below: What am I doing incorrectly:
MY CLASS
@isTest
public class PopulateContact {
static testMethod void insertNewAsset() {
Asset AssetToCreate = new Asset();
AssetToCreate.Name = ‘ZWave Smart Boiler and Hot Water Controls – Single Zone’;
insert AssetToCreate;
}
}
MY ERROR
30/06/2014 11:40
Class PopulateContact
Method Name insertNewAsset
Pass/Fail Fail
Error Message System.DmlException: Insert failed. First exception on row 0; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, PopulateContact: execution of BeforeInsert
caused by: System.QueryException: List has no rows for assignment to SObject
Trigger.PopulateContact: line 4, column 1: []
Stack Trace Class.PopulateContact.insertNewAsset: line 8, column 1
Hi David .
I need Your Help in Salesforce .
Firstly I will Tell You What Exactly I want to do…….
1. I have two Object CLK And CLKchild in these two Object CLK is a master of CLKchild.
i Created a component which will be used in VF Page many times but can understand how to use in Vf Page.
The Requirement is i have to use jQuery to dynamically add this component in page i will provide a add button which add dynamically this component in Vf Page .
This Component Contain 10 Input Field so when the Vf page Loads initially this component show only one time bydefault and when the user click on add button it will again add the same component below the existing component so now total input fields are now 20.
I have a controller class of VF page on which all save functinality have to be written
so my main prb is how can i achieve this with jquery and how could i get the data from this component into VF Controller class when user fill all those component feild.
Please Reply ASAP
I wrote this test class to update an approval process which gets updated on hourly basis. Unfortunately I am not able to reach the 75% code coverage to move it to production. My current code coverage is 50%. Any advice on this will be greatly appreciated. Thanks.
@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));
You can see which lines of code aren’t being covered by your test class after you run it – take a look, what usually happens is people forget to set variables and the code stops!
Just a quick question. Why cant we create classes for each object and just leave them. From then on we can just concentrate on create triggers. Am I right in thinking so or am I acting thick?
The other thing is about Private and public class. In your Webinars they have not been explained. Please could you throw some light on them.
I am trying to populate contact lookup name and and id on asset
The trigger has no errors but I am sure its not working because when I created the Asset the contact lookup does not populate the name.
All the fields are standard fields
Please find my triffer below:
trigger PopulateContact on Asset (before insert) {
for (Asset NewAsset : Trigger.new) {
if (NewAsset.contactid != null) {
Contact AssetContact = [SELECT Id,Name FROM Contact
WHERE id = :NewAsset.contactid
];
NewAsset.ContactId = AssetContact.Id;
NewAsset.Contact.lastname = AssetContact.name;
}
}
}
In your code you make sure that the asset contact is populated, then you end up populating the asset contact with itself! So you have a self fulfilling prophecy thing going on there!
The asset is created from the account not from contact. So that’s the reason the account is a populated and the relationship created between asset ad account. Now I also wanted the contact to be populated too so the asset will be a child of account and contact
M going thru the Apex4Admins series, currently working on the 2nd webinar from the series – Build on Basics. I tried creating a sample SOQL query in Workbench (replicated the one that you showed in the webinar) but it throws me an error message:
Parent relationship queries are disabled in Workbench: Account.Name
Due to issues rendering query results, parent relationship queries are disabled by default. If you understand these limitations, parent relationship queries can be enabled under Settings. Alternatively, parent relationship queries can be run with REST Explorer under the Utilities menu without issue.
M using Workbench ver 29.0 and using my developer id to login to it. Any idea why am I getting this issue? Appreciate your help!
HI David, I have been reading your pages and took the seminars you recently did, but I have not figured out how to create a trigger based on a stage of an opportunity. It seems most have to do with the creation of something and not the update of a field. Does that make sense? We are basically wanting to create a new project board (custom object) when an opp is closed won with certain fields going over. Can you point me in the right direction?
Not sure where to post this question so I posted here…
How do you get the Developer Console to remember all the logs and various settings? I noticed that when I close all the logs, pages, etc. and go back into the console they come back along with other settings that I changed!
I am speaking on your ORG — when I was at the developer console the other day and I closed all the open log tabs then closed the console and returned, the logs tabs were there again. When I do that on my org the log tabs do not come back!
Hi David,
am a microsoft .net developer and wish to learn sfdc. i have completed learning sfdc fundamentals and the customization.
Need your suggestion for going ahead to code. i have a few apps built on .net and would like to integrate them to sfdc.
Hi David
LIke you I’m completely self-taught (and not nearly as young:)). You are a big encouragement. I got my Developer’s certification about a year ago, and now (if I can find time) want to get Advanced Developer asap. I’m just ordering HeadFirst Java. I’d be grateful if you could point me in any other ways to get this knowledge expediently.
Force yourself to code! DEV 501 has plenty of Visualforce so you definitely need that under your belt. Luckily VF is easy-ish to learn once you have the fundamentals down in Head First Java. Standard documentation is plenty!
Basically find any excuse to code anything! You have all the resources you need to learn right now but not enough experience!
Hope you are doing good. Just a quick question on learnings from the first webinar.
My issue when i wrote a trigger:
In your trigger which you wrote, had 2 standard objects. What to do when you have 2 custom objects?
i am running the following trigger on Band object which would create a band member record. On band member object there is a field which looks up to the band. Both Band and Band Member are custom objects,
Hi David, thanks..it definitely works.
Here i have got another question-
I have a multi select picklist field “type” both in child objects- Band member and Parent object- Band. Now i want to get the chosen values of picklist “type” in band member to the available values of the picklist “type” in band object. E,g: If type in band member has values {guitar, drum, vocal, base programming} and i choose guitar and drum here…so now type field in band object should show guitar and drum values only among the available values.
%Following trigger copies the entire picklist from child object to the parent object.%
trigger Updateparent on Band_Members__c (after insert, after update) {
Set parents = new Set();
for (Band_Members__c child : trigger.new) {
if(child.Band__c != null){
parents.add(new Band__c(Id = child.Band__c, Type__c = child.Type__c)); // Copying type from child to parent
}
}
if(!parents.isEmpty()){
List toUpdate = new List();
toUpdate.addAll(parents);
update toUpdate;
}
}
Actually i m a marketing guy and now i left my job. Because i want to become salesforce developer. But i don’t know how to start and will i be able to do this. i am so confused. Please help me….Please!!!
this is sreenu….actually i don’t have any coding experience.i want become a good programmer.please help me.how to i learn programming in simple way..what books are reffered…please tell me…i am waiting for your reply…
Hi David,
sorry! to say this i think i am enough prepared to write trigger on any task but the problem i face is that the code length whereas other experts take 10 line of code and i take 20 for the same task can you help me out from this. so that how can i make my code short and best??
Thanks for the reply. I did this with the workflow, but now want to do this through code.. just to improve my coding skills and my knowledge.. I’ll just look into things deeper now..
Can you help me with this. I need to write a trigger to create and assign a dummy task to account owner on account creation if reporting country of account owner is India…
(The account owner’s reporting country is a tricky part for me) :(
Your site is a great help, I am a beginner and this really helps.
On the Developer Edition I would like to add Quotes as an option on the Tabs at the top, cannot find out how to do this. Can you please let me know how I can do this.
Hi David, this is really great information that you have put together. I come from a Java background and this really puts it in a great perspective how you can learn SFDC in more efficient manner. Couple of questions that I have.
1. Do you use Eclipse? If so do you recommend using it?
2. How can we setup source control for SFDC?
Most of the time I do use Eclipse! Nowadays though I find myself using the web ui or developer console more and more. They’re getting much better each release!
A lot of companies use source control (git, etc) but a surprisingly large amount don’t =) Salesforce doesn’t do it out of the box so most companies just override their code over and over! Haven’t set it up specifically but I would be shocked if there wasn’t a good tutorial on it somewhere on the web =)
i believe you said i should not worry about the webinar if i am going through the chapters right? or should i stop and watch webinars that you have posted. sorry if i asked this before!
Immerse yourself in code =) You will learn things in the webinar that are not taught on this site, and vice versa! The small time investment will give you lots of ROI!
david, can i use your free account to do your chapter exercises? also, if i wanted to just use the code you do in your chapters i would just kinda copy that code and just paste and see if it runs just like you show in your examples right?
last question is sandbox. do we as developers have to create a sanbox or is it created for us. i kinda don’t understand where a sandbox is and how to get there etc. the only thing i ever use is a freed developer account on the free trail. i am plowing through your chapters as i stated to you =)
also when you deploy you have to do inbound and outboud change sets right? you can just do change stets by using setup menu and then hitting deploy on whatever you have done in your sanbox.
getting this terminology down is my desire. like what is environment vs org and what is test org etc? I saw your video series and i would like to commend your work! keep it up sir! i hope you become super successful!
Hi David,
eagerly waiting for your next post on object oriented thinking.i learned triggers by practicing ur 1 to 7 chapters.now in the market who knows vf pages n triggers are getting jobs quickly.iam a jobseeker in sfdc..so plzz post those lessions if u find free time.thanks alot for ur support.this is the best site to learn sfdc till my all searches.so plzz try to post early…
YOU rock man! My Java book is arriving tomorrow and I will be reading away and taking be on this site all weekend! Quick question, will you have something for us to become a developer of VisualForce? I understand it can use HTML and or Javascript?
Hi, firstly thanks so much for creating sfdc99, what a great find!
I’ve just started looking at Apex today as I need to go beyond the point-and-click adventure I have had so far with Salesforce. Working for a UK charity with no budget means I am reliant on self education and this site has helped enormously, but….
At the risk of preempting Chapter 9 I have a specific requirement and I’d appreciate your comment on my proposed solution:
We have a thriving web site (www.nfm.org.uk) with a web form to allow prospective clients to self-refer (referral form). Currently that form gets emailed to the admin team and copied into Salesforce. The form software can write directly to Salesforce so I set up a custom object to receive the data (Web_Referrals). Now I need to copy that data to 2 existing objects to create “Case” and 2 “Clients” linked (master-child) to that Case assuming the data is ok.
So I thought just stick a custom button on the Web_Referrals detail screen, write some Javascript to call an Apex class/method. I’ve written some dummy code to emulate creating a case but cannot work out how to reference the Referrals fields in the Apex code.
Am I going about this the right way? I’ve google’d it to death but cannot find the answer so any tips/advice/pointers to other resources would be welcomed,.
Hi David,
I have worked as a windows admin.When I came to know about Salesforce and its development and demand,I want to become a Salesforce developer like you.I want tom follow your path for that so I have started you steps.I want to become Salesforce developer this summer and want to participate in this year’s Dreamforce Event.Please guide for my dream.
In everyone’s mind there will be a doubt when to use before vs after triggers.the way u expalined is excellent .i dont have words to tell, how much these lessions r helping me and building confidence in me.
i have so many doubts in apex classes and vf pages.if possible please write those lessons also…as they r most imp in interview point of view.
Thanks in advace.Thanks alot for ur tutorials.
where can i practice code? like when i see your tutorial and i want to copy and get same results? is it the inline editor in the free developer environment for visual force pages?
can you tell me steps how to start using a vf page? create a class , create a controller etc? I heard most people use inline editor once you create a page to code? some people said developer console? i have no idea what that is?
some terms if you can clarify
what are classess? public? private? test?
what are governor limits?
what are standard/custom controller? how do you create both?(sample code)
lastly i don’t understand the bracket usage for code( sorry i am really new to code)
in general when you type a line of code do you put opening bracket like this “{” and closing bracket “}” that ends one line of code? some of those brackets confuses the heck out of me. i forgot the rules. I also don’t understand the little “.” and other stuff in the lines of code. it looks alien but i will try to grasp it. i am trying to learn some in thatwebsitecalled ww3schools for beginners.
bear with me i only have two more questions i will ask you and then try to tackle myself.
I apologize for the inconvenience.
you rock! I would like your autograph one day for being a coding hero!
Some of these questions are way too advanced for you to worry about right now hahaha. Once you’re comfortable with topics in chapters 0 – 7 you can begin researching these things!
Think of brackets as simply layers of code. You’ll become more comfortable with it as you go through the chapters on this site =)
P.S. things like Javascript, HTML/CSS, and other technologies on w3schools aren’t really helpful for learning Apex! You have to learn Apex before learning Visualforce (otherwise you will be really confused, which is probably why you’re pretty confused right now). Then, while learning Visualforce, you should learn HTML/CSS. Javascript comes after that =)
David i think i will do this. I will follow what you say rather than asking questions.
so let’s do this step by step.
first step is…
do chapters 0-7? correct? i will be able to grasp this without that javabook? the only reason i showed those video is because i can’t but that java book and i need to start some learning and not waste timeetc.
so anyway, say yes/no to the step i mentioned and then we will do next step. like that you can guide me and i won’t ask anything else until i complete that step.
Thanks. I will contact you after i am done with chapter 7. would that be enough knolwedge to start as a noob developer in a company ? =) Is your webinar about these chapters? should i watch it or continue with this stuff as you suggested.
Hey i am trying to get a job as a salesforce developer.
here is my background: i just played around a little bit with free developer environment and did some basic stuff like create custom objects and some apps. I don’t know much about admin stuff. I am just learning javascript and trying to remember html.
here are my questions….
1) i know you need javascript for apex and i really don’t have much time to for a book so i am using this link(please look at it quickly). do you think this is good fro me to move ahead to apex guide you have from chapter 0? I mean i don’t have much time and i think i can pcik other stuff on job. also is html used for apex? what about css? would i have to learn these as well to understand the code you write in apex for salesforce?
2)as far as admin goes like i said i only played around with basic stuff like creating accounts etc. i know you gave a link to what admin concepts we need before we code. would watching those short 2 min salesforce videos on all the areas you gave in your link be enough? again i am trying to get job in three weeks and don’t have much time. how much admin stuff would we really need as developer? i mean i don’t see it as a prereq for developer and we don’t use it on our job correct? i certainly don’t know anything about territory management and currency management etc. would we need this?
3) lastly if i follow your guide from chapter 0 to the bottom would i have adequate skills to go as entry level developer? i am using your beginner tutorial to prepare i have no previous code experience and not much admin experience.
I totally understand that you want to learn Apex as quickly as possible. That’s why I made this site – so that you could focus on just the important lessons and avoid all the unnecessary stuff.
Please, I beg you, put in the time to study and don’t take any shortcuts. The only person you end up cheating is yourself! You can be a developer by the end of Summer. That’s really quick and it’s going to change your entire life! 5 – 10 hours a week for a few months is all it takes.
Life is all about priorities Sen. There are going to be times where you’ll have to prioritize learning code versus having fun, hanging out with friends, partying, etc. The small choices you make in these scenarios will add up over time and determine where you end up in life!
I will help you every step of the way Sen. But I can only point you in the right direction. Study. Work hard! Help me help you! I believe you can do it =)
This is Srinivas,May i know how to create a field in an object by using apex tags..? u understand my question right—>creating fields to an newly created object..Thanks in advance.
Hi David, Amazing posts…wished, all the topics you mentioned above was covered.Waiting for them to come in future is a bit painful.But, thankx for all the “Hard” effort you are putting in explaining u’r followers on this site. I have a basic question related to deployment. When deplying from Sanbox to Production we need overall coverage of 75% minimum. Is this code coverage limit same for Sanbox to sandbox org. Or we can deploy without 75% overall code coverage.
I am new bie to salesforce – planning to learn salesforce seeing the job market is high. But i dont know programming so was wondering what percentage of programming does salesforce developer course includes .
I am worried if this is right choice to choose salesforce as career can non programmer learn the developer course.
please provide ur inputs. will be gratefull.
awaiting for the reply!!
Thanks
Great stuff… You must be a mind reader just starting out as a salesforce developer the market is defo hot.. Hope you the the last few links added. Thanks mate
This is a wonderful website for beginners like myself , i have followed the steps mentioned in here and have managed to successfully run the test class, but my question is , how do i put this code in to use, i mean in real time , like when the class is executed new user should be created,i am using the free developer edition and don’t have access to sandbox.
Here you go =)
[SELECT Id, LeadId, CampaignId FROM CampaignMember WHERE LeadId = ‘0123456789’];
If you must do it from Leads:
[SELECT Id, (SELECT Id, CampaignId FROM CampaignMembers ORDER BY CreatedDate ASC LIMIT 1) FROM Lead WHERE LeadId = ‘0123456789’];
hi , i am new to sfdc, this blog is v helpful..but i can see only 7 chapters, to see chaper 8 do i need any extra privilege or it is yet to be posted??
David, I am new to salesforce development and have been tasked with keeping an existing ERP systems Contacts in sync with any new contact entered into to Salesforce. Can this be accomplished with an After Insert trigger and would this be the best approach for such an operation? Thanks, Tony
Hey David, please feel free to shoot me an email of your chapter drafts if you want any help with text editing, code scenarios, or just a second set of eyes. Keep it UP!!!
Sometimes you need to make large database changes that aren’t possible due to the Governor Limits in a trigger.
For example, you might have an integration with an external system where all records need to be synced at least on a daily basis. You couldn’t do this with a trigger because you’d run into a 50,000 record limit. However with batch Apex, you have much larger limits and can do this no problem!
Since you wouldn’t want to manually call your batch Apex every night, you’d use scheduled Apex to automatically call your batch Apex every day.
Got it!Thanks for your valuable comments.
Another question regarding test classes and code coverage.
Ques:
1) what are test class?
2) what we write in test class?
3) what is the need to write them?
4) how they actually work?
5) how we increase the code coverage if less than 75%?
Note:I know the theoretical concept that tells us that if code coverage is more than 75% then u can upload that class from sandbox to prod.Can you please clarify more!
You can look at the “Extended look” link at the bottom if you want even more detail =)
The 75% number is simply a random cutoff that Salesforce chose. In a lot of cases it’s impossible to reach 100% code coverage. For example, you might have a trigger that runs 1,000 different scenarios depending on certain conditions. To test all 1,000 would be crazy, so Salesforce lowered it and make it only 75% of all possible lines of code.
If your coverage is under 75% it simply means at least 25% of the lines of code in your trigger never ran. You’d need to write more tests to make those run!
Thanks Bro!
David ,can we design a complete website using Vf coding (Vf pages combined together) and is it compulsory,if i have designed it for my customers,they also have login first in salesforce then they can access my site.for e.g-i run a grocery store ,i want my customers to purchase grocery online using my website and i have designed a website using VF pages and apex classes and i want my end users to access it.is it possible,if they can access it across internet and no need to login first in salesforce.?Please explain.
The page gets refreshed everytime ,i click on Sum Button.I want that page should not get refreshed when i hit for Sum Button,what changes shall i make.
My class looks like:
public class AddNumbers
{
public integer a{set;get;}
public integer b{set;get;}
public integer c{set;get;}
public void add()
{
c=a+b;
}
}
Without knowing your code, what you probably want to do is add a rerender element on your command button. The rerender should point to the outputpanel containing your “Sum” field.
Hi sanjay ,
read the below.
A button that is rendered as an HTML input element with the type attribute set to submit, reset, or image, depending on the tag’s specified values. The button executes an action defined by a controller, and then either” refreshes the current page”, or navigates to a different page based on the PageReference variable that is returned by the action.
IF you don’t want to get the page refreshed then u might use the “HTML input button”instead of apex:button
The page gets refreshed everytime ,i click on result Button.I want that page should not get refreshed when i hit for result, button,what changes shall i make.
My class looks like:
public class AddNumbers
{
public integer a{set;get;}
public integer b{set;get;}
public integer c{set;get;}
public void add()
{
c=a+b;
}
}
David thank u so much, i just started learning and i am feeling so confident now.
when will you update chapter 7 waiting for them. eagerly waiting for the integration part.
Hi Yaniv,
As far as my understanding on #9 goes, Salesforce does some native rendering automatically once you access the application from mobile (Salesforce1). For that you need to enable some options in your settings (mobile settings, Salesforce1, etc).
Apart from that, when you create VF pages, you will see an option (checkbox) to enable it for mobile rendering as well (since VF pages are customized, so standard SFDC mobile rendering will not apply for them unless you select that checkbox).
Also I found some device level tags like below that you can use:
Also, you can trim off the header and the sidebar from your VF page for better viewing in mobile.
I’m sure there are some more details, just do some googling and you will get it.
I’m a developer working in SalesForce. Thank you so much for this site! I generally find it difficult to get decent help with developing in SalesForce, but your site is amazing! Thank you!
Your Site helped a lot.Thanks for guiding!!
Want some sites or materials from where i can study -to pass ADM201?please help!! The sites I found were 2-3 years old so will not help me with current exam since sales force updating every season.
I have a requirement that through custom VF page i am editing Account information like Account Name, Account Owner,Parent Account etc.
So I have created a Custom VF page but now I want to add condition to display different fields based on the Account Record type.
AS their are two record types in Account :
1) Person Account: In this type of account ‘First Name’ and ‘Last name’ is required.
2) Business Account: In this ‘Account Name’ is required.
So I want to display First name and Last name when admin select Record Type =’Person Account’ and display ‘Account Name’ when admin select Record Type =’Business Account’. in VF page.
i would like to know some details mentioned below.
1. What is Standard Set Controller. In which scenario it will use?
2. What is the purpose of Grant option in OWDs?
3. How to control the Workflow actions in Triggers?
4. How to load both the master and detail records at a time into database using SOQL query?
5. How to create Wizards in Salesforce?
6. What is the admin permission exist in PROFILEs to enable/disable DEBUG MODE option?
7. How to upload documents using Data Loader?
8. What is OAUTH and purpose in Salesforce?
9. What are all the changes needed in Visualforce pages and Apex classes to convert a web application to a mobile application?
10. What are Analytics in Salesforce?
Your guess is correct. I am looking for new opportunities and mentioned are some of the Qs I faced. Sure that I will get answers from Google for all. Need your help for below mentioned 3 questions for which i didn’t find correct one.
5. How to create Wizards in Salesforce?
Per my understanding, can write VFPs that resembles Wizards in execution. But there is no direct option in Salesforce to create Wizards. Please correct me if I am wrong.
6. What is the admin permission exist in PROFILEs to enable/disable DEBUG MODE option?
Per my understanding, there is no option or administrative setting in PROFILE to enable/disable the debug mode.
9. What are all the changes needed in Visualforce pages and Apex classes to convert a web application to a mobile application?
I am functional admin trying to get into the development realm. Having a tough day at my job where I have to
1. Hide a Contact Name custom field on opportunity object on the detail page
2. Based on the Contact name I have to create a Contact Role on the Opp marked as primary and set a role
3. Create a contact role on opp when its created from the Contact Object
Now I know for the first one I need to create Visual force page and add to the standard opportunity page layouts. However, I have never written a VF page before
and I need some direction in the next 2 as well.
Please help! I have started writing beginner level code (triggers) thanks to you, but I think the abov eis way beyond my understanding right now. Please privde some direction as to where and how I should get started.
This stuff sounds like it can be done without code!
1. Remove the field from the page layout
2 & 3. Only allow opps to be created from Contacts – this will automatically add them as a Contact Role on the opp as a primary contact! You can even write a trigger to move this along further!
Hi, I am Very new to SF… I need to do automatically convert lead to opportunity. If contact is not exist we need to create new contact, if contact is exist we need not create contact, and this lead automatically convert into opportunity.
this is converting lead to opportunity but not immediately. After adding lead this code executed and ” Converted Lead ” page showing with contact, account and Opportunity values. After clicking this value only this record move to opportunity.
Why we need to click, after that only record move to contact , account , opportunity. I need auto convert.
So the Lead is actually converted immediately after you create the lead – whether or not you click any links after that!
What happens is that Salesforce tries to navigate to the lead after the trigger finishes, and that goes to the page with links to the Account, Contact, and Opportunity. This is something you can’t change unfortunately! Triggers also cannot force a user to go to a certain page after it runs – only Visualforce can do this!
So your options are to either let it be as is (lead gets converted but landing page is not ideal), or, build a Visualforce page to redirect the user to the Opportunity! I recommend the former option since it’s a lot simpler!
Just wanted to leave a quick message of appreciation, i am also a ‘Junior dev’ and still learning the ropes, you have covered a lot of core information which is great, I have recommended this to many colleagues and will continue to do so!
I just started my coding on Apex. I have a problem in accessing ProductFamily, which is a pick list from the Visual Force Page. I have written the Custom Controller. But Still I am not able to get my ProductFamily fields in the picklist. Its null and I am getting null pointer exception.
My COntroller is as follows
public without sharing class UserController
{
public List UserTemp = new List();
public UserController()
{
}
public List UserList
{
get
{
UserTemp = [Select Name, ProductCode,Family From Product2];
I tried that bro. Now using the standard controller to display the picklist values. But after I choose a picklist, one more list should be displayed, based on the selected value. I am not finding how to do this.
is there really demand for simply admin people in the market? feel like people want developers or admins who code etc? would i be able to get a job as simply admin. i mean i can learn code later if i want on my own time but i feel like focus on one thing at time you know?
I agree that’s it’s best to learn the admin stuff first. You cannot be a good developer without being very good as an admin!
Market for both right now is hot but it’s a little better for devs. In the end, you need to choose what you enjoy the most, because you’ll be spending 40+ hours a week doing it!
i can’t seem to find the checkout enabled box for my user detail page. it told my to give manage billing permission first and i did that at my sys admin profile but then when i wen to my user detail page the checkout enable box is not there.
this checkout is to allow user to purchase additional license as you know.
info
i am using free developer account. license is salesforce.
what is a org that you refrred to? is org the company you are hired and working with?
also with regards to code…..
i barely know it or code stuff and am going fro admin right now.
Do i need sql/soql query languages for admin work or does that come later when i become a developer etc? what is the breadth of code needed for admin work? i assumed business logic like workflow, validation rules would be enough. i guess conditional statements like basic if then statements are all you need. i am assuming apex library and java not really needed? i was told you need triggers along with everything i stated.
planning on go for developer after admin so i have asked you.
when you enable things for users you do that at the profile level and all user to that profile have those right? you don’t need to go to each user to enable that etc? it is only when you want to give some users special access you use permissions correct and then you go to that indvidual user?
also, when you use permission do you need to first use a permission set and assign a user to that set and add the permission or no? I also think you don’t need permission set licenses for every permission?
lastly, how do you add user and feature license s to users? do you just do that at profile level or do you have to click on user or when you create a new user and assign that? for feature it says click users etc. basically i am confused what to add on prole level vs go to a user specifically for?
also are feature licenses related to user licenses or a part of them or separate? I hope my query was clear! I am studying for the company profile aspect of the admin exam.
org?
environment?
instance?
sandbox?
production
deployment?
i have a free developer environment account from developer force and that is the only thing i know. can you put these terms in your own words and relate them to mu free account so i can understand? thanks =)
also do admins need lot of sql stuff or just apex triggers?
Org – your Salesforce instance!
Environment – Same as org!
Instance – Same as org!
Sandbox – a type of org that is a copy of your “normal” instance but has no records. Good for practicing!
Production – your normal Salesforce org that your users are using!
Deployment – migrating things from sandbox to production!
SQL/SOQL is critical to writing triggers, almost every trigger will use it!
Dear David,
I need to create the following task only with trigger:
1. There is a Custom Object A with two child objects A1 and A2.
2. Each child objects has a mutiselect picklist field.
3. A1 has picklist values like food, beverage and whereas A2 has
picklist values like food, games.
Task: Whenever we select all picklist values of Child objects A1 and A2 ,the parent object A must populate all value of child records and it should be only unique values of child picklist value, for example, if I select the all the value of multiselect picklist of both child objects A1 and A2 then A parent object must populate food, beverage and games only not food twice.
I need this task to be completed only with trigger code, please provide the solution for the problem.
I
Here’s how to tackle the problem:
1. Create a trigger on the child object
2. In the trigger, traverse to the parent object and query all child objects
3. Loop through the child objects and add the picklist values to a Set (to prevent duplicates)
4. Update the master picklist on the parent object
Batch Apex lets you run and schedule huge coding jobs!
You’ll want to use batch apex if:
– You need to schedule something to run at a specific time on a repeating schedule
– Governor limits prevent you from doing the mass calculations you need in a trigger
Thanks a lot for the material you provided bro.Yesterday,i cleared a interview for the tier 2 developer support for salesforce,now i will appear for next round by 1 feb in which they will ask me about force.com platform and visual force pages and coding part.if i will find difficulty while studying that in next 15 days,i ll surely ask for your help.thanks a ton……..God bless you.
Hi David,
I have a merchandise object and line item object……when I place an order via a line item record, the merchandise inventory should get reduced accordingly. Can you help with this.
Can you recommend me some material for administrator part.i am working on sfdc for last 1 month.i am developing my app. in my developer org. for a school.i have used custom objects,custom tabs,custom fields,designed profiles and roles as well.used master-detail and look up as well.its really interesting,i think atleast for 6 months ,i should focus on admin part bcoz there are lots and lots of things such as workflow,approval process,junction obect,time based work flow,much more to undrstand and then i should jump into developer part.
1.So ,can you suggest me some material for admin part.
2.Can you explain me what is Record Type.
Think of record types as categories. For example, you might have a record type category for “Public” accounts and “Private” accounts. The biggest advantage of record types is that you can show different fields for each record type. For example, “Public” accounts could have a field for “Stock Price”, while “Private” accounts wouldn’t show that field.
Can you please explain me the difference with real world example for Workflow and Approval Process.
for e.g student(object) issuing a book from library(object) with date of issue and date of return fields. if student returns a book after 2 days ,he should be imposed a fine of $1 every day till he returns.So,will the workflow work for it or approval.
For your particular requirement, that won’t be possible with a workflow. Workflows are very simple “If this, then that” and don’t have access to other record values. So you’d need code in your book example.
Approvals wouldn’t really be used anywhere for your requirement!
Hii David ,
I created four custom objects ,A which is a a parent of B and B which is a parent of C and C is a parent of D. Each custom objects has amount field with currency data type.The thing is this ,I need to create this task only withTrigger in such a way so that it will calculate
the amount like B’s custom field i.e A+B will show addition of amount of both A and B . C will also display addition of amount of B and C same thing with D .Please provide me how to accomplish this task.
So let’s say A has three child objects of B, each with amount 10, 20, and 30. You can create a roll-up summary on A that sums up all the amounts of the children Bs, in this case, that would be 10 + 20 + 30 = 60. If you need to add A’s amount (let’s say it’s 50), create a formula that adds the two together 50 + 60 = 110.
You’ll mostly use {get; set;} when creating Visualforce pages and controllers. Outside of that they are not really necessary unless you’re building a huge app!
Adding {get; set;} after a variable automatically creates two methods for you that you can use. For example, with a “name” variable
String name {get; set;}
// These two methods are automatically created in the background
public String getName() {
return name;
}
public void setName(String n) {
name = n;
}
I want to make the below query dynamic, In below code I am using hard-coded values (integer i=1;i<=5;i++)
I know I can use size() method but in this case number depends on fields on Address object.
Currently in Address object there are 5 Fields so I have taken i<=5. I want in future if someone adds few more fields to that object we should not change the code. Plz help.
public with sharing class abc123dynamic {
public list addr = new list();
public string initialquery=’select Name,’;
public string middlequery=”;
public string finalquery=’ from Addrress__c’;
public string strq=”;
Eric – thanks so much for this! Reading about your experiences makes me realize that other non-techies are not alone in trying to figure this stuff out, and there’s hope, too!
Question on guidance… When would you recommend that people go through the links on this page (in order), versus starting off with 1 blog post and clicking the “next” link at the bottom of the post? Sometimes those go to additional articles that aren’t necessarily referenced on this page.
Hi David, you have done a wonderful job and I appreciate your efforts you put into to explain things in a very way.Best thing about you you respond to many of the mails and comments..please keep up the spirit
I would request you to please explain collections in a detail ways , as collections play a very important role. for example map collection requires lot of visualization to actually implement it.
Would appreciate if you explain collections in very details
Hi David,
I want to add two case fields in my custom VF page where i used Standard Controller= Account.
Is their any way to add case field in VF page using statndard controller as Account.
Below is my code.
I want to start off by saying a big “THANK YOU”. The information provided in this site is clear and easy to understand. I found your website on LinkedIn from an answer to a question someone asked on “how beginners could learn Apex”. I actually have practiced all the workbooks and materials “everyone” recommends for beginners but did not get a solid grasp of Apex language until I started going through the lessons on this site. You nailed it for me with this site. The lessons on this site connected the dots for me.
I spent over five hours on this site yesterday. I enjoyed the humor in your teaching style and love the practical examples. I found your words of encouragement and tips very helpful too. I have now completed all the lessons and I am hungry for more lessons from you. I have already sent your website info to new folks in SF that I know.
I just thought to leave a comment to encourage your desire to help others and find out what I could do to show some more appreciation. I honestly feel a “Thank You” is just not enough for this brilliant work. Well done.
Thanks a lot David for helping me understand the triggers,
your website is truely helpful for a beginner like me, if possible could you please add some simple Apex and Visualforce codes(apart from triggers) which will further help in understanding Apex and VF code.
Thank you Manish! There will definitely be lessons in VF and the non-trigger portions of Apex! I’d like to take it one step further even and talk about object oriented theory too!
looking forward to see next posts… Thanks for ur immense help… I was searching for all the sitesvery madly to learn the apex and got struck here with ur amazing site.. Its seriously soo helpful for me…
First off, remember that the DEV401 exam has no code in it. Absolutely zero! It’s actually very similar to ADM201 or ADM211.
There are two sites I highly recommend for passing DEV401:
1. Sample Recruiting App: this is good because it covers all the major features of Salesforce (workflows, validation rules, custom objects) http://bit.ly/1bge5A3
Hi David. Can you help me with this ? I’ve tried searching a lot for this but so far all my efforts are in vain.
I need to track ‘Days since last Event’ on every Account record. I need to prep a report for my org’s top mgmt. The default ‘Days since last Activity’ wont help me.
If you have come across any similar article which can help me on this, Please guide me. Thanks.
And Yeah, I’m a newbie. I’ve just started with Head First Java and loving it.
If you’re familiar with Roll-Up Summary fields, you can simply create one that gets the “MAX” date of associated Event records. You’d even be able to add criteria to your field to only get the MAX of certain Events.
Thanks for the prompt reply. However I’m unable to get it to work.
I installed the App and followed the step by step procedure. However the field on the Account object ‘Date of Last Event’ isn’t updating for some reason. I used the MAX(Completed Date) field of Event with a filter stating: Event Status = ‘Completed’..
Try doing it on a brand new set of accounts and events to see what happens! I suspect that it doesn’t work on older records unless you trigger it in a certain way!
If all else fails, give their support a call!
1.847.574.5742
Thanks for making this site and being so helpful in the support forum. I found your link there and came here and just want to express my thanks. I’ve been looking for a way to look down so I can write a trigger to update the children of a self-join when certain parent’s fields are updated. Most other code I found was way over my head. Your clear presentation made it easy to understand what I need to do. Also, your humor is greatly appreciated, too. That strawberry smoothy was delicious!
Thanks for the reply David,
I’m exactly asking about the functionality and link between Salesforce Standard Objects like Opportunity, Products, Opportunity line items, Quotes, Forecasting like things.
Thanks for the inspiration! I’m going to have a future chapter on data models and the different relationships between objects. For now though I recommend looking at Salesforce standard documentation for this kind of stuff.
David,
I posted some code to copy the task object’s activitydate on the success forum and you responded overnight, and I followed you to here. You are God-sent and may all the good that you are doing here on your site come back to you a million times – that is my blessing to you!
I clicked on your link to get the Java book you suggested. I hope you are being paid by Amazon for it.
I can’t wait for your next post – looking forward to it! Please keep doing what you are doing – you’re amazing!!!
Hope you are doing well!! congratulations for this amazing and very helpful website.. i am new to this platform, i found your website, and i started studying but unfortunately after Chapter 3-3rd point onwards the hyperlink just disabled and i am not able to view further chapters, unable to proceed with the course..
Could you please check the pages and do the needful..
Thanks a lot for your reply… i am new to this platform and i dont have coding background.. and would like to learn Apex, the way u explained Triggers and SOQL was very nice.. can u please suggest me how to go about it??
Thanks once again for your reply… and thank you so much for posting the 3rd chapter.. i was waiting to learn from your website.. also as you suggested will go through that link to learn Java Concepts.. Thanks once again.. keep up the good work..
Hi David Liu,
i am anand myself, i greatly appreciate your work here. your website is awesome for salesforce.
i would like to know some details, please guide me.
1. i am having JAVA/j2EE background, now i am interested in Salesforce, so is the programming in salesforce same like java..?
2. how long will it take to learn salesforce from scratch..? is apex and visual force are tough to code and learn..?
i am thankful for your valuable response. cheers David.
Apex and Visualforce will be a piece of cake for you to learn! You’ll be pleasantly surprised how easy they are to use compared to a Java EE background =)
The hardest part (if you haven’t already learned this) is to get used to the non-code aspects of Salesforce. For example, permissions, sharing rules, when to use record types, object relationships, etc. You absolutely cannot be a good Salesforce developer unless you have a very strong grasp of what you can do without code first.
Hope this helps, and I’m glad you enjoy my site!
David
Hi David. I want to thank you for sharing this info which is very easy to pick up for a beginner like me. I have just started my career on this platform as a business analyst after my MBA and am planning to get certified as an admin in near future.I find your website very useful. I will be waiting for more articles like these. Thank You.
Hi, I’m a beginner in apex coding. will you help me create a test class for this. I do not have DML. my class do is just searching existing accounts.
Here’s my apex controller:
public with sharing class autoAccountSearchController {
public String strDebug1 {get;set;}
public List accounts {get;set;}
public autoAccountSearchController()
{
accounts = new List();
Account a = [select Id, Name, OwnerId, Site from Account limit 1];
}
public PageReference populateAccounts()
{
accounts = [select Id, Name, OwnerId, Site from Account where Name like :(strDebug1 + ‘%’)];
return null;
}
Create a trigger to double the Unit Price on all Line Items when Merchandise Quantity is changed to 20? can you hep anyone for this question
I wish you’d make a post about slightly more advanced stuff, like interfaces, virtual, abstract, etc. These gives me a headache lol
Hello,
Do you have anything that will help me to parse a csv file with apex?
thank you in advance
from static resourse
Hello
do you have anything that will help me to parse a csv file with apex?
thank you in advance
how can get filter list of custom object in trigger.new.
If i want to get mycustomer records of mycustomer__c object that is created today and do before update operation only on that customers using trigger.
please guide
Hi All,
I am new to salesforce need to learn salesforce coding, Kindly guide me.
Regards,
Mamatha
well first start by writing the code
can you help me regarding this scenario.
—> Create a schedule class that runs every hour to check hoe many accounts, contact, opportunity, cases were generated and deleted in last one hour. Collect all this data and dump in one custom object. Create a report to show acc, contact, oppty and cases count with respect to time. Create a dashboard that could overview in one look.
HI David, just wanted to check if this course is relevant even now. Also I am not able to see the link from Chapter 8. Can you please add the link from 8th part of 8th Chapter Object Oriented Programming. Thanks
Yup! Apex is still the same. Chapter 8 and beyond are unwritten unfortunately!
Hi David, hope you don’t mind me asking why has Chapter 8 has been unwritten? Is there any other sites I can get more learning in replacements for this chapter?
Sorry Rio I basically moved on to other things instead! Googling it from here is best!
When contact record is inserted/Updated create account record same should be populate in contact and also create opportunity
record and tag opportunity to contact and account.
If name in the contact record updated, update same name in opp and account as well
Your blog is very interesting. Your level of thinking is good and the clarity of writing is excellent. I enjoyed so much to read this post. I am also a blogger, you can follow my blog here how much to make an app
Thanks for your post. We are professionally managed job vacancies information related platform where we are trying to connect employer with job seeker. So that employer can hire best candidate and at the same time candidate also get best job opportunity. Both of them can excel and achieve their mission and vision
https://magic-job.com
How can i add two same contact with different accountid to three different account in apex.
Thanks it’s very helpful for me
Pranay:
objects-
1. Folder(folder name,StartDate,EndDate,EsimatimatedDuration)
2. Project(Project Name ,Folder Name)
3. Board(Board Name,Project Name)
4. Card( Card Name, Board,Activity,MilleStone)
Relationships…..
1. lookup —
i- Folder -> Project
ii- Board -> Card.
2. Master —
i. Project -> Board.
Need to create 5 folder records…..
each folder contain 5 project… each project contain 5 board and each board contain 5 card record.
Hi your content is very great, thanks!
Hi David
Chapter 8 to 13 are disabled. How can I access them?
Thanks
Chapter 9 and rest of the chapters have their link diabled. Where can I find those topics?
Hi David,
I read your experience of how to become a Salesforce developer and I feel am in the right place.
I want to become a professional Salesforce Developer. What are my steps to follow to become a Pro Salesforce developer?
Check this post out!
https://www.sfdc99.com/2020/03/01/step-by-step-guide-to-becoming-a-salesforce-developer-in-2020/
David, Any chance you will have the content ready for the Chapter 12 for Lightning posted soon?
Hi David,
I am finally going through Apex Academy through PluralSight. I passed the first course but with challenges :-) Best way to learn though, right?
Now I am going through SOQL but getting an error when I run the first script to create Accounts and Contacts – I will try to debug but I thought I’d let you know anyway:
System.DmlException: Insert failed. First exception on row 222; first error: DUPLICATES_DETECTED, Use one of these records?: []
Thanks again for all you do and I hope you and your family are safe and healthy.
CandyW
Try turning off duplicate rules in your org!
Lead Conversion
To convert lead to Account, Contact Check the condition whether existing Account, Contact with the same values. If yes show show error
Message: Already the following lead is converted. Using validation rule
If not then convert the lead.
Pingback: Apex Learning Path | Eedanna Java/J2EE/Hadoop Tech Adda
Hi David,
I am going to start salesforce admin like sale process ,services process and marketing process so can you help me,
i would like to know some details, please guide me related admin.
Hi! Are you planning to end up chapters 8 to 13??
really interesting!!!
Hi
I’m new to Salesforce and Apex. I don’t have a Java background instead I have NodeJS (functional programming) background.
Can you suggest how I can learn Apex from scratch without a backgroud of object oriented programming?
hi there.. i used to have a post of yours saved where it gave you links to the SF Admin course flash cards and also 4 or 5 exams and which to take in order as some of the study materials were similar. But its missing now
do you still have it please?
thanks
It’s still there! Check out the certifications section in the tutorials menu!
Hi,
I’m a beginner in Salesforce apex.
Please help me to complete below requirement:
For Prospect accounts, assign CALL task to its contacts with Subject Call “ACCOUNTNAME: account phone number ” if contact have any opportunity in it.
David sir, please make new videos on pluralsight related with integrations or more advanced apex. Please sir. You are our role model! We all want to learn more from you. :)
Hey David,
The “HelloWorld” trigger…
Try this…
– create a brand new dev org
– write the HelloWorld trigger
– In LEX, go to the Leads tab, and navigate to all Leads.
– Click on a Lead to view it. (DO NOT EDIT IT).
Do you see what I see?
Which HelloWorld trigger? O_o
Sorry… the one in Apex Academy – The Absolute Beginner’s Guide
If you have a brand new dev org (I mean BRAND NEW), and you stay in LEX, and you follow my instructions above… the trigger fires on the Leads WITHOUT editing the record.
I have also noticed the same. The trigger runs without needing to edit any record as there are some backend process (duplicate check ?) getting triggered
I also have the same issue… puzzled… hope David will help us…
Thank you for ur post’s..!!.its very helpful.
can you please help me with this question..,
I have two objects one is a standard object i.e Account and the other one is a custom object and their have a look up relations .I have created 3 text fields as A,B,C in custom object.Now when I concatenate b/w A and B , the result should get displayed in C.when u type the value manually in field C ,it should throw the error.So which type of trigger is used and how wil u write the code?
thanks for the information
Hi David. Thank’s for sharing this information. This sales force tutorial are very easy to understand for a beginner like me. congratulations for this amazing and very helpful website. It really really helpful for me.
Hey David
I have defined two variables (currency fields actually ) as follows:
Set targetprice = new Set();
Set floorprice = new Set();
Then I try to update them ( the field CPK_Target_Price_c is type currency (16,2)
List prodmaster = [select ID, CPK_Target_Price__c,CPK_Floor_Price__c from Product2 where Id IN: product];
for (Product2 prodrecord :prodmaster){
prodrecord.CPK_Target_Price__c = decimal.valueOf(targetprice);
prodrecord.CPK_Floor_Price__c = decimal.valueof(floorprice);
I get the following error on compilation
Method does not exist or incorrect signature: void valueOf(Set) from the type Decimal
Hi,
I am preparing for google coding interview. Could you please help me with what kind of apex algorithms will be asked. If you can give some sample coding questions asked for a telephonic interview that would be great.
Thanks,
Suchitra
Hi David
I want to thank you for helping new apex code like me. I like the away you teach on pluralsight , you style of article writing . it fun to watch and easy to understand and very easy to pick up, less jargon , alway to the point. I was one of the audience member to see you get gold medal of honor (golden hoddy in salesforce) last year . I personally like to thank you for your help to make me a SaleForce developer in less then 2 years . Please keep continue your nice article and video tutorial (specially salesforce lightning) .
Please keep writing!!!
looking forward to reading more.
Thank you
RAT
=)
I’ve just started out on the apex academy and created the first trigger below in a brand new lightning org. The trigger fires on new lead record and existing record. When I open an existing lead record without updating it, the name field automatically changes to hello world. On creation of a new record too, the name changes to hello world. Any guidance will be appreciated.
trigger HelloWorld on Lead (before update) {
for (Lead l : Trigger.new) {
l.FirstName = ‘Hello’;
l.LastName = ‘World’;
}
}
Hi David,
Hope you doing good. I am learning Salesforce Development and I am doing Apex Academy Courses from pluralsight. As we know Mavensmate is not available. Please could you help which is best tool available today to write code.
Thanks for your help!!
Suresh Thakkar
Hi Suresh,
You can use Developer Console.
Thanks,
Shravan
Hi Suresh,
You can use Developer Console.
Login to your org >> Click on your name in right upper side of the page >> Click on Developer Console. In the file tab, when clicked ‘New’, you may want to chose whether you want to create a Class, Trigger, Visualforce Page, etc.
Thanks!
Regards,
Ankit Yadav
Hello David,
Can you post the trail mix track for admin course? I know you did posted on LinkedIn but cannot find it. Thank you
Hi David,
Loved your course. The chapters nine to 13 are disabled?How can I access them? Any special spell to be said to unlock them :P ?
Thanks,
Suvendu
Dear All,
I am getting Product_Purchase_Date__c variable not found error. I am using my own developer org for the learning purposes. Is there any way to import the demo code used in the Apex Academy into my org.
Please advise
Thanks in Advance
Viddya
Is it possible to give 20 trigger assignments for practice?
Hello I am learning salesforce developer I have 2 assignments of salesforce developer one is generate 4 generate number and display 3 maximum number and second is circular right shift array by n position please help me I don’t understand how I could do this
Hi David,
Any plan to write chapters 9 – 13 soon?
Please say yes :)))
Thanks!
Hhmmmmmmmm prob not anytime soon lol
First of all! Thank you very much making complex things into piece, almost kind piece of cake.
I am so keen see your update for integration and lighting, I hope you are working on the same.
Please at least come up with next apex academy videos on pluralsight. lol
Hello David,
I’m trying to populate the email address using apex on outlook can you tell me how to update the subject and content of the saved template on the same and avoid hitting the limit of sendemail in salesforce. By using any code or creating a class that does allow us to send emails from the third party client and not the original configuration of Salesforce.
How to append back-ground color to lightning:datatable column headers?Thanks in advance
Hi David, I started learning with Apex Academy at Pluralsight and am hooked to it. It’s great!
However, in the Secret Information in Case Decription Trigger,( a part of the course Apex Academy: Fundamental Salesforce Coding Techniques ) whenever am trying to create a new Case, am getting the following,
Execution of BeforeInsert caused by: System.NullPointerException: Attempt to de-reference a null object: Trigger.WarrantySummary: line 8, column 1
My code is an exact copy of yours.
Thanks in Advance.
Make sure you’re working in a new org since other configurations could affect your code! Double check your code too!
Hi David Liu,
I need Chapter 11 – Integrations to learn.
Hi Anuradha
I hope you have figured this out,
But if not :
I had the same issue, it is because of the Warranty Summary trigger you wrote you have told it to run off of the new fields you added
Product_Purchase_Date__c
Product_Total_Warranty_Days__c
So on this new trigger it is causing the other trigger to run but the values are not being inputted e.g ‘null’
I fixed this by adding :
childCase.Product_Purchase_Date__c = Date.Today ();
childCase.Product_Total_Warranty_Days__c = 10;
Hopefully this helps
David, I’d like to jump in and start learning but am hesitant on where to start. Should I begin with the beginner tutorials, or proceed with Apex Academy?
Beginner tutorials are free so start there. If you’re finding your learning too slow then jump into the Apex Academy!
Hi David,
I am learning this apex tutorial and its really helpful.I was wondering if you can post from module 8 of chapter 8 to rest of the chapters that would be really great.
Thanks,
Ram.
Hi David,
Is Mavensmate not available anymore? I am learning Apex using your training course and wanted to try along, but could not find mavensmate to install. Looks like it is not supported anymore. Which other tool do you recommend me to try? I am completely new to coding so want to find something not too complex. Could you please suggest?
Thanks,
RC
Dev console!
Thank you David for the quick reply, I will give it a try.
Just want to let you know that I really appreciate how you are helping beginners like me to get started with coding. I am enjoying your course and hopefully will learn to code soon!
Best regards,
RC
I have the same problem… Joe, who seems to be the author of Mavensmate recommends to use Visual Studio Code by Microsoft
Hello David. Many thanks for effort you put in helping other to learn Apex!
In the Absolute Beginner’s Guide to Coding in SFDC video, you (subliminally) strongly advise to use the MavensMate editor to write code. This tool is unfortunately no longer managed by its creator.
I’d like to know which tool you are now using to write code? Several people are pointing to the SFDC extension for Visual Sutdio. https://marketplace.visualstudio.com/items?itemName=salesforce.salesforcedx-vscode#overview.
What is your opinion?
Regards from Switzerland
Xavier
Dev console for now. =). I use the Force.com IDE at work!
// Map<Id,Map<Id,List>> AccToContact = new Map<Id,Map<Id,List>>();
Please tell me the what is the problem
here it’s code
Map<Id,Map<Id,List>> accToParentContact = new Map<Id,Map<Id,List>>();
Map<Id,List> accToContact = new Map<Id,List>();
for(Contact con : [SELECT ID,Name,AccountId,Account.ParentID from Contact]){
if(con.Account.ParentID != null){
if(accToContact.get(con.AccountId) != null){
List contList = accToContact.get(con.AccountId);
contList.add(con);
accToContact.put(con.AccountId,contList);
accToParentContact.put(con.Account.ParentID,accToContact);
}else{
accToContact.put(con.AccountId,new List{con});
accToParentContact.put(con.Account.ParentID ,accToContact);
system.debug(‘==accToParentContact=’+accToParentContact);
}
}
}
Hi David. Thank’s for sharing this information. This salesforce tutorial are very easy to understand for a beginner like me. congratulations for this amazing and very helpful website. It really really helpful for me.
Thank you!
Hi David,
How to update 2 lacs records usng batch class which is getting data from third party application using REST API?
As I know their is 10000 records limit in in one API call and able to update upto 10000 records but unable to get idea for hitting multiple calls so that it can fetch data and update in our sfdc database. Can you please help me out in this case? If you want code then I can aslo share with you. Thanks in advance
Bulk API or multiple batches!
My Batch class is as below. What should I change so that it can update bulk records?
global class AccountDataSyncBatch implements Database.Batchable, Database.AllowsCallouts, Schedulable, Database.stateful{
global String lastAccountId;
global String lastContactId;
global String lastOpportunityId;
global boolean isStart;
global AccountDataSyncBatch(){
/* lastAccountId = accId;
lastContactId = conId;
lastOpportunityId = oppId;
isStart = tempStart; */
}
global Database.QueryLocator start(Database.BatchableContext BC){
//return Database.getQueryLocator(‘SELECT Id FROM User LIMIT 1’);
string query = ‘SELECT Id, name, Account_Lead_Score__c,Relative_Performance__c, (select id, name,Contact_Lead_Score__c from contacts), (select id, name, Opportunity_Lead_Score__c from opportunities) from account limit 10000’;
return Database.getQueryLocator(query);
}
global void execute(Database.BatchableContext BC, List scope){
fetchData();
}
global void fetchData(){
navikAuthDomain.response mapResp = navikAuthentication.getMapId(UserInfo.getUserEmail(), Label.SalesAI_Auth_Password);
Http http = new Http();
HttpRequest request = new HttpRequest();
request.setHeader(‘sessionToken’, mapResp.data.sessionToken);
//request.setHeader(‘sessionToken’, ‘UNUEXHA0//SLWpBR9J3v6gEN5hHsbQd0C79nFkpelRojiBfhF6Yth2dZi6oawXSRYDE6AFRGsN0gpV3N0XMrqAkynQ5ZWSmcGT3QAomh3f0=’);
if(isStart = true){
request.setEndpoint(Label.SalesAI_AccountContactOpportunity_Dump_API);
}
request.setMethod(‘GET’);
HttpResponse response = http.send(request);
if (response.getStatusCode() == 200) {
DataSyncBatchHelper.ParentData parentData = (DataSyncBatchHelper.ParentData)JSON.deserialize(response.getBody(), DataSyncBatchHelper.ParentData.class);
system.debug(parentData);
if(parentData != null && parentData.data != null){
List accList = new List();
List conList = new List();
List oppList = new List();
//****************Accounts***********
if(parentData.data.accounts != null && parentData.data.accounts.size() > 0){
for(DataSyncBatchHelper.Accounts account : parentData.data.accounts){
if(account.accountNumber != null && account.accountNumber.startsWith(‘001’)){
accList.add(new Account(Id = account.accountNumber,
Account_Lead_Score__c = account.accountleadScore,
Relative_Performance__c = account.relative_Performance));
system.debug(accList);
}
}
if(accList.size() > 0){
Database.update(accList, false);
}
//****************Contacts************
if(parentData.data.contacts != null && parentData.data.contacts.size() > 0){
for(DataSyncBatchHelper.Contacts contact : parentData.data.contacts){
if(contact.contactId != null && contact.contactId.startsWith(‘003’)){
conList.add(new Contact(Id = contact.contactId,
Contact_Lead_Score__c = Decimal.valueOf(contact.contactLeadScore)));
system.debug(conList);
}
}
if(conList.size() > 0){
Database.update(conList, false);
}
//*****************Opportunity***************
if(parentData.data.opportunities != null && parentData.data.opportunities.size() > 0){
for(DataSyncBatchHelper.Opportunities opportunity : parentData.data.opportunities){
if(opportunity.opportunityId != null && opportunity.opportunityId.startsWith(‘006’)){
oppList.add(new Opportunity(Id = opportunity.opportunityId,
Opportunity_Lead_Score__c = Decimal.valueOf(opportunity.Opportunity_Score)));
system.debug(oppList);
}
}
if(oppList.size() > 0){
Database.update(oppList, false);
}
}}}}}}
global void finish(Database.BatchableContext BC){
}
global void execute(SchedulableContext sc){
database.executebatch(new AccountDataSyncBatch());
}
}
Dude that’s a lot of code to debug LOL!
Is their any paid forum where I’ll get immediate reply?
Hey David. The links in chapter 9 seem to not be working. How can I get access to chapter 9? I need help with recursions.
thanks
They haven’t been written yet unfortunately!
Hey David:
I am trying to complete a Trailhead challenge
To pass this challenge, create an Apex class that inserts a new account named after an incoming parameter. If the account is successfully inserted, the method should return the account record. If a DML exception occurs, the method should return null.
The Apex class must be called ‘AccountHandler’ and be in the public scope.
The Apex class must have a public static method called ‘insertNewAccount’.
The ‘insertNewAccount’ method must accept an incoming string as a parameter, name the account after the parameter, insert it into the system and then return the account record.
The ‘insertNewAccount’ method must also accept an empty string, catch the failed DML and return null.
After reviewing the salesforce help forums, My code reads as follows :
public class AccountHandler {
public static Account insertNewAccount (String accName){
Account asd = new Account(Name=accName);
try{
insert asd;}
catch(Exception e){
return null;
}
{
return asd;
}
}
}
While submitting the challenge, I get the following error;
Challenge Not yet complete… here’s what’s wrong:
There was an unexpected error in your org which is preventing this assessment check from completing: System.NullPointerException: Attempt to de-reference a null object.
Please HELP !!!!
Too much code to debug =)
@Sid, Try below code –
public class AccountHandler {
public static Account insertNewAccount(String name){
try{
Account accnt = new Account(Name = name);
insert accnt;
return accnt;
}catch(DmlException e){
System.debug(‘Insert DML exception occured: ‘+ e.getMessage());
return null;
}
}
}
try to move “return asd” inside your try block.
Hi David
I am trying to write a trigger to post to chatter when an attachment is added. Here is my code:
trigger NotifyOwner on Attachment (after insert)
{
for (Attachment a: Trigger.new)
{
User u = [SELECT UserType, Name FROM User WHERE Id=:a.CreatedById];
FeedItem post = new FeedItem();
post.ParentID = u.id;
post.Body = ‘Hello ‘+u.name+’ – A file or note was attached to a record you own’;
insert post;
}
}
I have written a test, and have 100% code coverage but don’t seem to be getting an chatter posts.
Any suggestions?
Barry
Interesting! You might be missing some code on the FeedItem? Not sure actually never use that object! Refreshing doesn’t work?
Ive looked into it, and our org is using Files Content so it explains why attachments aren’t working. However from my research, the contentDocument objects don’t have a relationship to the parentID of the object. It must be there somewhere though or how could they tell which files are linked to which objects??
I think for this you’ll need to query ContentDocumentLink object and get the LinkedEntityId field that gets you the ID of the Record your file is associated to.
Hi David,
My name is Venugopal, I’m a beginner in Sales Force and apex coding.
Request you to kindly suggest to how to start and go head in this.
Regards,
venu
Doesn’t this page tell you exactly where to start and how to learn? =)
I get this question a lot!
Maybe you pin this one to the top. You sir have the patience of a saint.
LOL
Hi David,
Me and my CTO have been working on an issue and not getting any resolution. I have created a trigger on after update of Account wherein if there is a change in Master Contract field on the account it should be passed to all the Open opportunities. The trigger is working fine by itself. But when we try to Book an Opportunity it is throwing a flow error. It does not throw a flow error if i disable the trigger. Here is a snapshot of the log. Not sure if my trigger is causing the flow error or not or we need to update the flow. Your help would be appreciated. Thanks.
12:25:46.905 (15172851002)|CODE_UNIT_FINISHED|Workflow:Opportunity
12:25:46.798 (15178844006)|FLOW_VALUE_ASSIGNMENT|4544777de95ef40176a3662bf72a15c17ddea4c-6b43|myRule_10_A1|true
12:25:46.798 (15178888896)|FLOW_BULK_ELEMENT_END|FlowRecordUpdate|myRule_10_A1|2|376
12:25:46.798 (15178913194)|FLOW_ELEMENT_BEGIN|4544777de95ef40176a3662bf72a15c17ddea4c-6b43|FlowRecordUpdate|myRule_10_A2
12:25:46.798 (15178918762)|FLOW_ELEMENT_DEFERRED|FlowRecordUpdate|myRule_10_A2
12:25:46.798 (15178925163)|FLOW_ELEMENT_END|4544777de95ef40176a3662bf72a15c17ddea4c-6b43|FlowRecordUpdate|myRule_10_A2
12:25:46.798 (15178935380)|FLOW_BULK_ELEMENT_BEGIN|FlowRecordUpdate|myRule_10_A2
12:25:46.798 (15193198030)|EXCEPTION_THROWN|[EXTERNAL]|System.LimitException: Too many SOQL queries: 101
12:25:46.798 (15193562042)|FLOW_VALUE_ASSIGNMENT|4544777de95ef40176a3662bf72a15c17ddea4c-6b43|myRule_10_A2|false
12:25:46.798 (15193609220)|FLOW_ELEMENT_ERROR|Too many SOQL queries: 101|FlowRecordUpdate|myRule_10_A2
12:25:46.798 (15193791920)|FLOW_BULK_ELEMENT_END|FlowRecordUpdate|myRule_10_A2|0|0
12:25:46.798 (15228076994)|FLOW_START_INTERVIEWS_END|1
12:25:46.794 (15228154057)|WF_FLOW_ACTION_ERROR|09L0j0000000All|300150000008pnP|Error executing flow: Account_Updates, FlowDefId: 300150000008pnP, FlowVersionId: 3010j00000055KL
12:25:46.794 (15228172139)|WF_FLOW_ACTION_ERROR_DETAIL|An unhandled fault has occurred in this flowAn unhandled fault has occurred while processing the flow. Please contact your system administrator for more information.
12:25:46.794 (15228305416)|WF_FLOW_ACTION_END|09L0j0000000All
12:25:46.794 (15228326557)|CODE_UNIT_FINISHED|Workflow:Account
12:25:47.232 (15232395159)|FLOW_VALUE_ASSIGNMENT|4540777de95ef40176a3662bf72a15c17ddea4c-6b47|myRule_8_A2|false
12:25:47.232 (15232457836)|FLOW_ELEMENT_ERROR|The flow tried to update these records: null. This error occurred: CANNOT_EXECUTE_FLOW_TRIGGER: The record couldn’t be saved because it failed to trigger a flow. A flow trigger failed to execute the flow with version ID 3010j00000055KL. Flow error messages: An unhandled fault has occurred in this flowAn unhandled fault has occurred while processing the flow. Please contact your system administrator for more information. Contact your administrator for help.. For details, see API Exceptions.|FlowRecordUpdate|myRule_8_A2
12:25:47.232 (15232562170)|FLOW_BULK_ELEMENT_END|FlowRecordUpdate|myRule_8_A2|0|0
12:25:47.232 (15251343939)|FLOW_START_INTERVIEWS_END|1
12:25:47.251 (15251399464)|WF_FLOW_ACTION_ERROR|09L0j0000000B0M|30015000000PQI6|Error executing flow: Contract_Updates, FlowDefId: 30015000000PQI6, FlowVersionId: 3010j0000004udl
12:25:47.251 (15251417739)|WF_FLOW_ACTION_ERROR_DETAIL|An unhandled fault has occurred in this flowAn unhandled fault has occurred while processing the flow. Please contact your system administrator for more information.
12:25:47.251 (15251503745)|WF_FLOW_ACTION_END|09L0j0000000B0M
12:25:47.251 (15251520352)|CODE_UNIT_FINISHED|Workflow:Contract
12:25:47.273 (15273579228)|FLOW_VALUE_ASSIGNMENT|3897777de95ef40176a3662bf72a15c17ddea4c-6df4|Activate_Master_Contract|false
12:25:47.273 (15273646484)|FLOW_ELEMENT_ERROR|The flow tried to update these records: null. This error occurred: CANNOT_EXECUTE_FLOW_TRIGGER: The record couldn’t be saved because it failed to trigger a flow. A flow trigger failed to execute the flow with version ID 3010j0000004udl. Flow error messages: An unhandled fault has occurred in this flowAn unhandled fault has occurred while processing the flow. Please contact your system administrator for more information. Contact your administrator for help.. For details, see API Exceptions.|FlowRecordUpdate|Activate_Master_Contract
12:25:47.273 (15273717532)|FLOW_ELEMENT_END|3897777de95ef40176a3662bf72a15c17ddea4c-6df4|FlowRecordUpdate|Activate_Master_Contract
12:25:47.273 (15297623601)|FLOW_ELEMENT_ERROR|The flow tried to update these records: null. This error occurred: CANNOT_EXECUTE_FLOW_TRIGGER: The record couldn’t be saved because it failed to trigger a flow. A flow trigger failed to execute the flow with version ID 3010j0000004udl. Flow error messages: An unhandled fault has occurred in this flowAn unhandled fault has occurred while processing the flow. Please contact your system administrator for more information. Contact your administrator for help.. For details, see API Exceptions.||
12:25:47.273 (15297646743)|FLOW_START_INTERVIEW_END|3897777de95ef40176a3662bf72a15c17ddea4c-6df4|OpportunityBookingWizard
12:25:47.314 (15314901632)|VF_SERIALIZE_VIEWSTATE_BEGIN|06615000003GWkr
12:25:47.314 (15318139590)|VF_SERIALIZE_VIEWSTATE_END
12:25:47.320 (15320607889)|CUMULATIVE_LIMIT_USAGE
12:25:47.320 (15320607889)|LIMIT_USAGE_FOR_NS|(default)|
That’s a lot to look at, try the official developer forums!
Hi Sri, Hope you have got the solution by this time. However if not then check the process builder if any conflicting with opportunity trigger.
Hi David,
I have a doubt in Salesforce Email tracking. Please give me some solution..
We want to send mass emails to multiple customers. This part we have done successfully to go to Contacts tab => Tools => Mass Email Contacts.
After that we have to find the customers who have opened or clicked that email and send another email to only those customers who have opened or clicked.
Check this out!
https://help.salesforce.com/articleView?id=000006731&type=1
Hi David,
I have a doubt. Can you please resolve this issue?
We want to send mass emails to multiple customers. This part we have done successfully to go to Contacts tab => Tools => Mass Email Contacts.
After that we have to find the customers who have opened or clicked that email and send another email to only those customers who have opened or clicked.
Thanks
Hey David!
Hope you’re doing great!
I’ve some doubt with trigger and SOQL.
So the problem is I’m trying to fetch related Account Name from Contact , So I’ve written SOQL as
“SELECT Id, Account.Name FROM Contact” — Which is running fine in Workbench BUT while putting into my Trigger . It’s fetching on AccountId and ID value.
Following is my Trigger.. (I’m just printing the values to know whether values are coming out as required or not)
Trigger ContactTrigger on Contact( before update){
ListmyCon = new List();
myCon = [SELECT Id, Account.Name FROM Contact];
for(Contact con : Trigger.new){
System.debug(‘—————–‘+myCon+’————-‘);
System.debug(‘—————–‘+con.lastName+’————-‘);
System.debug(‘—————–‘+con.Account.Name+’————-‘);
}
}
Could you just help me out..
Thanks!!
It may be because you’re using a “before” trigger, try it out!
Hello David,
Are you still using Mavensmate ?, I’m also using it because you said its the best out there. After its new version update, are yo having issue with it ? Like During unit test it doesn’t show Class coverage or Trigger coverage or any other test result. Am i missing here something ?
Hey Alok! I use dev console for smaller things and MavensMate for bigger ones. Haven’t experienced your issue but you can always do the test portion from Salesforce.com!
Hello David,
I am new to SalesForce and trying to learn from your videos in PluralSight. I have experienced with MavensMate download. It’s look like the site is no longer available to download.
Is another way to download it? I am using Windows.
Thank you,
KN
I’d recommend using the dev console in the interim!
Hi David
Another of your fans here .. really love your style.
I am looking forward to the ‘Integrations’ chapter of your sfdc99 guide or apex academy.
There is lot of stuff online but your method of communicating is just what I need.
I need to work on some integrations as a part of my job , do you have an estimate on when that chapter will be up ?
Any other links to courses on it which have a similar style (obviously not as good as you :-))
Thanks again
Anubhav
There is an integrations course on Pluralsight specific to Salesforce, check it out!
Or, check out the Architect Academy ebook (free) on this.
BTW thanks for the compliment!
Hi David,
I have started learning through Apex Academy and going through ‘Power of SOQL topic’.
I have a doubt in using workbench as I am on ‘free developer edition’ and therefore don’t have any sandbox/production User/Passwords.
I am unable to follow you on the course since you are using workbench for SOQL.
Please guide me on how to proceed.
You can use Workbench with a free developer edition, I do all the time! Make sure to choose “Production” when logging in
Hi David,
I am trying to deploy trigger and class through mavnesmate from one dev org to another.
When deployment is complete metadata results shows as success , but the deployment fails , i am not sure how to debug the issue , because i dont see deployment failure message on the deployment status page in dev org.
Could you please advise??
Well, try change sets =)
Thanks David.
I am going through ‘Apex Academy’ part 2 , i have created trigger ‘CheckSecretInformation’ and trying to create a case and getting the below error message , but when i deactivate the ‘WarrantySummary’ trigger i am able to create a case without any problem:
Error: Invalid Data.
Review all error messages below to correct your data.
Apex trigger CheckSecretInformation caused an unexpected exception, contact your administrator: CheckSecretInformation: execution of BeforeUpdate caused by: System.DmlException: Insert failed. First exception on row 0; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, WarrantySummary: execution of BeforeInsert caused by: System.NullPointerException: Attempt to de-reference a null object Trigger.WarrantySummary: line 4, column 1: []: Trigger.CheckSecretInformation: line 35, column 1
Please advise.
Check line 4 in your code =) Something there is null!!
David,
Below is the code for WarrantySummary trigger , line 4 is for ‘purchaseDate’ , which we input while creating a case:
trigger WarrantySummary on Case (before insert) {
for(Case myCase : Trigger.new){
String purchaseDate = myCase.Product_Purchase_Date__c.format();
String createdDate = DateTime.now().format();
Integer warrantyDays = myCase.Product_Total_Warranty_Days__c.intValue();
Decimal warrantyPercentage = (100 * (myCase.Product_Purchase_Date__c.daysBetween(Date.today())
/ myCase.Product_Total_Warranty_Days__c)).setScale(2);
Boolean hasExtendedWarranty = myCase.Product_Has_Extended_Warranty__c;
myCase.Warranty_Summary__c = ‘Product purchased on ‘ + purchaseDate + ‘ ‘
+ ‘and case created on ‘ + createdDate + ‘.\n’
+ ‘Warranty is for ‘ + warrantyDays + ‘ ‘
+ ‘days and is’ + warrantyPercentage + ‘% through its warranty period.\n’
+ ‘Extended warranty:’ + hasExtendedWarranty + ‘\n’
+ ‘Have a good day’;
}
}
Product_Purchase_Date__c is an empty field!
Hi CodeRider,
I am receiving the same error even though I am also manually entering a date for Purchase Date. What did you do to resolve this?
Thanks!
I know this is late, but I wanted to share what I discovered with anyone else that ran into this error while working through Apex Academy. David put together this great course, and I’m actually pretty excited to have this ‘additional homework’ ! It felt awesome to finally figure it out, and it drove home some of the concepts.
Ok, to the point:
The WarrantySummary trigger is expecting values for fields in the trigger for each case that is created. As both commenters mentioned above, they are adding a Product Purchase Date to the case THEY are adding, but what about the child cases that the new CheckSecretInformation trigger is creating?
So when David replied with “Product_Purchase_Date__c is an empty field!”, he was referring to the child case created.
Follow his instructions on wrapping an if (myCase.Subject != ‘Warning: Parent case may contrain secret info’) around the WarrantySummary trigger and BOOM.
^_^
Hi David,
Could you please give me a brief about multi-tenant architecture and how the data from different organizations is stored into Salesforce and how do they ensure the data security for different organizations.
Thanks in advance!
Sounds like a good interview question, LOL!
Read this: https://developer.salesforce.com/page/Multi_Tenant_Architecture
Thanks for getting back David, but I read that before, if possible could you please explain it in a easier language if possible.
Thank you!
im newbie to programming knows html css and making responsive.I want to learn more skills in javascript.Its good to become a salesforce developer to get proficiency in javascript .I couldnot grasp some differnces how salesforce works anyone please answer
Hi David ,
This place is great for a new beginner in Apex. Thanks for providing this .
Is there a way i can access chapters 9 to chapter 13
They haven’t been written yet =)
hi David,
I am a regular follower of your page….
I am waiting to access chapter 9 to chapter 13..
So, when can I expect your past regarding thr same
and ya by the way your post is very very awesome…. and very easy to understand…….
Good question… haven’t prioritized them yet!!
these tutorials are awesome.. Please could you provide the further chapters i.e. chaps 9-13..
Hi David,
Loved the tutorials, hope you keep writing more of these!
I’m new to Salesforce, but it’s guys like yourself that make me want to push myself to learn as much of it as efficiently as possible.
Cheers!
Thank you Nandini!
Hey David,
I just started Apex Academy and got stuck at MavensMate instructions. Your video isn’t matching my experience.
From here (http://mavensmate.com/) when I click on the download button, it takes me here:
https://github.com/joeferraro/MavensMate/tree/master/docs#quickstart … and does not look anything like what your tutial shows.
Any advice or links you know of that will get me around this impediment?
Working on updating the module, for now use the dev console – don’t let MavensMate stop you from coding!
David
I am trying to replicate user login history object as a custom object. The reasons are the User Login History is not available in the front end and the data is only stored for the last 6 months. Also, Login Date fields are unavailable in any formula fields. I have created the custom object and created all the API Fields. I am planning to implement a Schedule Class which runs every 30 mins and query the last 60 mins of login data. How does this sound ? Do you recommend any other solutions ?
Thanks
Harish
Sounds like a plan! Give it a shot and let us know how it goes!
Thanks David and will keep you posted. I am following your blog from few months which is very useful.
Does all the above Beginner tutorials are included in Apex Academy ? I would like to purchase Apex academy from plural sight and I can see only 3 courses available. Any ETA on the rest of the courses please ?
Regards
Harish
Also, What is the different between Monthly Subscription vs Monthly Plus Subscription in plural sight ?
Just get the normal one =) I believe they are merging the two for the same price!
Does all the above Beginner tutorials are included in Apex Academy ? I would like to purchase Apex academy from plural sight and I can see only 3 courses available. Any ETA on the rest of the courses please ?
Technically there is no finish line for the Apex Academy, so you could be waiting forever!
Honestly the best thing to do would be to make your decision based on only the current line-up. Many tutorials on this site are totally free so if you’re on a budget there’s no need to pay for anything. If your goal is to learn as quickly as possible, then you should consider the Academy =)
Good luck!
Hi David,
i am working as a software tester.I wanted to become a sales force developer.My target is November to get sales force developer.Can you please give some suggestions.
Thanks,
Venkatesh
Yes go for it 100%!! Check out the Apex Academy too – or, if you’re familiar with code, the tutorials here should be enough
Hi David, this is so cool.
I am working in a call center as IT support doing a bit of programming in C# .Net, SQL SSRS.
The main software we use has just integrate Salesforce in our calls and reports management.
This sounds like a huge opportunity to get to a step forward in my career.
I have read all the answers on this page which respond well to the questions I was having about how to develop in Salesforce.
I will get my hands dirty with coding right away.
If you have advices or recommendations to help me get my learning process smoother, don’t hesitate to alert me.
Again Thanks for bringing to particular light to us.
Carlos
I recommend going to as many Salesforce events as possible, you probably have some user groups nearby. Good luck!
thanks for your awsome viedos and grt salesforce explanations. really i get more knowledge to learn by number of times.i really appriciate. for that.. david.
Thank you Jaykant!
I am so excited!!! thanks for your hard work.
Hi, thank you so much for all you are doing. You are a great teacher. I am doing your courses in Pluralsight and I am loving it. I wonder, when will your 3rd course come out? Which day of August?
I really can’t wait
Thank you Guiem! It all depends on how quickly I make it =) It usually gets released about a week after I complete – and I’m halfway done now!
My guess is first half of August!
David
Hi David,
We are nearly at the end of the first half!! any clue as to when?
I have been waiting for this videos for too long, haha… I am having sleepless nights.
Thanks a lot and for all your effort.
Thanks Guiem! Sleep well, the course is done! Just going through final approvals.
It is without a doubt the best course of the series. Enjoy =)
David
Hi David,
I have a quick question. Do you suggest to use the “apex-lang” Utility code library for force.com provided by google. I checked the details and it has a huge and comprehensive list of utility classes. I think we might be using only 10% of the utility classes in any project. So wanted to know the best practices you suggest.
I would like to get some idea, what you do in your project when it comes to creating and reusing utility classes which can be used across multiple projects. Do you copy the classes in all project VS use “apex-lang” third party library or create a managed or unmanaged package of your own developed utility classes.
Thanks,
Bikram.
I’ve never used it so I can confidently say you don’t need it =)
If you find a good use case though by all means go for it!
Hi David,
After chapter 9, am not getting the link please let me know. Your materials are awesome and good for new learners, appreciate your time and help.
Hey David!!
I just can’t wait for the next class of Apex Academy. Thank you so much for helping millions of Salesforce aspirants. I have gone through first class of Apex Academy end number of time and each time I learn something new. So when can we expect your second class! I am getting impatient as I know this is going to be a blast. Can’t wait!!
Thank you so much
Nidhi
Thank you Nidhi!
The salesforce development experience is by far the worst I have ever encountered. This is truly awful. Any developer who likes to code with the half-baked apex, the laggy VisualForce, and the lamest javascript framework ever (Lightning), is NOT a real developer. Try out some real languages people and get a job you don’t hate. Look at this if you don’t believe me…
http://stackoverflow.com/research/developer-survey-2015#tech-super
73.2% of current salesforce developers want to quit. This is awful!
Thanks for sharing! I actually love my job, ahhh!!
Wow, did Marc Benioff take your lunch money when you were a kid?
It has more of a bias than you may know.
Here are two links on that very subject:
http://advancedapex.com/2015/04/08/stackoverflow-survey-sf/
http://meta.salesforce.stackexchange.com/questions/1946/is-salesforce-the-most-dreaded-tech-of-the-year-yes-no-why
As you may have also noticed, Salesforce StackExchange has quite a good SE community (better than the regular StackExchange in my experience).
Most of the people I often see complaining are usually poor programmers. Is Apex the best language in the world, no. Obviously there are much better, which has a lot to do with the maturity and money behind the language. But, it is a real language.
From my personal experience, there are two things that set it apart: Very simple to setup and that it enforces you to test everything.
I could go into it more, but it’s late ;) .
“Oh, there he goes off to his room to write that hit song ‘Alone in my principles.'”
Hello David,
When might we expect the next chapter to your plural sight course… very anxious to learn
Current course has about 3x as much content as originally planned, really going all out on this! Will launch around May!
It is now May! :)
LOL! Working hard on this!
Hello David,
When can we expect the next chapter to your plural sight course… so anxious for more
Current course has about 3x as much content as originally planned, really going all out on this! Will launch around May!
great post with detailing info, keep on writing more info about salesforce
Just finished Chapter 1 Quiz and creating Trigger and Class. Moving on to next section. Thanks. Very helpful and encouraging to listen in on the Webinar.
Hi David! Just passing by to thank you again for the free access to the Apex Academy.
Also, if this is not too much, may I request for you to do a video tutorial on how to install Mavensmate in Windows OS.
I’m having a nightmare with this, I believe I’ve followed the steps on your tutorial vid, but for some reason it isn’t working on my end, there might be different steps needed for Windows OS? I’m not sure. I did repeat it a couple of times, uninstalled and re-installed everything, I also did my part and searched for tutorials online on how to install Mavensmate on Windows, but still I’m not getting anywhere…
I had problem too with file read error due to the folder path settings under Windows 10. I changed the path to like this ‘C:\\path\\to\\your\\workspace’ and it worked.
Hi David,
I am a Salesforce admin but new in coding. I am starting to learn APEX and obviously, using your videos to learn. I have my own SFDC dev org and trying to test a sample trigger but having troubles with it. Would you be so kind if I ask on how to correct this? I kept on watching the slide but I still get one more error.
trigger SAMPLE on Account (after insert) {
for (Account acc : Trigger.new) {
Case SAMPLE = new case ();
Case.subject = ‘Sample for my first Trigger’;
Case.status = ‘working’;
Case.description = ‘testing’;
}
}
Error: Compile Error: Expression cannot be assigned at line -1 column -1
I tried to copy yours but same error. What should be the build of the code? If I understood it, first line should be like:
trigger on {
– am I right or just blabbering? Sorry.. I really wanted to learn apex badly.
Hey Bianca,
Congrats on attempting your first trigger!
Make sure you’re creating this trigger from the ACCOUNT page =)
David
Yeah. I am doing it on Accounts Triggers, which confuses me as it does not accept the code. What could be the other possible cause of the error?
Hi Bianca,
Please try using Sample instead of case after you have created instance for case.
Like:
Case SAMPLE = new case();
SAMPLE.subject = ‘Sample for my first Trigger’;
Great find Sunny!
Thanks David :)
because of you and my colleagues, I have a basic idea of triggers
waiting for your lessons on visualforce and their controllers.
Thanks David :)
because of you and my colleagues I now have a fair basic ideas of triggers.
Waiting for your lessons on controllers.
Hello David, I have 10 years of experience as a IT systems Administrator, in order for me to get started with Development side of the business does it require for me to get started with the Admin cert or can I start working on the Development side ? although I have very minimum knowledge of programming ? Thank you in advance..
Chapter 0 is required =)
When chapter 11 is coming?
Probably not anytime soon!
Hey David, When can we expect to see your videos on Pluralsight… anxious to watch.
Thanks Travis! 90% through the first course, just closing it out now!
Hi David, Thanks for this usefesul blog. Just a comment to add, It will be very useful if you include tasks which will require use of all (at least as much as you could) aspects of Apex triggers & visualforce controllers. This will help in gaining complete understanding.
Planning to have these in my video courses coming up!
Hi David. Thank You very much for your effort. You have written a very good material for a non-tech person like me to understand how to write APEX. I am eager looking fwd to content of chapter 9.
Thanks Simon!
Hi David.. i am yur big fan. When you will complete full content of chapter 8 and 9. I am eagerly waiting for this. Please do it asap if you get chance. Thanks in advance
Oh man probably not anytime soon because I’m doing videos now from the beginning!
Hey David, first of all lemme tell u….you are fantastic dude. Would you believe the Salesforce support recommends your website for new bees … This is incredible, keep the good work going !!!
Really??? Forward me the email I’d love to see it and hang it on my wall!!
Hi David,
I enjoyed learning Apex in sfdc99.com. Are they any plans of posting rest api post?(Integeration).
Thanks for all the posts. they are simply superb. Neat and Clean..
Thanks
Big plans coming up!
Hi David,
I am having one requirement, but didn’t find any solution for that till now.
Its little complicated and tricky, and quite difficult to explain, let me try to explain you, and hope you will tell me the appropriate solution for that.
I am using new Salesforce console view, to view my cases. In that when I open my record, that will become a Primary Tab, and Details & other related list will become its Sub Tabs.
So what my requirement is, that I want to connect two machines(desktop/laptop) on my desk, and on 1st machine, I want to view the details of Case(which is sub tab) and drag and drop related list data(other sub tabs) into 2nd window, so that it will be visible on my 2nd machine.
Please help me on this.
Thanks,
Manav
Sorry Manav I don’t know much about console!!
Oops !! Its Ok David.. Np :)
Hi Friends,
I am new to coding and I want to know basic difference between (Function & Method) are they both same.
For ex: database.add() is a function or method.
If they are both are different, then where do we use Function and methods in Salesforce.
When will you complete this lecture series.
=)
Has this project been abandoned?
99% of people who visit my site never get past Chapter 8 so I don’t focus as much as those! =)
Hi David, well I need to read the rest of your tutorials – could you please release them! I am really looking forward to continue studying using your website. Thank you, Sinan
Hi David,
I noticed you have some chapters and lessons without links. Do you plan to create these post in the future? No rush, I was just wondering.
Thanks!
They’re coming!!! Eventually =)
David, Thanks for coming back to support the entire community of budding developers. Salesforce should thank you for your contribution to increasing the developer community (by encouraging and hand holding them to be developers). We are excited and motivated again!! Let the lessons keep on coming!!!!! God bless your for the selfless service you are doing!!!!!
Thanks Suku!
Hi David, if you are not able to complete the series maybe you could ask someone from the community to help you out.
You can find info on all stuff by Googling it =)
Hi,
Hope you are doing well!
I have some problem, please help me.
I want to integrate salesforce app to Salesforce app. Is it is possible to integration Salesforce to salesforce.
For example:- 1 Salesforce app data to send another salesforce app data.
Thanks,
Rahul
Hi David
How can i insert Multiple endpoint URLs remote site srttings through Apex class ,can u send me sample code for that.please its need urgent.this is my mail id nagarajuu.c@gmail.com
No idea sorry!
Hi,
what is different between Salesforce Platform vs Heroku
which one is better Salesforce or Heroku…
Salesforce is a SaaS as well as PaaS while Heroku is just Paas. You have to create 100% custom application for Heroku and thats not the case for SFDC
Hi could you please give the piece of code regarding the Custom Login Page.
1. remember me check box(should save the username and password in the browser)
2.When username and password is empty error message should display without using
Hi,
Please solve my problem.
How to send email id and password send to personal Email id (like – Gmail or outlook ) and user Login In those email id and password use. and then log in page and use
This is a Code…..
Note: all fields are required.
Controller Code……..
public with sharing class CommunitiesSelfRegController {
public String firstName {get; set;}
public String lastName {get; set;}
public String company {get; set;}
public String email {get; set;}
public String password {get; set {password = value == null ? value : value.trim(); } }
public String confirmPassword {get; set { confirmPassword = value == null ? value : value.trim(); } }
public String communityNickname {get; set { communityNickname = value == null ? value : value.trim(); } }
public CommunitiesSelfRegController() {}
private boolean isValidPassword() {
return password == confirmPassword;
}
public PageReference registerUser() {
// it’s okay if password is null – we’ll send the user a random password in that case
if (!isValidPassword()) {
ApexPages.Message msg = new ApexPages.Message(ApexPages.Severity.ERROR, Label.site.passwords_dont_match);
ApexPages.addMessage(msg);
return null;
}
String profileId = null; // To be filled in by customer.
String roleEnum = null; // To be filled in by customer.
String accountId = ”; // To be filled in by customer.
String userName = email;
User u = new User();
u.Username = userName;
u.Email = email;
u.FirstName = firstName;
u.LastName = lastName;
u.CommunityNickname = communityNickname;
u.ProfileId = profileId;
u.CompanyName = company;
String userId = Site.createPortalUser(u, accountId, password);
if (userId != null) {
if (password != null && password.length() > 1) {
return Site.login(userName, password, null);
}
else {
PageReference page = System.Page.CommunitiesSelfRegConfirm;
page.setRedirect(true);
return page;
}
}
return null;
}
}
Too much code to debug, sorry! Try the official developer forums =)
Hi David,
Please help me,
How to create a Register Page and login page in visualForce and controller page and email and password send to personal Id like Gmail & Twitter ID for verification, Please tell how to create a code…… Please help
Try the official developer forums! =)
David,
Please send me the code official developer forums, I don’t how to write a code official Developer forum.
Please help…
Right here!
https://developer.salesforce.com/forums/#!/feedtype=RECENT&criteria=ALLQUESTIONS
Hi David,
Thank You So much for such a good website on salesforce. I am a Salesforce developer who was struggling to code, but your tutorial has given me confidence that I can surely do better.
Thank You so much.
hi David,
you are doing a great job, Thank you so much.
i have one question in my mind,I hope you will guide me
what is the difference between merge field and cross-object reference field ?
From what I understand, merge fields are used mainly for email templates. So it will automatically update the field with the object-field’s value (ex. Greeting this will be replaced by the actual customer’s name. Cross object fields are mainly used for creating workflows. Same function, works for related objects, must have master object.
‘Thanks David’
Thanks for your wonderful site providing immense guidance to people interested in Salesforce CRM.
Reading many of the comments, I appreciate your replying to most of you. Inspired, I also wrote my queries and unfortunately, I was among the few chosen by you not to be replied. May be you are busy or just skipped it by mistake or on intention. Assuming that you might have just skipped, I have hope you will do reply sometime on my last message. And today I am writing again this note to only say you thanks.
I have started learning Java and getting introduced to Salesforce with hopes of someday learning it to be proficient in this. Your site is one key resource in my kit of Salseforce CRM learning material and I am hopeful to achieve good lengths in my career and Salesforce knowledge using this. Ending the message in exactly same words of thanks.
‘Thanks David’
Hi David,
Thank you so much for sharing your knowledge, it is really appreciated.
I am done wiht chapters till 8 but after 9th chapter there is no link.
Please let me know if it is not available and in development.
Thanks,
Murali
Not available =)
Hi David,
After a decade of development experience using VB6, ASP3, VB.NET, C# – I am assigned to work with a SF team & hence am expected to learn and work using APEX.
Searching through the various available sources, fortunate to have traced this site – for do find it interesting as well as is building confidence in me on learning APEX. Yet, I do have few queries where I need your advice / opinion:
a.
SF/APEX is like beginning something new for me despite my decade long experience.
I am confident I can do this
Yet, I a, not sure on what are the future possibilities I can look for once I learn this (in terms of career).
b.
Until now, I have often been working as Developer or Project Lead, and my future plan is to work in Project Lead, Project Manager in some big brand organizations like google (where you can guide better about).
What will be my prospects to work with such big brands if I excel myself in learning SF.
c.
I really loved your site – and it has added to my confidence, inspiring to learn it well enough to be listed among experts and also attain certification.
At some stage I would wish to then invest time to give back like you and begin a site like yours (distant dream for now) – I hope you will not dislike me for this aim.
My query here is what kind of career path I can draw here for myself – from a beginner to excelling enough to write a site for this – to getting a job with google, etc. and to be a certified developer.
d.
I am confidently hopeful of an honest answer from you on this, hence asking.
Do you see SF to stay in high demand and reward high pay for next few years – asking you from your current experience and vision.
e.
I would wish to learn and excel in SF knowledge starting now – to be proficient enough to begin a site like yours for helping others, be able to switch to big brand companies for job and achieve certifications in SF with my attained knowledge.
My final query here is – will my previous knowledge and experience help me in learning APEX (and is it mandatory to learn Java for same).
+.
This is an additional query – just something out of curiosity. After SF what field you have chosen in your career path.
And will your having shifted focus there still keep you available for any guidance or queries we post to you here or on twitter.
Hope that you will do read my long post and will do reply, for it will be really helpful for me and my career confidence.
Thanks,
Sahil.
Hey great tutorial, thank you very much. :)
common.exception.ApiQueryException: sObject type ‘user__c’ is not supported. If you are attempting to use a custom object, be sure to append the ‘__c’ after the entity name
why i am getting this error
What is the context of your error ? The exception message seems to be pretty clear, the sObject called in your code is not supported by the type.
If you want a clear answer, you should ask a clearer question.
BR
@HttpGet
global Static String doget(){
RestRequest req = RestContext.request;
RestResponse rcs = RestContext.response;
String contID = req.requestURI.subString(req.requestURI.Lastindexof(‘/’)+1);
List cc = new list();
List ac = [select name,(select FirstName,LastName,Email from contacts) from account Limit 10];
//return ac;
sampleExample rs = new sampleExample(ac.firstname ,ac.lastname ,ac.Email );
Error: Compile Error: Initial term of field expression must be a concrete SObject: List at line 25 column 41
last line erreo came ples give any ideas………
Hello Ali,
You are getting an error because you are trying to call directly fields that are held in a list object. If you do want to instanciate a new object, you could use the list as parameter or transfer the list in another variable that you could use afterward.
Look at the anonymous code below to get the big picture :
List acc = [select name,(select FirstName,LastName,Email from contacts) from account Limit 10];
for (Account accs : acc) {
System.debug(‘The name of the related Account is : ‘ + accs.name );
for (contact c : accs.contacts){
System.debug(‘The childs are’ + c.FirstName + c.LastName);
}
}
@HttpGet
global Static String doget(){
RestRequest req = RestContext.request;
RestResponse rcs = RestContext.response;
String contID = req.requestURI.subString(req.requestURI.Lastindexof(‘/’)+1);
List cc = new list();
List ac = [select name,(select FirstName,LastName,Email from contacts) from account Limit 10];
//return ac;
sampleExample rs = new sampleExample(ac.firstname ,ac.lastname ,ac.Email );
how to write mapping resume skills and client requirement skill into sales force…
example : i have a Profile You have requirement for the position of java/.net ….
if source resume in portal….like monster/ Naukri .then find few profiles related in your requirements….
is the same process work on sales force or not..
if possible give me solution please?
Hi David,
What an amazing website. Iam new(just 1 month) to salesforce and have no knowledge of coding, But looking at your website makes me hopeful to become a good developer.
I have a requirement where in I have to convert the created date to Julian date(keeping the leap year in mind too) using http://www.fs.fed.us/fire/partners/fepp/DODprogram/juliandate.htm
I was wondering if we have any formula for Julian dates?
Thanks.,
nupur
Great course David, I really liked it. Looking forward to you completing the VisualForce lessons :)
Hi,
I am very new in salesforce and i want to learn coding.Give me some coding tips.
Thanks,
Kaavya
Here is the best tip EVER : https://www.sfdc99.com… JK.
You can follow the https://developer.salesforce.com/trailhead tutorials in order to get into the context and then follow http://limitexception.com/ & http://blog.jeffdouglas.com/ blogs.
I’m saying nothing new, David Sir said it even better than me…
You have the weapons, now you have to learn how to use them.
BR
Hi All,
I am new to salesforce need to learn salesforce coding, Kindly guide me.
Regards,
Mamatha
Absolutely fantastic work. I love this. Thanks for the effort spent in building this site. Keep rocking and I will follow you.
Why thank you =)
HELP me through this . Task is to implement a trigger on contact This trigger should check that
1.related account must not have more than 10 childs.
2.Update child count in account through trigger whenever a contact is created or update or deleted.
3.While creating a new record in contact it should not allow duplicate record which have email and mobilenumber.
I Have Just small dought consern of SalesForce, is it necessary to had awareness on C# or any other .Net Related technologies For becoming a SalesForce Developer.
None needed!
Hi David,
I am unable to understad test classes could you plz help me
What are you not understanding about them?
Make sure to look carefully at the test class examples over the site and try to see what they have in common, it’ll come to you!
HI David ,
Thanks for great site which very usefull to all sfdc floks and i have one questionwhen you are going to post chapter 9,10 and 11 ,
Thanks&Regards
Karthik.A.S
I want to do more Visualforce before going to those chapters!
Looking forward to Chapter 12 too!
Just joined the Austin Developer Group in their Challenge to be a Developer by the end of 2015 using your system. I’m on the Fast Track because I’m not currently working and am making much more progress than I anticipated because the material is not dry like so many others. Can’t wait for you to come visit!
Thank you Jennifer I am super excited too!!! =)
Best of luck on your journey!
Some BISP learning stuff:
S.No Document Link
1 SalesForce Certification Lab II http://www.scribd.com/doc/187549488/SalesForce-Certification-Lab-II
2 SalesForce Managing Data http://www.scribd.com/doc/187548253/SalesForce-Managing-Data
3 SalesForce Certification Preparation Lab#1 http://www.scribd.com/doc/187210179/SalesForce-Certification-Preparation-Lab-1
4 SalesForce Class 16 http://www.scribd.com/doc/185057421/SalesForce-Class-16
5 SalesForce Class 15 http://www.scribd.com/doc/185056547/SalesForce-Class-15
6 183207316-SalesForce-class-14.pdf http://www.scribd.com/doc/183207598/183207316-SalesForce-class-14-pdf
7 183203806-SalesForce-class-8.pdf http://www.scribd.com/doc/183204367/183203806-SalesForce-class-8-pdf
8 183202671-SalesForce-class-7.pdf http://www.scribd.com/doc/183203012/183202671-SalesForce-class-7-pdf
9 SalesForce Beginner’s Guide Lab #6 http://www.scribd.com/doc/183201332/SalesForce-Beginner-s-Guide-Lab-6
10 SalesForce Beginner’s Guide Lab#5 http://www.scribd.com/doc/183201330/SalesForce-Beginner-s-Guide-Lab-5
11 SalesForce-class-3.pdf http://www.scribd.com/doc/183191397/SalesForce-class-3-pdf
12 Getting Started with SalesForce Lab 4 http://www.scribd.com/doc/182967367/Getting-Started-with-SalesForce-Lab-4
13 Getting Started with SalesForce Lab 13 http://www.scribd.com/doc/182965827/Getting-Started-with-SalesForce-Lab-13
14 Getting Started with SalesForce Lab 12 http://www.scribd.com/doc/182965437/Getting-Started-with-SalesForce-Lab-12
15 SalesForce Lab Guide 11 http://www.scribd.com/doc/178996579/SalesForce-Lab-Guide-11
16 SalesForce-Lab Guide 10 http://www.scribd.com/doc/178996050/SalesForce-Lab-Guide-10
17 Getting Started With SalesForce Lab 9 http://www.scribd.com/doc/176864756/Getting-Started-With-SalesForce-Lab-9
18 Getting Started WIth SalesForce Part I http://www.scribd.com/doc/172413844/Getting-Started-WIth-SalesForce-Part-I
19 Getting Started WIth SalesForce Part II http://www.scribd.com/doc/172413843/Getting-Started-WIth-SalesForce-Part-II
20 Getting Started WIth SalesForce http://www.scribd.com/doc/170274876/Getting-Started-WIth-SalesForce
21 EMail and Workflow Administation http://www.scribd.com/doc/194512440/EMail-and-Workflow-Administation
22 Managing Users Doc http://www.scribd.com/doc/193792856/Managing-Users-Doc
23 Sales Analysis Sheet http://www.scribd.com/doc/25012120/Sales-Analysis-Sheet
24 Salesforce Integration With MS Office http://www.scribd.com/doc/194501887/Salesforce-Integration-With-MS-Office
Looks like some labs is missing
What a great website! I first started by stumbling upon your youtube video, then linkedIn, and now this site. You’re the man! Thanks for making such a great resource!
Thanks!
Hey David – Was wondering if you have ever posted anything about writing a class for Batch Apex? Either way, would you please point me towards your recommended direction? Thanks again for this site that you have created… If it wasn’t for this, I honestly don’t know where I would begin to understand any of this.
Haven’t gotten there yet but it’s planned in an upcoming chapter!
I learned from this doc:
http://developer.force.com/cookbook/recipe/using-batch-apex-to-reassign-account-owners
Hi Devid,
I am working as java devleoper since last 2 years. Is it gonna be easy for me to start salesforce programming?
Yes!
Hi David,
I don’t see hyper links from Chapter 8 – Object Oriented Thinking, Example: How to prevent triggers from running twice and the following chapters 9, 10, 11,12, 13 and Visualforce.
Can you please help!!
Regards,
Manju
I’ve planned those lessons out but haven’t written them yet =)
I still remember when I only had 2 chapters!
Hi David,
You are doing a brilliant job in helping people out with their salesforce skills. I was wondering if you had ever thought of conducting your own webinar coding sessions. I watched your Dreamforce session where you explained the fundamentals of triggers and it was awesome! I understood the basics of triggers so much better. I know this is too much to ask nevertheless I wanted to give it a shot. Thanks a bunch David! You are awesome!
Please ignore it! I dont know how i missed the webinars posted!!!
=)
Hi David,
I am a working professional having exp of about 8.5 years in Software Testing in Banking domain.
also I have worked on CRM product as a test analyst. then I discovered this world no#1 CRM product-Salesforce and I decided to switch my career path to Salesforce Dev. My current company is Salesforce partner and have pojects on salesforce
My current company is Salesforce partner and have pojects on salesforce. Will my testing background be considered in my new role? or I will be treated as fresher completely.
Please suggest.
You’ll be a fresher =)
hi every one i just really like this site very much it is helping me alot.
comming to the point i am new to the code .
And my requirement is when ever i create a new account i want one contact recard auto created
trigger con on Account (after insert) {
for(account acc : trigger.new) {
Contact mycontact = new Contact();
//case mycontact= new case();
mycontact.FirstName = ‘Firstname’;
mycontact.LastName =’Lastname’;
mycontact.accountid=acc.id;
insert mycontact;
}
}
I am getting Error: Compile Error: Constructor not defined: [contact].() at line 3 column 22
Looks good to me O_O
try this.
trigger Accoutupd on Account (after insert) {
Contact mycontact = new Contact( );
for(account acc : trigger.new) {
//case mycontact= new case();
mycontact.FirstName = ‘Firstname’;
mycontact.LastName =’Lastname’;
mycontact.accountId=acc.id;
}
insert mycontact;
}
Hi David,
Your site is awesome! thank you so much for creating a learning tool for us that are SFDC freaks! What is the quickest path to learning APEX?
No problemo!
Shortcut here:
https://www.sfdc99.com/2014/10/11/step-by-step-guide-to-becoming-a-salesforce-developer-this-year/
Thank you so much David! I picked up Head First Java already!! May the Force.com be with you young Apex Coding Jedi Master
David, thank you for creating this website. I’m an experienced developer but I had to write a complex trigger in Salesforce … And I know absolutely nothing about Salesforce! Your tutorial made it so easy and explained everything in such a no-nonsense way that I have gone from totally-confused to completely-enlightened in just two hours of reading. This is not just for people beginning programming – I think this is absolutely great for even programmers new to Salesforce.
I looked for your email on your website so I could drop you a thank you note, but I couldn’t find it so dropping a comment.
Thank you Mehdi =)
Hi,
I am getting the error message System.QueryException: List has no rows for assignment to SObject
MY TRIGGER is as follows:
trigger contactRecOwnerUpdate on Contact (before insert)
{
// This trigger sets the owner of the contact record to be the same as the
// owner of the account record
//
// Version 1.0
Map contactMap = new Map();
for (Contact contact : Trigger.New)
{
if(Trigger.isBefore)
{
if (System.Trigger.isInsert)
{
// Find the OwnerID of the account that the contact is going to be associated to
Account contactAccount = [select OwnerId from Account where Id=:contact.AccountId];
// Make the contact owner the same as the account
contact.OwnerId = contactAccount.OwnerId;
// Insert the OwnerId into the contact record
contactMap.put(contact.OwnerId,contact);
}
}
}
}
And MY Class is below:
@isTest
private class TestApexTriggers
{
static testMethod void apexTriggersUnitTest()
{
//Set up user
Profile supportUser = [SELECT Id FROM Profile WHERE Name=’U K Support User’];
Profile supportUserTL = [SELECT Id FROM Profile WHERE Name=’SENIOR MANAGER’];
User nordicTL = [SELECT Id FROM User WHERE ProfileId=:supportUserTL.Id and Alias =’ball’];
// The alias will change when the correct users are created
User nordicAgent = [SELECT Id FROM User WHERE ProfileId=:supportUser.Id and Alias =’rbows’];
// Get a list of all active record types within the system associated to Accounts
List accRTypes = [Select Name, Id From RecordType where sObjectType=’Account’];
// Create a map between the Account record Type Name and Id for for easy retrieval
Map accountRecordTypes = new Map{};
for(RecordType accRT: accRTypes)
accountRecordTypes.put(accRT.Name,accRT.Id);
// Get a list of all active record types within the system associated to Contacts
List conRTypes = [Select Name, Id From RecordType where sObjectType=’Contact’];
// Create a map between the Account record Type Name and Id for for easy retrieval
Map contactRecordTypes = new Map{};
for(RecordType conRT: conRTypes)
contactRecordTypes.put(conRT.Name,conRT.Id);
//Run As nordicTL
System.RunAs(nordicTL)
{
// Test Reseller create
System.debug(‘****** START Reseller Test *******’);
System.debug(‘Expected User: System Administrator’);
System.debug(‘Current User: ‘ + UserInfo.getUserName());
System.debug(‘Current Profile: ‘ + UserInfo.getProfileId());
Account resellerAcc = new Account();
resellerAcc.Name = ‘Unit Test Reseller1’;
resellerAcc.RecordTypeId = accountRecordTypes.get(‘Reseller’);
resellerAcc.Reseller_s_Hub_PIN__c = ‘9999’;
resellerAcc.ShippingStreet = ‘Test Street1’;
resellerAcc.ShippingCity = ‘Test City1’;
resellerAcc.ShippingState = ‘Test State1’;
resellerAcc.ShippingCountry = ‘Denmark’;
resellerAcc.ShippingPostalCode = ‘4700’;
System.debug(‘******* Trying insert resellerAcc *******’);
insert resellerAcc;
System.debug(‘******* Inserted resellerAcc *******’);
System.debug(‘****** END Reseller Test *******’);
}
//Run As nordicTL
System.RunAs(nordicAgent)
{
System.debug(‘****** START Home Test *******’);
System.debug(‘****** Creating a list of resellers in the system *******’);
// Get a list of all Resellers within the system associated to Contacts
List resellersList = [Select Name, Id From Account where RecordTypeId=:accountRecordTypes.get(‘Reseller’)];
System.debug(‘****** Creating a map of name, id for the retrieved resellers *******’);
// Create a map between the Reseller Name and Id for for easy retrieval
Map resellers = new Map{};
for(Account resAcc: resellersList)
resellers.put(resAcc.Name,resAcc.Id);
// Test Home create
System.debug(‘Expected User: Support User’);
System.debug(‘Current User: ‘ + UserInfo.getUserName());
System.debug(‘Current Profile: ‘ + UserInfo.getProfileId());
Account homeAcc = new Account();
homeAcc.Name = ‘Unit Test Home1’;
homeAcc.RecordTypeId = accountRecordTypes.get(‘Home’);
homeAcc.Reseller__c = resellers.get(‘Unit Test Reseller1’);
homeAcc.ShippingStreet = ‘Test Street1’;
homeAcc.ShippingCity = ‘Test City1’;
homeAcc.ShippingState = ‘Test State1’;
homeAcc.ShippingCountry = ‘Denmark’;
homeAcc.ShippingPostalCode = ‘4700’;
System.debug(‘****** Trying insert homeAcc *******’);
insert homeAcc;
System.debug(‘****** Inserted homeAcc *******’);
System.debug(‘****** END Home Test *******’);
// Test Contact create
System.debug(‘****** START Contact Test *******’);
System.debug(‘****** Creating a list of Home accounts in the system *******’);
// Get a list of all Resellers within the system associated to Contacts
List homesList = [Select Name, Id From Account where RecordTypeId=:accountRecordTypes.get(‘Home’)];
System.debug(‘****** Creating a map of name, id for the retrieved homes *******’);
// Create a map between the Home Account Name and Id for for easy retrieval
Map homes = new Map{};
for(Account homAcc: homesList)
homes.put(homAcc.Name,homAcc.Id);
Contact homeCon = new Contact();
homeCon.AccountId = homes.get(‘Unit Test Home1’);
homeCon.RecordTypeId = contactRecordTypes.get(‘Consumer’);
homeCon.Salutation = ‘Mr1’;
homeCon.FirstName = ‘Apex1’;
homeCon.LastName = ‘Unit-Test1’;
System.debug(‘****** Trying insert homeCon *******’);
insert homeCon;
System.debug(‘****** Inserted homeCon *******’);
System.debug(‘****** END Contact Test *******’);
}
}
}
One of your SOQL queries is returning no results!
The error message will say which line =)
Hi David,
I’ve recently completed the book: Apex Workbook.
This gave me fine idea of Apex and visual force.
Next, I’m thinking to start with book: Force.com workbook to learn Admin & functional part(which i already know a lil bit.).
M i going in correct path? Or please suggest me the next steps.
Thank u so much.
Make sure to check out Trailhead too!
https://www.sfdc99.com/additional-resources/
Hey David,
Wanted to first thank you for all the amazing work you’ve put into this website! You sir, should be knighted if you ever choose to visit us here in the United Kingdom!
I’ve been wanting to get into Apex coding for a while now but never quite found the motivation to really spend some time on it. I’ve just had an “eureka” moment (which you will find so small!) where I managed to use SOQL, a list and a DML statement to change a candidate’s first name in my dev org! Probably made me way happier than what it should have done…but small victories eh!
I’ll definitely be visiting your page daily as I continue my quest to become a decent Apex programmer.
Many thanks,
Pedro
Thank you for the kind words sir and good luck on your journey!
Hi David,
When can we expect the Quiz for chapter 7 and more topics for chapter 8 and other new chapters. Eagerly waiting for new topics to be published. I am thoroughly enjoying all your articles and quizzes.
Thanks,
Bikram.
Hhhmmm was planning to finish Chapter 8 before getting back to that!
Mostly comes down to whatever topic I have the most inspiration for at the time (I jump around a lot)!
David,
you are doing such great work! When I stumbled upon your site, I felt like dropping everything else and jumping right into Salesforce which I’m going to.
I come from programming background (mainly Java, J2EE, SOA integrations) and do not have Salesforce background (yet) BUT I want to pursue my career in Salesforce. Where should I start? Admin? Admin Certifications? then Dev?
Watching your videos from Dreamforce feels like breath of fresh air! Hope to meet you at Dreamforce this year :-)
– SD
Thanks SD!
I recommend starting off on the dev side and learning admin along the way, only because you have a strong dev background and doing it the other way might bore you =P
More info here too:
https://www.sfdc99.com/how-to-get-a-salesforce-developer-job/
See you at Dreamforce!
David
hi david,
i am new to salesforce ,wen i am writing this trigger facing an error : Variable does not exist : name
trigger autocon on Account (after insert) {
list lc = new list();
for(account ac : trigger.new){
contact c = new contact();
c.firstname = ac.name;
c.AccountId = ac.id;
c.Phone = ac.phone;
c.MailingCity = ac.billingcity;
lc.add(c);
}
insert lc;
}
and i am preparing for DEV 401,plz suggest me what are things that i need to cover
Honestly your trigger actually looks good to me.
Make sure to check out this page:
https://www.sfdc99.com/2014/10/02/guide-to-passing-all-salesforce-certifications/
once see the what type of account you have if its person account you have to give “last name”
THAT’S IT!!!!!!
Hi David,
I’m beginner to sales force. I’ve been working on Oracle CRM on Demand from last 6 years.
Now trying to switch into sales force.
This is really very site to learn about sales force and apex coding.
Thanks for such a nice documentation.
You’re welcome Priyanka =) Thank you for the kind words.
Hi David,
I found your website one of the plentiful with resources of SalesForce.
What I actually come across is the situation to create a Lead and assign it to the Campaign using SOAP API in C# application.
I just know that in order to do so, first I have to create CampaignMember and then assign it to the Campaign.
But I could not find a good example to start with.
Can you please give me some code snippet so I can make my way for this?
Thanks
Sorry can’t help with C# code!! Try the official forums for this one =)
Hi David, I need help on these following scenario, I have created 2 Products One is Main Products (Coffee) Second one is offer product(Coffee offer). If I sale or do outward of second one (Coffee offer), stock need to deduct from Main product (Coffee). How can I do this. Please help me on this.
Thanking you
Regards
Prasad
justlikeprasad@gmail.com
Try roll-up summaries for this =)
Hi David,
I was making an trigger between two object interview and position. Interview would have one look up which will go to Parent table Postion . What i need to do, i want to automatically generate the Interview date once user would select the position in interview. Postion will have one field start_end date.
trigger Interview on Interview__c (After insert, after update) {
for (interview__C interview : trigger.new)
{
If(position__C ! = null) — look up filled in interview
{
position__c start = [select start_date__c from postition__c where id := ] — (don’t know how will i relate the look up field with the position object detail)
// Means whatever record user will select from this reference , it would take that start end date so i can add it with 30 days which can automatically generate the interview date
interview_date__C = position_c.start + 30;
}
}
}
Please help me to make this complete !!
You can actually do this with a workflow instead and it would take all but five minutes to do!
yes , i can do but if i need to make this den ?? in the query i need to take a common field which can relate to that or through standard field like ID we can related this ??
Noooo do it without code! Start good habits early =)
Hello David Liu,
Currently I am working as QA engineer on salesforce.I am dev 401 certified and would like to switch in development.I am having total 1.6 years of experience in QA on Salesforce and knowledge of Java programming language.
Kindly suggest me how to learn apex and get into the development.
Thanks in advance.
Rahul
You definitely need to see this series!
https://www.sfdc99.com/how-to-get-a-salesforce-developer-job/
Dear David,
Are you going to add “Introduction to Apex Web Services” in chapter 11. Integration. I am trying to learn by myself but facing problems to understand webservices.
Thanks,
Swapnil
I sure will =)
But not this year!
Hello David,
Please do add Chapters on Visualforce whenever you feel its required for us. :)
You are my GURU. Its becuase of you I have cleared an interview and get a Decent Job of Salesforce Developer. But I am bit nervous about how will I survive as a Developer cause I haven’t have much confidence on Developement APEX & Visualforce.
BTW.. Thanks a lot.. I am just following you blindly and I know i ll become a great Salesforce Developer one day. No one can stop me now.
Thanks Again
Dharmendra
I have a field API name as DiscountPrice__c,I don’t want this field to be seen in page layout, instead this field should be seen in details page with its Discount price value.How can I accomplish this?Help me.
You’ll need Visualforce if you want it to show up on the Edit page but not the regular layout!
David you are the super hero(guru) of Salesforce! I finished my Admin 201 certificate with your inspirations and comments in the blog.Now i am working on Dev 401 certification.Thanks for the inspiration!God Bless You with Millions of dollars and Good Health.
hahaha my pleasure buddy and congrats on the cert!
1. If any student have wife name populated, then automatically mark him as married [new field] = true.
2. User should not be able to insert/update if that teacher is not active.
3. User should not be able to delete a class if there is any student in it.
Try to get some code started and maybe post it on our forums!
Hi David,
I have been going through your tutorials while preparing for my admin exam ( already have Dev 401 ). I just have a question RE: studying the correct way. I have been following your philosophy of your tutorials, going through Head First java and getting certified, however, there seems so many places to learn SF and its overwhelming. Sometimes I think I am not going down the correct path the best way. There is mention of Udacity, Pluralsight , TrailHead, learning VisualForce (do I dare), Lightning Components, developer workbooks. It’s just a little confusing. I don’t want to jump around a lot, but want to absorb as much as possible and complement my learning path.
Do you have any advice for me (and others) for taking the correct steps through a Salesforce learning path?
BTW, nice podcast on YappExchange
Focus on triggers and forget the rest =)
Once you’re good at triggers (ie Chapter 5 is cake) you can move on =)
Salesforce Interview Preparation Toolkit
http://www.scribd.com/doc/205126161/Salesforce-Interview-Preparation-Toolkit-Formula-and-Validation-Rules-in-SalesForce
Hi ,
Salesforce Developer 401 Winter 15 Certification Dumps Required. Pls send to My Mail Id ramkumar.srec@gmail.com. Thanks in Advance
by,
RamKumar
Check this page out!
https://www.sfdc99.com/2014/10/02/guide-to-passing-all-salesforce-certifications/
I want to start learning Salesforce. I do not have much coding knowledge. I have worked in dot net.
Do I need to have strong knowledge of Java, apex etc to be a salesforce developer.
Does Salesforce admin need coding knowledge?Please advise
The only background that’s really helpful when learning is an admin background!
But admins do not need to know how to code. Most people want to code to become even more powerful than admins.
Hi David, I cleared DEV 401 and getting my hands dirty by learning coding. I am really happy that i found your site.
Thanks for all your support for newbies. We are fortunate to have a kind person like You. #TrueInspiration
Thank you Lokesh!
Hi David, I have been struggling with coding for some time. Just started with your site, You are a boon and God sent for new aspiring coders, you have made a very hard task a fun task. When you do such selfless things in life, you accumulate good wishes and blessings (knowingly or unknowingly) from all your users. God bless!!
Thank you Suku for your kind words!
David, I’ve never been exposed to coding. I’ve been just a mere Salesforce admin and I was about to be canned because I do not know how to code. However, I created some simple triggers and run those on orgs after I came here, sfdc99 and studied. I still have a far, far way to go, but you’ve been my inspiration and motivation to learn. I really wish if I could treat you to a nice dinner or a beer if I were in your area! Hope to see you around next Dreamforce!
Thank you for your kind words Kelly!
I am always down for a beer if you’re ever in the area!
P.S. You’d probably have a killer story of how you turned your career around by learning to code!
https://www.sfdc99.com/sfdc99-reader-success-stories/
David
When i am trying to deactivate user get below error:-
You cannot deactivate a user who is receiving cases or notifications as part of your case assignment/escalation rules. Click here to view your case assignment / escalation rules.
User are not part of case assignment rules and escalation rules, but still i am getting error also i have deactivate all assignment/escalation rule but still not able to deactivate user.
Check your workflow and case settings =)
Hi David,
Thank you for your guidance. I have bought the book, you suggested, but here am worried – will there be any conflict and confusion in learning both the Java and apex programming at a time alternatively.
Regards,
Kumar
I learned that way and so did many others!
https://www.sfdc99.com/sfdc99-reader-success-stories/
No need to worry at all =)
Hi David,
I am Sandeep based out of Bangalore (India). I am very excited to see your site sfdc99, it has lot of inspirational information and stories of many achievers from non-developement background. I am on the same path. I have completed 6 years of experience in various IT domains ( mainly with server operations)and thought of looking for a different domain and that is when I heard of SFDC. I took training on ADM201 and DEV401 which helped me understand well about SFDC. I built couple of apps with guidance from training institute. Giving many trys in different companies am failing to clear the interviews( Usually getting rejected saying am good with admin stuff but not with developement). My feel is if I start working atleast as SFDC admin, I can parallelly learn coding which am currently doing. But in India there is no demand for admins. I am a Physically challenged person and getting it hard to get a job in SFDC domain as an admin. Kindly advise and help me with further steps. I really want to work in Salesforce domain as an admin at first and further grow as a developer with detailed learning.
Warm regards
Sandeep
Glad you’re enjoying the site =)
If I was in your situation, I would learn the admin side first. This is best for long-term but will definitely slow your code learning in the beginning. It should take no more than two months of hard work to learn enough of the admin side of things.
After that, learn development but always remember that if you can do something without code, it’s better to do it without code first!
So stay on your path! Just know that you don’t need to go super deep in the admin side before you start coding =)
David
Hi All,
I work on remedyforce tool. I want to create a email service in which whenever a person sends email to that email service an incident(incident object) get generated. Please help me out
You need to check this out!
https://developer.salesforce.com/page/An_Introduction_To_Email_Services_on_Force.com
Hi David, I am loving your site and have just got a job as a Salesforce analyst with a view to becoming a Salesforce developer in time. I would love to see some exercises that I could try. Are you considering adding some to your site?
Thanks again.
Congrats on the job!!!
Have you tried…
Quizzes: https://www.sfdc99.com/beginner-tutorials/
Challenges: https://www.sfdc99.com/challenges/
Hi David,
I am new to the salesforce and I am going to write a DEV 401 exam.
For that What are the topics Ive to learn?
I dono what to do learn and dont
Please help!
This post is all you need =)
https://www.sfdc99.com/2014/10/02/guide-to-passing-all-salesforce-certifications/
Many thanks David.
hi devid,
site is very good……
i want to know about chapter 8,9 and 10.. could you provide??
After Dreamforce!
HI David,
I have a question on how may users we can create with developer edition of salesforce. i have created two users with license selected as salesforce and after i am not able to select salesforce as license option.
Thanks
Ramakrishnaa
Only two – I tried!
Hi David, are aware of any workaround to fire a trigger from a mass-email? It’s a no-no to tell somebody to do their mass emails outside sfdc because the activity won’t fire a trigger.
*are you aware
You’ll want the trigger to fire on whatever record is saved as a result of the mass email – I believe it is something like an HTML email message or something like that!
Thanks for answering!
The trigger is fire from the record saved as result of the mass emaiil (the task). My trigger runs on Task after insert and after update; it modifies Contact fields. When the Activity from a Mass Email is created, it doesn’t fire the trigger. I see in the documentation that Mass Emails don’t fire triggers, that’s why I’m trying to find a workaround.
Thanks for your posts! You have perfect success story.
I’ve shared your site with Russian Salesforce Community. Here https://salesforce-developer.ru/links
Thank you sir for the shout-out!
Thanks so much David for taking the time to create this website. I have no formal background in coding and have been trying for awhile to take my developer skills to the next level on the SFDC platform. Before I found your website, I could read some code and copy and paste it but I was really struggling with customizing and applying what I knew to our Org. A colleague of mine pointed me to this website and after reading some of the chapters and watching the webinars the light bulb finally went off, I get it now! The way you present and explain things makes it so easy to understand. Awesome work, can’t thank you enough!
Go Amanda!!
hehehe give your colleague a high five for me for sharing my site!
I want to write some code/a trigger to do a lookup. I have a field on my client object that is a custom field. When I create a task related to that client, I want to be able to view some information from the client object on the task (i.e. pull in the phone number or alternate address) and they said I would need to write a trigger to do this. I’m a beginner, can you just point me in the right direction?
Hi David,
I am stuck in a problem. Help me out. I have a Object called residential in this there is a field called Budget Maximum and size maximum. Then the Total value Budget Maximum will be in result.. while i am making a formula then the value in Crores like 70 crore in Budget Maximum and 50 crore in Size maximum is running and total value in the case of Budget maximum is showing, but in the case of (100 crore + )in Budget Maximum and [(Max)-whatever after 100 crore+ ] in Size maximum is not working.. help me out .. what should i write in formula or is it good to make a trigger.? Help me out if trigger how?
question for you David. i see we can use eclipse for writing code but I’m getting pretty familiar with Netbeans. Do you know if there is a plug in connecting netbeans with force.com. I have tried google but can’t find anything.
thanks,
Chad
Never tried or heard of NetBeans! One I hear often about though is MavensMate – worth a look!
Actually in below trigger Whenever crate the account automatically create ooportunity. so plz david send me test class in below trigger
trigger createOpp on Account(after insert){
list listopp=new list();
for(Account a:trigger.new){
opportunity opp=new opportunity();
opp.Name=a.name;
opp.AccountId=a.id;
opp.stageName=’proposal’;
opp.CloseDate=system.today()+5;
listopp.add(opp);
}
insert listopp;
}
Hi david,
you are doing a great work for beginners in salesforce, i can understand clearly all the things :) hats off
Thanks =)
It’s really confusing to know where to use constant or static when to use what, I know lot of theories in salesforce when coming to implementation, I lose everything how can I enhance that and know what to use when and where
Chapter 8 will cover this kind of stuff =)
Play it safe and use constants for now until you learn about static =)
amazing things you are doing thanks a lot david :)
Hi David,
Your story is so motivating. I have started learning Salesforce this week and targeting to pass DEV401 and ADM 201 in next 30-40 days.
Thanks,
Santosh
Hi David,
THE Best tutorial for beginners. If a newbie just read through your topics, he would understand all the concepts without even actually working on it. I SIMPLY LOVE IT.
Now desperately awaiting tutorial on BATCH APEX, Scheduling and Future annotations.
If there would have been a rating system, I would rate you 10 out of 5 Dave.
Thanks buddy =)
hi david pls give the answer
question: “when ever custmer record is updated,before updating the record create new record in test object with old value of custmer record in salesforce trigger code”
Hi David
Thanks for everything. Got a question. In an apex class, how can I query for child records where the parent id is the same in two or more cases. Can’t do GROUPING BY in apex apparently, so I’m trying to figure out a for loop with something like size()
So – pseudo code something like
Find Id, start_date__c, completion_date__c, parentId where completion_date__c = null in customchild__c record where parentId has more than one customchild__c record.
It would be even better if I could group by parentId and grab only the customchild__c record from each group where start_date__c is the earliest
Hi David,
Hope you doing fine.
Just a quick question , i am a salesforce admin and wanted to automate some stuff i.e., package installation.
I am not sure if i can do that provided ,they are all manged packages and there is difference in access for each package.
Let me know your thoughts.
You probably want to check out Ant deployment:
http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_deploying_ant.htm
Hi David, I am from mainframes background and looking to move career from this to sales force. I came across your site and I am loving it. You had everything in detail . Even an amateur in this field can easily grasp the subject. Thank you so much.
I want to become a sales force admin, Should I still go through your Point 1 in Chapter 0 – The Basics or we should start at Point 2 , “The best way to quickly learn the non-coding, admin side of Salesforce”
You might want to go to #2, then #3, then #1 ha ha ha =)
Glad you like the site!
The best site to learn Apex. I was able to bulkify my first trigger with the help of this site. And it was not an easy one. It had insertions and updations on one object and insertions into another object. Plus a master-detail relationship between both. And I’m glad I did it with your help. Thanks again David…
I’m proud of you =*) Great job Tasnim!!!
Hi David,
How are you ,
I need to write a trigger on user object that executes immediately after user login into salesforce. i.e. a field should get updated as soon as user login into salesforce.
– Shobhit
hey david……loving you site soooo much….thanx for everything…….
You’re welcome!
hey david….i got a problem…i had a html code which is application for job.i had implemented that html code into visualforce page…i want to save that data on my org.i didnt created any object or anything for that html…..can u help me…?
Hi David,
I am confused about the usage of trigger.new and trigger.old.In every trigger these lines are there.Please explain the above two.
Thanks Krishna
Maybe you can post this on our forums? =)
https://www.sfdc99.com/forums/forum/beginning-apex/
hi david canyou tell me hw to insert a image in vf page
http://www.salesforce.com/us/developer/docs/pages/Content/pages_compref_image.htm
hi DAVID…..can you please tell me how to insert image file in VF page
http://www.salesforce.com/us/developer/docs/pages/Content/pages_compref_image.htm
Hello David, I’m trying to do the SOQL Query in the 2nd video but I’m getting an error that says: ERROR:
Parent relationship queries are disabled in Workbench: Account.Name
Due to issues rendering query results, parent relationship queries are disabled by default. If you understand these limitations, parent relationship queries can be enabled under Settings. Alternatively, parent relationship queries can be run with REST Explorer under the Utilities menu without issue.
Any idea why I’m getting that? I’ve tried with two different developer orgs and I get the same error on both.
Never mind on this. I actually read the error message this time.
Click the Workbench icon, go to settings, and enable the parent queries =)
Hi David,
I found this question in salesforce forum, tried to resolve it but not even getting an idea how to do that.. Can you please check this once..
Creating a formula number field which should accept only month and year
mm/yyyy format
and not date
let meknow the formula to use
Hurry!!!!!
I solved it..
TEXT(MONTH(DATEVALUE(TEXT(Project__r.Actual_Project_close_date__c )))) & “/” & TEXT(YEAR(DATEVALUE(TEXT(Project__r.Actual_Project_close_date__c ))))
Sweeeeeeeeeeeet!
Hiiii David!!!
Many Congratulations..
Happy Married Life!!!!
David – first mazal tov on the wedding; second thanks for your generous interest in all of us trying to teach ourselves apex.
I’m stuck. I’ve written a trigger and some classes on the Opportunity Object. The code ‘works’ and in the sandbox the 8 methods say covered 100%. However, when I try to deploy it to production it’s 45%. The only other triggers belong to Marketo (appExchange) and they are all 100%. I’m happy to post the code, but I’d really like to learn ‘what I’ve done wrong’.
I already know some things in my test aren’t working as I want so I had to adjust.
Any suggestions on the best next step?
Thank you Jonathan!
Most likely either…
1. There’s a validation rule in production causing an error in your test class
2. Something in your test class is hardcoded, and that value doesn’t apply in production
3. You’re using the @SeeAllData=true annotation, which often breaks test classes as they’re deployed
Basically something in your test class is breaking, and it only breaks in production because of some difference in production vs sandbox!
David
Thanks David
After looking at it again (and by the way, I’m totally self taught at all things computer so forgive bad habits):
1) I think I resolved one problem by some different hard-coding, but I’d really like to use variables. However, I’m not sure what the syntax is to do it in the following example [here’s my first bit of code]:
//data setup functions
private static Opportunity createTestOpps(String Name, String StageName, Decimal Probability, Date CloseDate, String Type) {
return new Opportunity (Name=Name, StageName = StageName, Probability = Probability, CloseDate = CloseDate, Type = Type);
}
//create bulk opportunities
private static testmethod void createBulkTestData() {
//create String List for Opportunity StageName picklist values
List stNames = new List();
stNames.add(‘Qual’);
stNames.add(‘Needs’);
stNames.add(‘Rest’);
//create Opportunities
List newTestOpps = new List();
for (Integer i=0; i<10; i++) {
newTestOpps.add(createTestOpps('Trigger'+i, 'Qual', 0.01, date.Today() + 10, 'New Business'));
}
try{
insert newTestOpps;
} catch (DmlException e) {
}
______________________________________________
I would like to replace my String StageName with the variable stNames[0] but I'm not sure what to put instead of 'String'.
2) My trigger and class basically do this:
a) On insert of new opportunity or on update(change) of opportunity stage a custom object record is created and the start date populated to Today(). My testing confirms both of these scenarios work as expected.
b) If an opportunity already had one 'stage' record with an open 'completion date', and the stage is set to the previous opportunity stage value, then the trigger/class go back into that record and populate the completion date with Today() as well. This works in my sandbox. It also says in my test class that 8/8 methods are covered. However, my attempts to update the Opportunity StageName on the records I just created, thereby enacting the trigger/class to create a new record and close the old one are failing to activate the trigger/class. All I'm doing below is updating the value without activating the trigger/class.
//Update opportunity stage to 'Needs'
List firstTestOpps = [Select Id, StageName FROM Opportunity WHERE Id = :insTestOpps];
List updTestOpps = [Select Id, StageName FROM Opportunity WHERE Id = :insTestOpps];
updTestOpps[0].StageName = ‘Needs’;
try{
update updTestOpps[0];
}catch (DmlException e) {
}
Opportunity_Stage_History__c updInsOppsh = [Select Id, Opportunity__c, Stage__c, Start_Date__c, Completion_Date__c
FROM Opportunity_Stage_History__c
WHERE Opportunity__c =:updTestOpps LIMIT 1];
System.assertEquals(‘Needs’, updTestOpps[0].StageName);
System.assertEquals(updInsOppsh.Start_Date__c, date.TODAY());
System.assertEquals(updInsOppsh.Completion_Date__c, NULL);
Opportunity_Stage_History__c updOldOppsh = [Select Id, Opportunity__c, Stage__c, Start_Date__c, Completion_Date__c
FROM Opportunity_Stage_History__c
WHERE Opportunity__c =:firstTestOpps LIMIT 1];
System.assertEquals(updOldOppsh.Stage__c, firstTestOpps[0].StageName);
System.assertEquals(‘Qual’, firstTestOpps[0].StageName);
}
_________
If I add something like System.assertNotEquals(null, updOldOppsh.Completion_Date__c); it will fail as null is there.
Any help would be great:)
PS – here’s another attempt to get at the new opportunity stage record but I can’t get further and find the updated Stage record (which should have a completion date) or the new Stage Record
static testmethod void createUpdateOppData() {
//Create an opportunity
Opportunity updOpp = new Opportunity();
updOpp.Name = ‘TestUpdate’;
updOpp.StageName = ‘Qual’;
updOpp.Probability = 0.01;
updOpp.CloseDate = date.TODAY() + 10;
updOpp.Type = ‘New Bus’;
insert updOpp;
//This gives us a frozen view of the opportunity as originally entered
List oldOpp = [SELECT Id, Name, StageName FROM Opportunity WHERE Id = :updOpp.Id];
System.assertEquals(oldOpp[0].StageName, ‘Qual’);
//Create Opportunity Stage History
Opportunity_Stage_History__c firstOsh = new Opportunity_Stage_History__c();
firstOsh.Opportunity__c = updOpp.Id;
firstOsh.Stage__c = ‘Qual’;
firstOsh.Start_Date__c = date.TODAY() – 10;
firstOsh.Completion_Date__c = null;
insert firstOsh;
//Update Opportunity StageName
updOpp.StageName = ‘Needs’;
try {
update updOpp;
} catch (DmlException e1){
}
//Get updated opportunity
Opportunity updatedOpp = [Select Id, Name, StageName FROM Opportunity WHERE Name = ‘TestUpdate’];
System.assertEquals(updatedOpp.StageName,’Needs’);
System.assertNotEquals(updatedOpp.StageName,oldOpp[0].StageName);
System.assertEquals(updatedOpp.Id,firstOsh.Opportunity__c);
}
___
It’s driving me crazy (crazier).
disregard stuff below. By system.debug – which is now my best friend, I’ve found that nothing I’m doing (tried a few ways), is successfully activating the ‘after update’ part of my trigger/class in my test class. I’m presuming I don’t know the way to have the Test class think it’s ‘saving’ a record so I can tell my test record that it’s now being updated and needs to activate the after update part of the trigger. Right now I can update the value in the field that’s supposed to trigger the trigger, but it won’t do it’s bit. (as I’m writing this, just got an idea, but in the meantime…)
…if you can help me figure this out, I would be really grateful.
hey david ….love you sooooooo much…….
Love you too!
hi david,
i have created an object with a lookup relation with some other custom object.
how can i access multiple values for the lookup relation??
This post will show you how!
https://www.sfdc99.com/2013/06/24/example-how-to-write-a-cross-object-soql-query-part-2/
Hi David,
Could you please tell what is wrong with this piece of code :
public class login (){
public DateTime lastlogin{get;set;}
User u = [SELECT LastLoginDate FROM User WHERE Id =:UserInfo.getUserId()];
lastlogin = u.LastLoginDate;
}
Error message : unexpected token ‘=’
Could you please tell me why i am getting this error message.
Thanks in advance.
– Shobhit
Hi Shobit,
I am not sure about the answer but it might help you, please try this..
This sentence –public DateTime lastlogin{get;set;}— you declaring lastlogin as DateTime, that means DATE and TIME right.
But here — [SELECT LastLoginDate FROM User WHERE Id =:UserInfo.getUserId()] — LastLoginDate may be only Date field ( not DATETIME field)
So –lastlogin = u.LastLoginDate;– when your are assigning a DATE field to DATETIME field it will not accept.
May be this is the reason why you got this Error message : unexpected token ‘=’
Hi Nagarjuna,
Thanks for your reply.
LastLoginDate is a date time field i queried it using Developer Console’s execute Anonymous and found the following result :
|DEBUG|2014-08-29 08:08:40
And if you declare it as a date field it will give u error stating that “Illegal assignment from Datetime to Date”.
David – Sorry about that parenthesis :D
– Shobhit
It might also be the parenthesis after the class name!
public class login {
public DateTime lastlogin {get;set;}
User u = [SELECT LastLoginDate FROM User WHERE Id =:UserInfo.getUserId()];
lastlogin = u.LastLoginDate;
}
Sorry about that parenthesis :D
LastLoginDate is a date time field i queried it using Developer Console’s execute Anonymous and found the following result :
|DEBUG|2014-08-29 08:08:40
And if you declare it as a date field it will give u error stating that “Illegal assignment from Datetime to Date”.
So, now could you let me know what is the correct solution for this piece of code :)
– Shobhit
This’ll do the trick!
https://www.salesforce.com/us/developer/docs/apexcode/Content/apex_methods_system_datetime.htm#apex_System_Datetime_date
On which collections(LIST,SET,MAP) we can perform DML Operartions?
List!
How Nested reports are implemented and what is the limit for it. (Custom Reports And the Limit is 4)
How to depict the Polar dashboard for a report
Hi David
What is Salesforce Automation?
Salesforce automation means ondemand customer relationship management system,
SalesForce Automation includes ,
* Marketing Automation
* Sales Automation
* Customer Support Management
In simple general words, let us consider a Product that we need to sell.
1) we will do compaigns (advertisments, emails, seminors etc…) to make every one know about our product. (marketing)
2) Then we will sell our product ( sales)
3) Once after selling our product we have to provide customer service if product have any problem ( customer support)
Are you just sending me your interview questions? =)
Ha Ha Ha.. May be he is!!
But Nag keep asking what ever questions you have in your mind..
Now think whether the question in small or good or bad or anything..
Cheers,
Nagarjuna
By avoiding profiles and roles, how can you make the user to access the records?
By using Permission sets you can grant access to particular records to a user.
Hi David,
I have a query.
I need to develop a functionality where when user login in to salesforce, one field on user or account object is automatically updated or a PDF is automatically downloaded.
Approach :
1. Firstly, i will write a trigger on user object
2. I need to capture the login event how i will do that ? Could you please help me in this scenario.
Thanks in advance.
– Shobhit
How about checking the LastLoginDate field?
Hi David,
Thanks David, i am able to update the field but how do i download the file automatically upon login.
Cheers.
– Shobhit
HI Shobhit,
I am not sure whether it works or not but try it.
If you are able to update a field upon login, then try to write a trigger on that particular updated filed (like when field is updated trigger will fire generating a pdf ).
Cheers.
Hi David,
I was reading few articles to understand the difference between abstract class and virtual class and I came across this http://share-salesforce.blogspot.in/2013/05/salesforce-apex-class-simpleregular-vs.html. The description for abstract class is bit confusing. The only possible explanation to have regular methods within abstract class is that they must be defined as static. Please tell me if my understanding is correct.
Also, can you please explain what’s your take on difference between the abstract and virtual class?
Thanks,
Harish
Great question but I honestly don’t know that topic well enough off the top of my head to give you a clear answer! I’d be shocked honestly if any Salesforce development interviews asked about that!
Hi Harish,
Refer Java documentation directly you will get better explanation.
Dont try to remember them. As hard you try to remember the difference between them that much soon you will forget.. Just go on!! your coding teach you..
Hi David, I have a requirement wherein I need to take the total of all expense line items for a specific category and add this expense total to a amount field in a different object.
1. I used a List to fetch the total from expense line items.
2. And then, fetched the current records from the other object into a map.
3. within a for loop, I get the current value from the map, add it to the total obtained earlier and build a list of objects.
4. Outside the for loop I fire a update DML.
Is there a better way to do this (especially step 2 & 3)?
Thanks
Jake
Looks great so far Jake!
by using workflow when i modify child object i want to update parent object.in which relation it is possible?
Possible, but only if it’s a master-detail relationship!
ARE DAVID PLEASE ANSWER MY QUESTION ON LINKEDIN
Hi DAVID
i have 2 orgs.org1 have 10 opp__r object records with 10 child records each which accept duplicates and org2 will not allow duplicates i want to insert the org1 records to org2 without duplicates how?
You should break this down into separate steps:
1. Get rid of all dupes
2. Migrate to org2
. i am having 11 objects if i write the trigger i want to fire all the 11 objects?
how many triggers you will write?
11 triggers!
Hi David
I have a validation rule which i want to fire only while inserting How?
Use the ISNEW() formula
Hi david ,
i have a validation rule when entering data from sfdc ui i want to fire?i dont want to fire when i am uploading data from external systems eg.ms crm, sybel crm…?how u can achive this?
If data coming from external systems is logging in as a specific user, make an exception in your validation rule for that user ID
thanxxxx David
Np man luv u 2!
hey David…….been a regular follower of your blog……….i’m done with all the lessons just wondering when would you start chapter 8 9 10 11…..awaiting your reply
Chapter 8 in progress! Future chapters unknown!
Hi david, can you lend an ear? Can we chat via email rather than on-line. My company is HIPAA compliant and we are in the bay too! If you can provide a private email that would be helpful? Thank you =-) Our website is low key and we are not on facebook.
Referred you to a few strong options (via email) since I’m unfortunately not available for hire!
Wish you the best though as it sounds like you’re on an unbelievable trajectory!
Hi David, I have a growing company and I am looking to utilize/create software that allows my customers to book appointments via an app or other. We need to provide real time updates on our availability and provide round-the-clock service for our 7 day per week revolving client base connecting to 1200 new customers monthly. We are drowning in a system that needs to go paperless and we need to provide better customer service with timely updates. Can you provide an email so we can connect? I just stumbled on saleforce site.
Thanks for reaching out Nichole! I probably can’t help you out with this one – but you may want to give the Salesforce sales a team a call to see if they can hook you up!
I am new to triggers and have never written in Apex, can you point me in the write direction or do you have sample code in order to update a standard picklist field with all the values from a custom picklist field, i’ve read that this is they way to go in order to update a standard picklist with a custom picklist. I attempted to do this with a worklow in order to do a field update but i am only able to select one of the picklist values and i need to pass all the values.
I have lead statuses that need to be dependent on phases but they are not dependent on phases(custom field) because that status field in SF is a standard field and i can’t use a workflow to update a standard field with a custom field. Our idea was to create a another custom field (lead statuses) this field will be used to create a workflow in order to have lead status dependent on phases and then use the custom field (lead status picklist) to update the standard field picklist.
Using code you can populate picklists with anything, even if the values aren’t defined!
For example, you might have a picklist: red, green, blue. Using code, you can populate a record with yellow as the picklist value!
The only thing to note is that users will only be able to choose yellow if the code does it for them!
David – do you have another email? I would like to see about having you develop a system for us. Please contact
when will the rest of the chapters will be available , that is after chapter 7
Probably after my wedding in a month! Hoping to start beforehand though!
Hi David,
I need advice. I have had experience administering some SAAS applications like SuccessFactor and Taleo but not Sales Force. I have a background in Computer Science but its been a few years since I last coded. I want to be Sales Force developer but need guidance on how to start. I have ordered Head First Java and started reading it. Is this the right way to start or should I start learning about Sales Force administration before starting with Java. Could you suggest some tutorials/books/videos to get started with administration or should I just continue with your recommended plan.
Hahaha definitely continue with my recommended plan! It took me a long time to come up with it, and it’s the quickest, most effective way available!
hey David…….been a regular follower of your blog……….i’m done with all the lessons just wondering when would you start chapter 8 9 10 11…..awaiting your reply
Hahaha going slowly, prepping for a wedding right now!
Hi David I have just got a job as salesforce admin.I am new to it.Since i have basic knowledge of java programming my manager has given me a project to develop customized dashboard.I dont know where to start.Please assist
This is all admin stuff – the Analytics workbook is a good start!
Customized dash board is required.and that requires VF coding.Please assist.
Hi David
I have just got a job as a salesforce admin and since i have basic knowledge of java coding my manager has given me a project to create customized dash board. I dont know where to start.Kindly assist.
Hi david,
I am new to the salesforce…So can you tell me the flow of sales objects(Campaign,Lead,Account,Contact,Opportunity,Product,Quotes,orders,Contract,cases and solution..)
Hhhmm that is a long subject, I recommend looking at other sites for that info =) Maybe YouTube!
No words to say, All I can say is I am a SFDC Developer & I’m In from today until I RIP. ~ Respect
My 2 Cents : Kindly add a forum to the site with Vbulletein or something that you find fit and also a way to create username & Pass so that all can be a part of the Salesport.
Love it!!
The forum is a great idea! I will look into that!
David
Hello David,
what is difference between workflow, trigger and Approval process in salesforce
can you help me with some example.
Thanks,
Manish
Approval – approve/reject changes
Workflow – simple automation
Trigger – complex automation
Hi, David;
Your site has been most illuminating; I’m working thru it, the SFDC ‘Apex Workbook,” and “Headfirst Java” all at the same time, spurred along by an urgent project need here at work, where I need to use a trigger to perform a bit of calculation on a customized Opportunity. Normally I’d do this via a formula field or a workflow rule / field update pair, but due to intensive customization in our org, trying to do it with a formula field exceeds the per-object calculation limits, and when I do it using a WFR/FU pair it fails because the WFR runs before other values have finished being calculated – – users end up having to ‘save twice’ to get everything properly calculated on the Opp.
With the help of your tutorials, I’ve managed to build the following trigger; it works fine for individual records in our sandbox instance, but I’m still a little mystified about the whole ‘bulkification’ angle. As far as I can see I’m not making any SOQL or DML calls & the trigger runs before update only, so I don’t THINK I need bulkification, but I’m paranoid and would like to be sure things aren’t going to break later, say on a bulk Opp update done via DataLoader.
I could really use your help, oh SalesForce Sensei!
Can you tell me 1) Does the below trigger need bulkification, and 2) if yes, can you show me how it would work here?
trigger WarrantyCalc on Opportunity (before update) {
String WarrTypeStr1 = ’90 Day Standard-Response’;
String WarrTypeStr2 = ‘1 Year Standard-Response’;
String WarrTypeStr3 = ‘Box Sale-Mfg\’s Warranty Only’; // backslash escapes the sgl-quote char
for (Opportunity oppInLoop : Trigger.new){
if (oppInLoop.Warranty_Cost_Override__c != null) { // part I: Cost selection
oppInLoop.Warranty_Cost__c = oppInLoop.Warranty_Cost_Override__c; // If there’s a cost override, use it
} else if (oppInLoop.Large_Project_Flag__c == ‘No’ && // If project is small AND
(oppInLoop.Selected_Warranty__c == WarrTypeStr1 // If one of these types…
|| oppInLoop.Selected_Warranty__c == WarrTypeStr2
|| oppInLoop.Selected_Warranty__c == WarrTypeStr3 ) ) {
oppInLoop.Warranty_Cost__c = 0; // …cost is Zero
}else{
oppInLoop.Warranty_Cost__c = oppInLoop.Warranty_Cost_Select__c;} // Otherwise, use cost as calculated
if (oppInLoop.Warranty_Sell_Override__c != null) { //Part II: Sell selection
oppInLoop.Warranty_Sell__c = oppInLoop.Warranty_Sell_Override__c; // If there’s a Sell override, use it
} else if (oppInLoop.Warranty_Cost_Override__c != null) { // If there’s a Cost override,
oppInLoop.Warranty_Sell__c = (oppInLoop.Warranty_Cost_Override__c / 0.70); // Calculate Sell based on it
} else if (oppInLoop.Large_Project_Flag__c == ‘No’ && // If project is small AND
(oppInLoop.Selected_Warranty__c == WarrTypeStr1 // If one of these types…
|| oppInLoop.Selected_Warranty__c == WarrTypeStr2
|| oppInLoop.Selected_Warranty__c == WarrTypeStr3 ) ) {
oppInLoop.Warranty_Sell__c = 0; // … Sell is Zero
}else{
oppInLoop.Warranty_Sell__c = oppInLoop.Warranty_List_Select__c;} // Otherwise, use List as calculated
}
}
Thanks in advance for any input you can offer… the project is due next week!
You’re 100% spot on: no need to bulkify since you don’t have SOQL in your trigger!
Best way to check is to:
1. Test on individual records to simply make sure your code works
2. Use data loader to update 200 Opps at the same time to see if you get any errors
Excellent! Thanks so much for your reply – just the confidence-booster I needed to kick this puppy into Production!
Hi David…I’ve been following your site since attending your webinars a month or so back…GREAT stuff to say the least! I do have a question however that i can’t figure out…I’ve written a few triggers in my Sandbox that work perfect, basically when a specific task is completed, the trigger fires and updates a couple custom fields on the Account object. I need to replicate the same action, BUT it needs to happen on an Event – when the date and time pass – but since Events are not “completed” and there is no field change per se…is there a trigger or method to update the custom field(s) on the Account when the Event is technically “completed”? I’m completely lost on this one…any help would be greatly appreciated. Thanks so much!!!
No problem!
Two solutions:
(Easy) Use a time-based workflow
(Hard) Have a scheduled Apex job (using Batch Apex) to do a daily check of past events
(Medium) Have a time-based workflow update an Event after it passes. Triggers will run on this update
OK…I’d like to keep this as “Easy” as possible, lol… On my Event, the driver for the change is the “Subject” field, so on the time-based workflow would I set it to look at Events with an “End date” of let’s say “YESTERDAY” AND with the particular subject entered as a filter, then if it meets the criteria, have it update the custom field on the Account? Then have it kick-off say at 1:00am each day for the previous day’s entries? Does that seem correct? Sorry if it’s elementary…thanks again David!!!
Give it a shot! You might have some trouble updating the account though – code time!
Great stuff David!!! One last issue however…
I created the Custom picklist (Event_Status_c) with 2 values – Not Started and Completed. The default is not Started. I created a workflow rule that will update the custom field to “Completed” once the date/time passes…basically if the Event End Date is YESTERDAY it triggers the rule to run. Tested that and it works perfect…my problem is now with the trigger. Since I’m still a newbie to Apex and triggers, I tried modifying an existing trigger for the Event to update the fields on the Related To Account…below is that code:
trigger changeAccountStageEvent1 on Event (after update) {
List accsToUpdate = new List();
for (Event ev: Trigger.new){
if(ev.Event_Status_c==’Completed’ && ev.Subject==’Initial Sell/Needs Assessment’){
Account ld = new Account(Id=ev.WhatId);
ld.Stage__c = ‘Needs Assessment Completed’;
accsToUpdate.add(ld);
}
}
update accsToUpdate;
}
Problem is I keep getting this error – Error: Compile Error: Invalid field Event_Status_c for SObject Event at line 4 column 16.
Does anything jump out as being wrong in my code? Been battling this one for a while now…but I can’t give up, lol!!!
Any thoughts? Thanks again!!! :)
Yes! You need two underscores there!
Event_Status__c
Amazing site , i have seen many sites but this has so much simplicity and the goodness of the heart is reflected in these Reservoir of knowledge.
Thank you very much! I love this site!
Hi David
I didnt get another place to post my query so doing it under your reply.
I am a admin and now getting in Development requirements.One such is as follows.
1)During the lead conversion process we have several picklist fields that need to be mapped to several objects(acounts, contacts and opptys) and SFDC standard functionality gives us ability to map it to just one.How can i achieve that.My understanding is a trigger but i am not familiar with writing one.
2)On a case page we have 2 lookups. account owner and project owner.So whenever the case record type is project, the case should be assigned to project owner and in other cases to account owner
Any help will be great..Looking forward for a reply.
Thanks
For #1 you can simply create duplicate fields and map those instead. 5 minutes of time and you’ll be done!
#2 will need a trigger!
Hi David
#1 But those are picklist values and we need picklist to be retained.So if i just copy them i will have to maintain 9 Different Picklists.So one value is added in one picklist we will have to manually add them to 9 different places.
#2 Can i get a sample code by chance so i can work around it,I never got my hands on on trigger but now trying to learn them frm above tutotials and others.
Thnks for the help David.
Sounds like you need code then! Too far behind on content nowadays to debug code though!
All I can recommend is to read this post:
https://www.sfdc99.com/2014/02/22/debug-your-code-with-system-debug/
Hey David –
Thank you for your great work. People like you are a true inspiration for our community. I am a Salesforce Admin trying to become a developer. The effort and time you put into this site will help my dreams come true. Once again, thank you!
Best regards,
George da Silva
Thank you for the kind words =)
David,
Need some of your expertise. I am trying to do something very simple, a rollup of all closed won opportunities in 2014. Here is where I am right now:
trigger Rollup on Opportunity (before insert, after insert, before update, after update) {
AggregateResult[] results = [SELECT SUM(Amount) summary
FROM Opportunity WHERE StageName = ‘Closed Won’ AND CloseDate >= 2014-01-01 AND CloseDate <= 2014-12-31 AND Amount != 0 ];
System.debug('National_YTD_Sales__c'= + results[0].get('summary'));
}
The National_YTD_Sales__c lives on the opportunity but ultimately I want the value to end up on a Regional Quota object but I am just trying to get a trigger written and working and then worry about tweaking.
Awesome! It actually looks like you’re on the right track. Next step is to use the SOQL “GROUP BY” function!
Hello david,
I am new to the salesforce ..
Can you tell me what are the topics I have to learn for admin part
Thanks in advance
The following is my class but there seems to be an error. The error and class is below: What am I doing incorrectly:
MY CLASS
@isTest
public class PopulateContact {
static testMethod void insertNewAsset() {
Asset AssetToCreate = new Asset();
AssetToCreate.Name = ‘ZWave Smart Boiler and Hot Water Controls – Single Zone’;
insert AssetToCreate;
}
}
MY ERROR
30/06/2014 11:40
Class PopulateContact
Method Name insertNewAsset
Pass/Fail Fail
Error Message System.DmlException: Insert failed. First exception on row 0; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, PopulateContact: execution of BeforeInsert
caused by: System.QueryException: List has no rows for assignment to SObject
Trigger.PopulateContact: line 4, column 1: []
Stack Trace Class.PopulateContact.insertNewAsset: line 8, column 1
You have a trigger “PopulateContact” that is broken!
I think you do a SOQL query in it and the query returns no results.
Hi David .
I need Your Help in Salesforce .
Firstly I will Tell You What Exactly I want to do…….
1. I have two Object CLK And CLKchild in these two Object CLK is a master of CLKchild.
i Created a component which will be used in VF Page many times but can understand how to use in Vf Page.
The Requirement is i have to use jQuery to dynamically add this component in page i will provide a add button which add dynamically this component in Vf Page .
This Component Contain 10 Input Field so when the Vf page Loads initially this component show only one time bydefault and when the user click on add button it will again add the same component below the existing component so now total input fields are now 20.
I have a controller class of VF page on which all save functinality have to be written
so my main prb is how can i achieve this with jquery and how could i get the data from this component into VF Controller class when user fill all those component feild.
Please Reply ASAP
This is probably too large a topic and outside the scope of my help XD I recommend StackExchange instead!
Hi David,
I wrote this test class to update an approval process which gets updated on hourly basis. Unfortunately I am not able to reach the 75% code coverage to move it to production. My current code coverage is 50%. Any advice on this will be greatly appreciated. Thanks.
@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();
}
}
You can see which lines of code aren’t being covered by your test class after you run it – take a look, what usually happens is people forget to set variables and the code stops!
Hi David,
Just a quick question. Why cant we create classes for each object and just leave them. From then on we can just concentrate on create triggers. Am I right in thinking so or am I acting thick?
The other thing is about Private and public class. In your Webinars they have not been explained. Please could you throw some light on them.
regards
Lawrence
I’ll be talking about this in Chapter 8! You are on the right course Lawrence!
I am trying to populate contact lookup name and and id on asset
The trigger has no errors but I am sure its not working because when I created the Asset the contact lookup does not populate the name.
All the fields are standard fields
Please find my triffer below:
trigger PopulateContact on Asset (before insert) {
for (Asset NewAsset : Trigger.new) {
if (NewAsset.contactid != null) {
Contact AssetContact = [SELECT Id,Name FROM Contact
WHERE id = :NewAsset.contactid
];
NewAsset.ContactId = AssetContact.Id;
NewAsset.Contact.lastname = AssetContact.name;
}
}
}
Hey Lawrence,
In your code you make sure that the asset contact is populated, then you end up populating the asset contact with itself! So you have a self fulfilling prophecy thing going on there!
David
Also – if all you’re trying to do is populate the last name on the asset, then you can do is with a formula field instead of code!
Hi David
The asset is created from the account not from contact. So that’s the reason the account is a populated and the relationship created between asset ad account. Now I also wanted the contact to be populated too so the asset will be a child of account and contact
In that case this line of code will always fail (since the contact field is blank!)
if (NewAsset.contactid != null) {
So you should change it to this instead:
if (NewAsset.contactid == null) {
You should also limit your SOQL query to only 1 record, otherwise you’ll get an error!
Also, this isn’t necessary in code and should be done with a formula field instead:
NewAsset.Contact.lastname = AssetContact.name;
Hi David,
M going thru the Apex4Admins series, currently working on the 2nd webinar from the series – Build on Basics. I tried creating a sample SOQL query in Workbench (replicated the one that you showed in the webinar) but it throws me an error message:
Parent relationship queries are disabled in Workbench: Account.Name
Due to issues rendering query results, parent relationship queries are disabled by default. If you understand these limitations, parent relationship queries can be enabled under Settings. Alternatively, parent relationship queries can be run with REST Explorer under the Utilities menu without issue.
M using Workbench ver 29.0 and using my developer id to login to it. Any idea why am I getting this issue? Appreciate your help!
Click the Workbench icon then in the settings you’ll be able to allow Parent Relationship queries =)
Bingo! Works like a charm! Thanks a lot man :)
HI David, I have been reading your pages and took the seminars you recently did, but I have not figured out how to create a trigger based on a stage of an opportunity. It seems most have to do with the creation of something and not the update of a field. Does that make sense? We are basically wanting to create a new project board (custom object) when an opp is closed won with certain fields going over. Can you point me in the right direction?
he he he Chapter 6!
https://www.sfdc99.com/2014/02/25/comparing-old-and-new-values-in-a-trigger/
Hi David,
Not sure where to post this question so I posted here…
How do you get the Developer Console to remember all the logs and various settings? I noticed that when I close all the logs, pages, etc. and go back into the console they come back along with other settings that I changed!
Go to the “Debug Logs” section in Setup and you’ll be able to set a “Monitored User” which will save his/her debug logs for a while!
Hi David,
I am speaking on your ORG — when I was at the developer console the other day and I closed all the open log tabs then closed the console and returned, the logs tabs were there again. When I do that on my org the log tabs do not come back!
Or did I misunderstand what you where telling me?
Hehehe yup the Dev Console only logs things while it’s open, while the solution I mentioned logs things no matter what =)
You are the man David! Thanks again! :)
Hi David,
am a microsoft .net developer and wish to learn sfdc. i have completed learning sfdc fundamentals and the customization.
Need your suggestion for going ahead to code. i have a few apps built on .net and would like to integrate them to sfdc.
This is the place to start!
https://www.udacity.com/course/ud162
Pingback: Beginning my developer journey | sodakforce
Hi David
LIke you I’m completely self-taught (and not nearly as young:)). You are a big encouragement. I got my Developer’s certification about a year ago, and now (if I can find time) want to get Advanced Developer asap. I’m just ordering HeadFirst Java. I’d be grateful if you could point me in any other ways to get this knowledge expediently.
I also need to gain vf chops.
Thanks
Awesome stuff!!!
Force yourself to code! DEV 501 has plenty of Visualforce so you definitely need that under your belt. Luckily VF is easy-ish to learn once you have the fundamentals down in Head First Java. Standard documentation is plenty!
Basically find any excuse to code anything! You have all the resources you need to learn right now but not enough experience!
Hey David,
Hope you are doing good. Just a quick question on learnings from the first webinar.
My issue when i wrote a trigger:
In your trigger which you wrote, had 2 standard objects. What to do when you have 2 custom objects?
i am running the following trigger on Band object which would create a band member record. On band member object there is a field which looks up to the band. Both Band and Band Member are custom objects,
trigger Twitter on Band__c (after insert) {
for ( Band__c acc: Trigger.new )
{
Band_Members__c bandMember = new Band_Members__c();
bandMember.name = ‘xyz@dasra.org’;
bandMember.Twitter_handle__c = acc.Twitter_Handle__c;
bandMember.Band__c.Id= acc.Id;
insert bandMember;
}
}
this is throwing up the following error.
“Error: Compile Error: Invalid foreign key relationship: Band_Members__c.Band__c at line 7 column 5”
What do i do?? How do i get the correct id?
Change that line to this!
bandMember.Band__c = acc.Id;
Explanation: Band__c is a lookup field, therefore you must set it to an ID! No need to use dot notation and use Band__c.Id
Hi David, thanks..it definitely works.
Here i have got another question-
I have a multi select picklist field “type” both in child objects- Band member and Parent object- Band. Now i want to get the chosen values of picklist “type” in band member to the available values of the picklist “type” in band object. E,g: If type in band member has values {guitar, drum, vocal, base programming} and i choose guitar and drum here…so now type field in band object should show guitar and drum values only among the available values.
%Following trigger copies the entire picklist from child object to the parent object.%
trigger Updateparent on Band_Members__c (after insert, after update) {
Set parents = new Set();
for (Band_Members__c child : trigger.new) {
if(child.Band__c != null){
parents.add(new Band__c(Id = child.Band__c, Type__c = child.Type__c)); // Copying type from child to parent
}
}
if(!parents.isEmpty()){
List toUpdate = new List();
toUpdate.addAll(parents);
update toUpdate;
}
}
Can you please guide me what i should do?
It’s easy to change the selected values of a multi-picklist but it’s veryyyyyy difficult to change the possible values.
You’ll need to look into the Metadata API if you want to do so! It will be a nightmare to implement!
Hii David
Actually i m a marketing guy and now i left my job. Because i want to become salesforce developer. But i don’t know how to start and will i be able to do this. i am so confused. Please help me….Please!!!
I went down the exact same path! (You can read more in the About Me page)!
Start at the beginner tutorials and you’ll be a developer in no time!
https://www.sfdc99.com/beginner-tutorials/
hiii david…
this is sreenu….actually i don’t have any coding experience.i want become a good programmer.please help me.how to i learn programming in simple way..what books are reffered…please tell me…i am waiting for your reply…
This page has everything you need to know, let me know if not!
https://www.sfdc99.com/beginner-tutorials/
Hi David,
sorry! to say this i think i am enough prepared to write trigger on any task but the problem i face is that the code length whereas other experts take 10 line of code and i take 20 for the same task can you help me out from this. so that how can i make my code short and best??
That will come over time! Try to read other people’s code and you’ll learn what shortcuts they use =)
Shorter isn’t always better – the best code is the one that’s easiest to understand, even if it takes 10 more lines of code!
Thank u!! David
Hi David,
Thanks for the reply. I did this with the workflow, but now want to do this through code.. just to improve my coding skills and my knowledge.. I’ll just look into things deeper now..
Thanks
Hi David,
Can you help me with this. I need to write a trigger to create and assign a dummy task to account owner on account creation if reporting country of account owner is India…
(The account owner’s reporting country is a tricky part for me) :(
Thanks
You can actually do this with a workflow – no need for a trigger!
Try to figure out what “reporting country” means to you – imagine you’re a computer and only understand basic inputs!
Hi David,
Your site is a great help, I am a beginner and this really helps.
On the Developer Edition I would like to add Quotes as an option on the Tabs at the top, cannot find out how to do this. Can you please let me know how I can do this.
Thank you
Barry
There is no standard Quotes tab =) You simply create them from the Opportunity!
Hi David, this is really great information that you have put together. I come from a Java background and this really puts it in a great perspective how you can learn SFDC in more efficient manner. Couple of questions that I have.
1. Do you use Eclipse? If so do you recommend using it?
2. How can we setup source control for SFDC?
Thanks,
Justin
Most of the time I do use Eclipse! Nowadays though I find myself using the web ui or developer console more and more. They’re getting much better each release!
A lot of companies use source control (git, etc) but a surprisingly large amount don’t =) Salesforce doesn’t do it out of the box so most companies just override their code over and over! Haven’t set it up specifically but I would be shocked if there wasn’t a good tutorial on it somewhere on the web =)
David
i believe you said i should not worry about the webinar if i am going through the chapters right? or should i stop and watch webinars that you have posted. sorry if i asked this before!
Immerse yourself in code =) You will learn things in the webinar that are not taught on this site, and vice versa! The small time investment will give you lots of ROI!
david, can i use your free account to do your chapter exercises? also, if i wanted to just use the code you do in your chapters i would just kinda copy that code and just paste and see if it runs just like you show in your examples right?
last question is sandbox. do we as developers have to create a sanbox or is it created for us. i kinda don’t understand where a sandbox is and how to get there etc. the only thing i ever use is a freed developer account on the free trail. i am plowing through your chapters as i stated to you =)
also when you deploy you have to do inbound and outboud change sets right? you can just do change stets by using setup menu and then hitting deploy on whatever you have done in your sanbox.
getting this terminology down is my desire. like what is environment vs org and what is test org etc? I saw your video series and i would like to commend your work! keep it up sir! i hope you become super successful!
thanks!
Take a second look at Chapter 1 – all these things are covered Sen!
Hi David,
When will be the webinar video of May 15th session is available?
Hhhmm don’t know yet but I’ll ask the crew when I see them this week!
Thanks.
Hi David,
eagerly waiting for your next post on object oriented thinking.i learned triggers by practicing ur 1 to 7 chapters.now in the market who knows vf pages n triggers are getting jobs quickly.iam a jobseeker in sfdc..so plzz post those lessions if u find free time.thanks alot for ur support.this is the best site to learn sfdc till my all searches.so plzz try to post early…
Thank u David.
Well done!!!
If you haven’t already read the book, give Head First Java a try as it’ll teach you object oriented thinking!
Going as fast as I can hahaha
Hi David
I’m a Java programmer but interested to learn Apex. Do I still need to read this book?
Thanks
Java programmer – no need for the book, jump right in!
Hi David,
Hi Ofelia =)
YOU rock man! My Java book is arriving tomorrow and I will be reading away and taking be on this site all weekend! Quick question, will you have something for us to become a developer of VisualForce? I understand it can use HTML and or Javascript?
Visualforce is coming up right after I talk about something even more important – object oriented thinking!
Hi, firstly thanks so much for creating sfdc99, what a great find!
I’ve just started looking at Apex today as I need to go beyond the point-and-click adventure I have had so far with Salesforce. Working for a UK charity with no budget means I am reliant on self education and this site has helped enormously, but….
At the risk of preempting Chapter 9 I have a specific requirement and I’d appreciate your comment on my proposed solution:
We have a thriving web site (www.nfm.org.uk) with a web form to allow prospective clients to self-refer (referral form). Currently that form gets emailed to the admin team and copied into Salesforce. The form software can write directly to Salesforce so I set up a custom object to receive the data (Web_Referrals). Now I need to copy that data to 2 existing objects to create “Case” and 2 “Clients” linked (master-child) to that Case assuming the data is ok.
So I thought just stick a custom button on the Web_Referrals detail screen, write some Javascript to call an Apex class/method. I’ve written some dummy code to emulate creating a case but cannot work out how to reference the Referrals fields in the Apex code.
Am I going about this the right way? I’ve google’d it to death but cannot find the answer so any tips/advice/pointers to other resources would be welcomed,.
Javascript:
{!REQUIRESCRIPT(“/soap/ajax/15.0/connection.js”)}
{!REQUIRESCRIPT(“/soap/ajax/15.0/apex.js”)}
sforce.apex.execute(“createWebReferralCase”, “createNewCase”, {});
window.alert(‘Case Created’);
Class:
global class createWebReferralCase
{
WebService static void createNewCase()
{
Mediation_Case__c caseToCreate = new Mediation_Case__c();
// add some data
caseToCreate.Name = Web_Referral__c.C1_Last_Name__c; // doesn’t work!
caseToCreate.Referral_Date__c = date.today();
// insert the new case
insert caseToCreate;
}
}
Please ignore this, I did find the answer eventually via the developer forum. I enjoyed the first webinar yesterday, very inspiring.
hii david,
i am beginner in salesforce, i want to ask u 1 que.
can we convert read only field instead of required field in standard field through page layout??
You sure can – just need to lock the field on the page layout editor! Depending on your use case you can also use a validation rule.
Hi David!!! I just finished your tutorials a couple of weeks ago, they are amazing!!! Thank yo much.
I was wondering if you can answer me a question… is it possible to access an “apex:inputHidden” on a VF page from the controller??
Yup should be possible but need to understand your use case as there may be a better solution!
For those who are very new to the Salesforce.com , You can refer Salesforce Fundamentals Help document here : http://www.salesforce.com/us/developer/docs/fundamentals/index.htm
I found it useful, thought to share :)
Thank you Nitin for sharing!
Hi David,
I have worked as a windows admin.When I came to know about Salesforce and its development and demand,I want to become a Salesforce developer like you.I want tom follow your path for that so I have started you steps.I want to become Salesforce developer this summer and want to participate in this year’s Dreamforce Event.Please guide for my dream.
This guide is all you need Srinivasan!
https://www.sfdc99.com/2014/04/28/step-by-step-guide-to-becoming-a-salesforce-developer-this-summer/
Hi David,
In everyone’s mind there will be a doubt when to use before vs after triggers.the way u expalined is excellent .i dont have words to tell, how much these lessions r helping me and building confidence in me.
i have so many doubts in apex classes and vf pages.if possible please write those lessons also…as they r most imp in interview point of view.
Thanks in advace.Thanks alot for ur tutorials.
Thank you Gousia! YOU CAN DO IT!!!
Apex classes are coming up next!
The Visualforce!
Then… how to get a job!
David
Another question sir…
where can i practice code? like when i see your tutorial and i want to copy and get same results? is it the inline editor in the free developer environment for visual force pages?
can you tell me steps how to start using a vf page? create a class , create a controller etc? I heard most people use inline editor once you create a page to code? some people said developer console? i have no idea what that is?
some terms if you can clarify
what are classess? public? private? test?
what are governor limits?
what are standard/custom controller? how do you create both?(sample code)
lastly i don’t understand the bracket usage for code( sorry i am really new to code)
in general when you type a line of code do you put opening bracket like this “{” and closing bracket “}” that ends one line of code? some of those brackets confuses the heck out of me. i forgot the rules. I also don’t understand the little “.” and other stuff in the lines of code. it looks alien but i will try to grasp it. i am trying to learn some in thatwebsitecalled ww3schools for beginners.
bear with me i only have two more questions i will ask you and then try to tackle myself.
I apologize for the inconvenience.
you rock! I would like your autograph one day for being a coding hero!
Sen
Some of these questions are way too advanced for you to worry about right now hahaha. Once you’re comfortable with topics in chapters 0 – 7 you can begin researching these things!
Think of brackets as simply layers of code. You’ll become more comfortable with it as you go through the chapters on this site =)
P.S. things like Javascript, HTML/CSS, and other technologies on w3schools aren’t really helpful for learning Apex! You have to learn Apex before learning Visualforce (otherwise you will be really confused, which is probably why you’re pretty confused right now). Then, while learning Visualforce, you should learn HTML/CSS. Javascript comes after that =)
Go get em!!!
David
David i think i will do this. I will follow what you say rather than asking questions.
so let’s do this step by step.
first step is…
do chapters 0-7? correct? i will be able to grasp this without that javabook? the only reason i showed those video is because i can’t but that java book and i need to start some learning and not waste timeetc.
so anyway, say yes/no to the step i mentioned and then we will do next step. like that you can guide me and i won’t ask anything else until i complete that step.
do you like this idea sir?
Sincerely,
Sen
hahaha yes Sen! And no need to call me sir, I am simply your friend who is still learning as well =)
Thanks. I will contact you after i am done with chapter 7. would that be enough knolwedge to start as a noob developer in a company ? =) Is your webinar about these chapters? should i watch it or continue with this stuff as you suggested.
Chapter 7 is more than enough to be able to write 95% of triggers!
The webinar will not go into that depth however you will learn many of the intangibles!
Hey i am trying to get a job as a salesforce developer.
here is my background: i just played around a little bit with free developer environment and did some basic stuff like create custom objects and some apps. I don’t know much about admin stuff. I am just learning javascript and trying to remember html.
here are my questions….
1) i know you need javascript for apex and i really don’t have much time to for a book so i am using this link(please look at it quickly). do you think this is good fro me to move ahead to apex guide you have from chapter 0? I mean i don’t have much time and i think i can pcik other stuff on job. also is html used for apex? what about css? would i have to learn these as well to understand the code you write in apex for salesforce?
2)as far as admin goes like i said i only played around with basic stuff like creating accounts etc. i know you gave a link to what admin concepts we need before we code. would watching those short 2 min salesforce videos on all the areas you gave in your link be enough? again i am trying to get job in three weeks and don’t have much time. how much admin stuff would we really need as developer? i mean i don’t see it as a prereq for developer and we don’t use it on our job correct? i certainly don’t know anything about territory management and currency management etc. would we need this?
3) lastly if i follow your guide from chapter 0 to the bottom would i have adequate skills to go as entry level developer? i am using your beginner tutorial to prepare i have no previous code experience and not much admin experience.
am i fool for trying =)
thanks for your help!
Sincerely,
newbie
Hey Sen,
I totally understand that you want to learn Apex as quickly as possible. That’s why I made this site – so that you could focus on just the important lessons and avoid all the unnecessary stuff.
Check out this post for a step-by-step guide to learning:
https://www.sfdc99.com/2014/04/28/step-by-step-guide-to-becoming-a-salesforce-developer-this-summer/
Please, I beg you, put in the time to study and don’t take any shortcuts. The only person you end up cheating is yourself! You can be a developer by the end of Summer. That’s really quick and it’s going to change your entire life! 5 – 10 hours a week for a few months is all it takes.
Resiliency is your #1 skill as a developer!
https://www.sfdc99.com/2014/04/23/what-is-resiliency/
Life is all about priorities Sen. There are going to be times where you’ll have to prioritize learning code versus having fun, hanging out with friends, partying, etc. The small choices you make in these scenarios will add up over time and determine where you end up in life!
I will help you every step of the way Sen. But I can only point you in the right direction. Study. Work hard! Help me help you! I believe you can do it =)
David
Pingback: Salesforce Developer Skills Lead to Dream Job - SkyOffice Consulting | SkyOffice Consulting
Hi david,
This is Srinivas,May i know how to create a field in an object by using apex tags..? u understand my question right—>creating fields to an newly created object..Thanks in advance.
Thanks,
Srinivas
Hi David, Amazing posts…wished, all the topics you mentioned above was covered.Waiting for them to come in future is a bit painful.But, thankx for all the “Hard” effort you are putting in explaining u’r followers on this site. I have a basic question related to deployment. When deplying from Sanbox to Production we need overall coverage of 75% minimum. Is this code coverage limit same for Sanbox to sandbox org. Or we can deploy without 75% overall code coverage.
Time flies =) I still remember struggling to write the first chapters a few months ago, and here we are today!
Focus on learning the concepts up to Chapter 7 very deeply! The rest is easy =)
Sandbox to sandbox doesn’t require any code coverage, so you’re good to go!
David
Hi David,
Gud morning….
I am new bie to salesforce – planning to learn salesforce seeing the job market is high. But i dont know programming so was wondering what percentage of programming does salesforce developer course includes .
I am worried if this is right choice to choose salesforce as career can non programmer learn the developer course.
please provide ur inputs. will be gratefull.
awaiting for the reply!!
Thanks
Check these posts out!
https://www.sfdc99.com/2014/04/15/dealing-with-doubt/
https://www.sfdc99.com/2014/04/17/hard-work-beats-talent/
The market is HOT and anyone can learn no matter what their background is!
Great stuff… You must be a mind reader just starting out as a salesforce developer the market is defo hot.. Hope you the the last few links added. Thanks mate
I am often told that I am hurting my own job prospects by increasing the competition against me in the industry!
I’m just happy to make a difference!
Hi David
This is a wonderful website for beginners like myself , i have followed the steps mentioned in here and have managed to successfully run the test class, but my question is , how do i put this code in to use, i mean in real time , like when the class is executed new user should be created,i am using the free developer edition and don’t have access to sandbox.
Really appreciate your efforts.
Thanks in advance.
If you have access to an Enterprise Edition of Salesforce you can deploy it using the steps in this chapter!
Otherwise you can’t deploy from a free developer edition! Don’t worry though, that part is easy so you’re not missing out!
David
Hi David,
May i Know how to create radio button???please let me know that…thanks in advance..
Here you go sir =)
https://www.salesforce.com/us/developer/docs/pages/Content/pages_compref_selectRadio.htm
sir,can’t we done without apex tags????
hai mate,
actually i have a query can u pls help me.
my question is how to represent the campaign lookup field in lead can u pls tell me the api name of that.
Here you go =)
[SELECT Id, LeadId, CampaignId FROM CampaignMember WHERE LeadId = ‘0123456789’];
If you must do it from Leads:
[SELECT Id, (SELECT Id, CampaignId FROM CampaignMembers ORDER BY CreatedDate ASC LIMIT 1) FROM Lead WHERE LeadId = ‘0123456789’];
Go get em!
David
hi , i am new to sfdc, this blog is v helpful..but i can see only 7 chapters, to see chaper 8 do i need any extra privilege or it is yet to be posted??
Still working on writing them Hima (sorry!). I usually write 2 – 3 posts a week!
HI, David. Thank you for sharing your knowledge in such an easy to understand form. I get excited whenever you have a new entry up.
Glad you enjoy it Xavier, I believe in you!
David, I am new to salesforce development and have been tasked with keeping an existing ERP systems Contacts in sync with any new contact entered into to Salesforce. Can this be accomplished with an After Insert trigger and would this be the best approach for such an operation? Thanks, Tony
An after trigger could certainly do this, but this project is much bigger than you might expect!
Integrations are best left to tools like Boomi:
http://www.boomi.com/
I would only recommend coding your own integration if you’re very comfortable with code, IE coding chapter 7 triggers in your sleep!
Hey David, please feel free to shoot me an email of your chapter drafts if you want any help with text editing, code scenarios, or just a second set of eyes. Keep it UP!!!
Thanks Matt I will keep you in mind!
What are Schedule classes or Scheduled batch jobs?What is its use?
Hey Sanjay,
Sometimes you need to make large database changes that aren’t possible due to the Governor Limits in a trigger.
For example, you might have an integration with an external system where all records need to be synced at least on a daily basis. You couldn’t do this with a trigger because you’d run into a 50,000 record limit. However with batch Apex, you have much larger limits and can do this no problem!
Since you wouldn’t want to manually call your batch Apex every night, you’d use scheduled Apex to automatically call your batch Apex every day.
Hope this helps!
David
Got it!Thanks for your valuable comments.
Another question regarding test classes and code coverage.
Ques:
1) what are test class?
2) what we write in test class?
3) what is the need to write them?
4) how they actually work?
5) how we increase the code coverage if less than 75%?
Note:I know the theoretical concept that tells us that if code coverage is more than 75% then u can upload that class from sandbox to prod.Can you please clarify more!
Regards,
Sanjay
Hey Sanjay,
You definitely want to check out this post!
https://www.sfdc99.com/2013/05/14/how-to-write-a-test-class/
You can look at the “Extended look” link at the bottom if you want even more detail =)
The 75% number is simply a random cutoff that Salesforce chose. In a lot of cases it’s impossible to reach 100% code coverage. For example, you might have a trigger that runs 1,000 different scenarios depending on certain conditions. To test all 1,000 would be crazy, so Salesforce lowered it and make it only 75% of all possible lines of code.
If your coverage is under 75% it simply means at least 25% of the lines of code in your trigger never ran. You’d need to write more tests to make those run!
Hope this helps!
David
Test class
Thanks Bro!
David ,can we design a complete website using Vf coding (Vf pages combined together) and is it compulsory,if i have designed it for my customers,they also have login first in salesforce then they can access my site.for e.g-i run a grocery store ,i want my customers to purchase grocery online using my website and i have designed a website using VF pages and apex classes and i want my end users to access it.is it possible,if they can access it across internet and no need to login first in salesforce.?Please explain.
thanks
Hey Sanjay,
I know this is definitely possible however I have no experience in this area! Try Site.com perhaps!
David
The page gets refreshed everytime ,i click on Sum Button.I want that page should not get refreshed when i hit for Sum Button,what changes shall i make.
My class looks like:
public class AddNumbers
{
public integer a{set;get;}
public integer b{set;get;}
public integer c{set;get;}
public void add()
{
c=a+b;
}
}
VF Page
Regards,
Sanjay Kumar
Hey Sanjay,
Visualforce code in comment doesn’t render well!
Without knowing your code, what you probably want to do is add a rerender element on your command button. The rerender should point to the outputpanel containing your “Sum” field.
Good luck!
David
Hi sanjay ,
read the below.
A button that is rendered as an HTML input element with the type attribute set to submit, reset, or image, depending on the tag’s specified values. The button executes an action defined by a controller, and then either” refreshes the current page”, or navigates to a different page based on the PageReference variable that is returned by the action.
IF you don’t want to get the page refreshed then u might use the “HTML input button”instead of apex:button
Thanks!
The page gets refreshed everytime ,i click on result Button.I want that page should not get refreshed when i hit for result, button,what changes shall i make.
My class looks like:
public class AddNumbers
{
public integer a{set;get;}
public integer b{set;get;}
public integer c{set;get;}
public void add()
{
c=a+b;
}
}
VF Page looks like:
Regards,
Sanjay Kumar
David thank u so much, i just started learning and i am feeling so confident now.
when will you update chapter 7 waiting for them. eagerly waiting for the integration part.
ooo baby glad you’re enjoying it – tell your friends!
I finish about a chapter a month, so a few months from now hahaha.
After 6 lessions how to learn all remaing lessions?????
Hey Jenish,
I haven’t yet written them =(
David
Sorry, it seems the tag got missed out:
‘ ‘
Hahaha my site html encodes all comments, so you need to type:
For <, type “& lt ;” without spaces
For >, type “& gt ;” without spaces
Hi Yaniv,
As far as my understanding on #9 goes, Salesforce does some native rendering automatically once you access the application from mobile (Salesforce1). For that you need to enable some options in your settings (mobile settings, Salesforce1, etc).
Apart from that, when you create VF pages, you will see an option (checkbox) to enable it for mobile rendering as well (since VF pages are customized, so standard SFDC mobile rendering will not apply for them unless you select that checkbox).
Also I found some device level tags like below that you can use:
Also, you can trim off the header and the sidebar from your VF page for better viewing in mobile.
I’m sure there are some more details, just do some googling and you will get it.
Let me know if it helps!
~Ayan
Thanks for the assistance Ayan!!
Hello!
I’m a developer working in SalesForce. Thank you so much for this site! I generally find it difficult to get decent help with developing in SalesForce, but your site is amazing! Thank you!
My pleasure Bernard! Very exciting announcement about the site coming up!!
Hi David,
Your Site helped a lot.Thanks for guiding!!
Want some sites or materials from where i can study -to pass ADM201?please help!! The sites I found were 2-3 years old so will not help me with current exam since sales force updating every season.
Hey Athena,
Check out Quizlet.com and search for flashcards related to ADM201! I passed four certifications studying almost exclusively off this strategy.
David
Thanks:)
Hi David,
I have a requirement that through custom VF page i am editing Account information like Account Name, Account Owner,Parent Account etc.
So I have created a Custom VF page but now I want to add condition to display different fields based on the Account Record type.
AS their are two record types in Account :
1) Person Account: In this type of account ‘First Name’ and ‘Last name’ is required.
2) Business Account: In this ‘Account Name’ is required.
So I want to display First name and Last name when admin select Record Type =’Person Account’ and display ‘Account Name’ when admin select Record Type =’Business Account’. in VF page.
The “rendered” tag is your best friend here =)
Example:
Hi David,
Could you please give some examples on rendering or some sample code.As I am new in SFDC.
Oops – darn commenting system hid the example!
Example:
<apex:inputField value=”{!account.FirstName}” rendered=”{!account.RecordTypeId == ‘1234567890’}” />
Hi David Liu,
i am Yaniv myself, appreciate your work here.
i would like to know some details mentioned below.
1. What is Standard Set Controller. In which scenario it will use?
2. What is the purpose of Grant option in OWDs?
3. How to control the Workflow actions in Triggers?
4. How to load both the master and detail records at a time into database using SOQL query?
5. How to create Wizards in Salesforce?
6. What is the admin permission exist in PROFILEs to enable/disable DEBUG MODE option?
7. How to upload documents using Data Loader?
8. What is OAUTH and purpose in Salesforce?
9. What are all the changes needed in Visualforce pages and Apex classes to convert a web application to a mobile application?
10. What are Analytics in Salesforce?
i am thankful for your valuable response.
That’s a lot of questions Yaniv – very curious where they came from!!
Maybe some of these are good interview questions, hahaha.
Anyway, I can’t help you with all of them but the good news is you can probably Google most of the answers. I wrote a sweet post of #4 though check it out!
https://www.sfdc99.com/2013/06/24/example-how-to-write-a-cross-object-soql-query-part-2/
David
Hi David Liu,
Your guess is correct. I am looking for new opportunities and mentioned are some of the Qs I faced. Sure that I will get answers from Google for all. Need your help for below mentioned 3 questions for which i didn’t find correct one.
5. How to create Wizards in Salesforce?
Per my understanding, can write VFPs that resembles Wizards in execution. But there is no direct option in Salesforce to create Wizards. Please correct me if I am wrong.
6. What is the admin permission exist in PROFILEs to enable/disable DEBUG MODE option?
Per my understanding, there is no option or administrative setting in PROFILE to enable/disable the debug mode.
9. What are all the changes needed in Visualforce pages and Apex classes to convert a web application to a mobile application?
Thanks for your valuable response.
Best of luck in your interviews!
5. You can use Visual Workflows without code!
https://help.salesforce.com/HTViewHelpDoc?id=vpm_admin_flow_overview.htm&language=en_US
6. It is on the user detail page: “Development Mode”
9. Never done this before so can’t give a good answer sorry!! My guess is very little!
Hi David,
Currently I am working as Testing engineer. I am planning to learn salesforce development. Can you please guide me how to start with sales force.
Please Thanks in advance….
Are my beginner tutorials insufficient for your needs? =(
https://www.sfdc99.com/beginner-tutorials/
If so, let me know where it’s lacking so I can write those guides!
David
David, I just want to say I love the site!!!! Thanks for ALL your help!!!
Love you guys too!
David
Hey David,
I am functional admin trying to get into the development realm. Having a tough day at my job where I have to
1. Hide a Contact Name custom field on opportunity object on the detail page
2. Based on the Contact name I have to create a Contact Role on the Opp marked as primary and set a role
3. Create a contact role on opp when its created from the Contact Object
Now I know for the first one I need to create Visual force page and add to the standard opportunity page layouts. However, I have never written a VF page before
and I need some direction in the next 2 as well.
Please help! I have started writing beginner level code (triggers) thanks to you, but I think the abov eis way beyond my understanding right now. Please privde some direction as to where and how I should get started.
Thanks
Best,
Hamed
Hey Hamed,
This stuff sounds like it can be done without code!
1. Remove the field from the page layout
2 & 3. Only allow opps to be created from Contacts – this will automatically add them as a Contact Role on the opp as a primary contact! You can even write a trigger to move this along further!
Hope this helps!
David
Hi, I am Very new to SF… I need to do automatically convert lead to opportunity. If contact is not exist we need to create new contact, if contact is exist we need not create contact, and this lead automatically convert into opportunity.
Please provide trigger code for this solution.
Thanks in advance.
Check out these two links to help you out!
Lead conversion:
http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_dml_convertLead.htm
Deduping:
https://www.sfdc99.com/2013/10/19/example-how-to-write-a-deduping-trigger-for-leads-and-contacts/
Hi David,
I have taken below this code form net.
trigger ConvertLead on Lead (after insert, after update) {
for (Lead lead : Trigger.new) {
if (lead.isConverted == false) //to prevent recursion
{
Database.LeadConvert lc = new Database.LeadConvert();
lc.setLeadId(lead.Id);
String oppName = lead.Name;
lc.setOpportunityName(oppName);
LeadStatus convertStatus = [SELECT Id, MasterLabel FROM LeadStatus WHERE IsConverted=true LIMIT 1];
lc.setConvertedStatus(convertStatus.MasterLabel);
Database.LeadConvertResult lcr = Database.convertLead(lc);
System.assert(lcr.isSuccess());
}
}
}
this is converting lead to opportunity but not immediately. After adding lead this code executed and ” Converted Lead ” page showing with contact, account and Opportunity values. After clicking this value only this record move to opportunity.
Why we need to click, after that only record move to contact , account , opportunity. I need auto convert.
Please advise.
Hey Jameel,
So the Lead is actually converted immediately after you create the lead – whether or not you click any links after that!
What happens is that Salesforce tries to navigate to the lead after the trigger finishes, and that goes to the page with links to the Account, Contact, and Opportunity. This is something you can’t change unfortunately! Triggers also cannot force a user to go to a certain page after it runs – only Visualforce can do this!
So your options are to either let it be as is (lead gets converted but landing page is not ideal), or, build a Visualforce page to redirect the user to the Opportunity! I recommend the former option since it’s a lot simpler!
David
Thanx bro.. Ll try that now
Hi David,
Just wanted to leave a quick message of appreciation, i am also a ‘Junior dev’ and still learning the ropes, you have covered a lot of core information which is great, I have recommended this to many colleagues and will continue to do so!
I look forward to chapter 9!
My pleasure Kay, thank you for commenting!!!
David
Hello David
I just started my coding on Apex. I have a problem in accessing ProductFamily, which is a pick list from the Visual Force Page. I have written the Custom Controller. But Still I am not able to get my ProductFamily fields in the picklist. Its null and I am getting null pointer exception.
My COntroller is as follows
public without sharing class UserController
{
public List UserTemp = new List();
public UserController()
{
}
public List UserList
{
get
{
UserTemp = [Select Name, ProductCode,Family From Product2];
UserList = new List();
for(Product2 temp : UserTemp)
{
UserList.add(new SelectOption(temp.Family, temp.Name));
}
return UserList;
}
set;
}
}
and My Visual Force Code is as follows
It would be really helpful, if you could help me out please.
Thanks and Regards,
Pavan
Here’s my advice!
Try hardcoding Family values first just to see if it’s working at all!
If it’s not, you know you’re not accessing the data correctly with your Visualforce.
If it is, then there is something incorrect with your SOQL query! Try doing your query in a tool like Workbench to see the output!
Hope this helps!
David
I tried that bro. Now using the standard controller to display the picklist values. But after I choose a picklist, one more list should be displayed, based on the selected value. I am not finding how to do this.
Regards,
Pavan
Liberal use of the “rerender” attribute Pavan!!
Thank you so much Bro.
Regards,
Pavan
My pleasure Pavan way to go!
is there really demand for simply admin people in the market? feel like people want developers or admins who code etc? would i be able to get a job as simply admin. i mean i can learn code later if i want on my own time but i feel like focus on one thing at time you know?
I agree that’s it’s best to learn the admin stuff first. You cannot be a good developer without being very good as an admin!
Market for both right now is hot but it’s a little better for devs. In the end, you need to choose what you enjoy the most, because you’ll be spending 40+ hours a week doing it!
Thank you for your patience and your kind and informative responses! I wish you a good 2014 my friend!
Hey!
sorry! absolute last question!
i can’t seem to find the checkout enabled box for my user detail page. it told my to give manage billing permission first and i did that at my sys admin profile but then when i wen to my user detail page the checkout enable box is not there.
this checkout is to allow user to purchase additional license as you know.
info
i am using free developer account. license is salesforce.
thank you and sorry for the questions!
I believe that checkbox is only for paid Salesforce orgs =)
last question
what is a org that you refrred to? is org the company you are hired and working with?
also with regards to code…..
i barely know it or code stuff and am going fro admin right now.
Do i need sql/soql query languages for admin work or does that come later when i become a developer etc? what is the breadth of code needed for admin work? i assumed business logic like workflow, validation rules would be enough. i guess conditional statements like basic if then statements are all you need. i am assuming apex library and java not really needed? i was told you need triggers along with everything i stated.
planning on go for developer after admin so i have asked you.
Thanks again!
Sincerely,
Zen
Hey Zen,
An org is simply the Salesforce that you are logging in to =)
No need to know Apex, sql/soql, or triggers if you simply want to be an admin! Zero code and zero code reading! 90% of people are simply admins!
David
what exactly is a instance?
when you enable things for users you do that at the profile level and all user to that profile have those right? you don’t need to go to each user to enable that etc? it is only when you want to give some users special access you use permissions correct and then you go to that indvidual user?
also, when you use permission do you need to first use a permission set and assign a user to that set and add the permission or no? I also think you don’t need permission set licenses for every permission?
lastly, how do you add user and feature license s to users? do you just do that at profile level or do you have to click on user or when you create a new user and assign that? for feature it says click users etc. basically i am confused what to add on prole level vs go to a user specifically for?
also are feature licenses related to user licenses or a part of them or separate? I hope my query was clear! I am studying for the company profile aspect of the admin exam.
Thank you so much!
zen
Hey Zen,
An instance is your Salesforce that your users log in to!
Profile permissions are shared across all users!
Permission sets are if you want to assign a permission to just one person!
Feature licenses are per user!
David
hello
Hi =) I get a lot of spam comments so I need to approve all comments before they show up! I promise I’m reading!
Hey i just wanted to clarify some terms
what is a
org?
environment?
instance?
sandbox?
production
deployment?
i have a free developer environment account from developer force and that is the only thing i know. can you put these terms in your own words and relate them to mu free account so i can understand? thanks =)
also do admins need lot of sql stuff or just apex triggers?
Org – your Salesforce instance!
Environment – Same as org!
Instance – Same as org!
Sandbox – a type of org that is a copy of your “normal” instance but has no records. Good for practicing!
Production – your normal Salesforce org that your users are using!
Deployment – migrating things from sandbox to production!
SQL/SOQL is critical to writing triggers, almost every trigger will use it!
Dear David,
I need to create the following task only with trigger:
1. There is a Custom Object A with two child objects A1 and A2.
2. Each child objects has a mutiselect picklist field.
3. A1 has picklist values like food, beverage and whereas A2 has
picklist values like food, games.
Task: Whenever we select all picklist values of Child objects A1 and A2 ,the parent object A must populate all value of child records and it should be only unique values of child picklist value, for example, if I select the all the value of multiselect picklist of both child objects A1 and A2 then A parent object must populate food, beverage and games only not food twice.
I need this task to be completed only with trigger code, please provide the solution for the problem.
I
Hey Piyush!
Here’s how to tackle the problem:
1. Create a trigger on the child object
2. In the trigger, traverse to the parent object and query all child objects
3. Loop through the child objects and add the picklist values to a Set (to prevent duplicates)
4. Update the master picklist on the parent object
Best of luck =)
David
Dear david,
Can you please make me understand through coding, it will
be really a great help ,I am totally new to triggers.
Thanks
Regards
Piyush
Hey Piyush,
My best suggestion is to get this Java book to ramp up quickly:
https://www.sfdc99.com/2013/05/20/the-best-way-to-quickly-learn-how-to-code-in-salesforce/
Then go through each chapter here one by one – you definitely have the tools to do this once you get up to Chapter 5!
https://www.sfdc99.com/beginner-tutorials/
When you’re ready, post your code and I’ll do my best to help debug!
David
Congrats David on you Becoming an MVP.Your contribution to the
community is amazing and i wish you all success in your future
endeavours.
Thank you so much =*) This means a lot to me!
Hi David,
Can you please explain the concept of Batch Apex with a simple example.
Regards,
sfdc novice
Batch Apex lets you run and schedule huge coding jobs!
You’ll want to use batch apex if:
– You need to schedule something to run at a specific time on a repeating schedule
– Governor limits prevent you from doing the mass calculations you need in a trigger
I used this to learn how to do batch apex =) It’s pretty good!
http://developer.force.com/cookbook/recipe/using-batch-apex-to-reassign-account-owners
I’ll have a series on how to do batch and scheduled Apex in chapter 9!
David
Nice post and it made me confident on salesforce by reading your all articles
Good job Prasanth, hope you continue to have a great Salesforce career!
Thanks a lot for the material you provided bro.Yesterday,i cleared a interview for the tier 2 developer support for salesforce,now i will appear for next round by 1 feb in which they will ask me about force.com platform and visual force pages and coding part.if i will find difficulty while studying that in next 15 days,i ll surely ask for your help.thanks a ton……..God bless you.
Woohoo!!! Congrats on passing the interview!!!
Best of luck on your next round – if you need any advice, you know who to talk to!
David
Hi David,
I have a merchandise object and line item object……when I place an order via a line item record, the merchandise inventory should get reduced accordingly. Can you help with this.
Thanks
sss
Hey sss =)
You’ll need a trigger for this!
First, your trigger needs to detect when an order is placed (hard part):
http://blog.jonathanbroquist.com/using-trigger-old-trigger-new-to-detect-when-field-values-change/
Then, you’ll need to do a SOQL query for the particular Merchandise object and reduce its inventory (easy part):
This tutorial does something similar: https://www.sfdc99.com/beginner-tutorials/#soqlTrigger
Hope this helps, let me know if you need more guidance!
David
Hi David,
Can you recommend me some material for administrator part.i am working on sfdc for last 1 month.i am developing my app. in my developer org. for a school.i have used custom objects,custom tabs,custom fields,designed profiles and roles as well.used master-detail and look up as well.its really interesting,i think atleast for 6 months ,i should focus on admin part bcoz there are lots and lots of things such as workflow,approval process,junction obect,time based work flow,much more to undrstand and then i should jump into developer part.
1.So ,can you suggest me some material for admin part.
2.Can you explain me what is Record Type.
This one’s by far the best tutorial I’ve seen for the admin side of things! It covers everything you’d ever want to know!
http://bit.ly/1bge5A3
Additionally, here’s a free course that’ll help you get started on the admin side:
https://www.udacity.com/course/ud162
Think of record types as categories. For example, you might have a record type category for “Public” accounts and “Private” accounts. The biggest advantage of record types is that you can show different fields for each record type. For example, “Public” accounts could have a field for “Stock Price”, while “Private” accounts wouldn’t show that field.
Hope this helps!
David
Hi David,
Can you please explain the concept of email services with a simple example.
Regards,
sfdc novice
No worries SFDC novice, I’ve added this to the tutorial to do list!
In the meantime, you can check this page out for an example:
http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_forcecom_email_outbound.htm
David
Hi David,
Can you please explain me the difference with real world example for Workflow and Approval Process.
for e.g student(object) issuing a book from library(object) with date of issue and date of return fields. if student returns a book after 2 days ,he should be imposed a fine of $1 every day till he returns.So,will the workflow work for it or approval.
can you give me some real world example.
Here’s a video that covers it in depth:
http://www.salesforce.com/_app/video/workflow/help/create_workflow_rule.jsp
For your particular requirement, that won’t be possible with a workflow. Workflows are very simple “If this, then that” and don’t have access to other record values. So you’d need code in your book example.
Approvals wouldn’t really be used anywhere for your requirement!
Hii David ,
I created four custom objects ,A which is a a parent of B and B which is a parent of C and C is a parent of D. Each custom objects has amount field with currency data type.The thing is this ,I need to create this task only withTrigger in such a way so that it will calculate
the amount like B’s custom field i.e A+B will show addition of amount of both A and B . C will also display addition of amount of B and C same thing with D .Please provide me how to accomplish this task.
Hey Piyush,
Since this is possible without writing code, I’d recommend that method first.
Whenever you have master-detail relationships, you can “sum” the values of your children using roll-up summaries:
https://help.salesforce.com/HTViewHelpDoc?id=fields_about_roll_up_summary_fields.htm&language=en_US
So let’s say A has three child objects of B, each with amount 10, 20, and 30. You can create a roll-up summary on A that sums up all the amounts of the children Bs, in this case, that would be 10 + 20 + 30 = 60. If you need to add A’s amount (let’s say it’s 50), create a formula that adds the two together 50 + 60 = 110.
Hope this helps =) Let me know how it goes!
David
David, could you explain the get;set . If you have already done in the past direct me on page.
public List accounts {get;set;}
Thanks
You’ll mostly use {get; set;} when creating Visualforce pages and controllers. Outside of that they are not really necessary unless you’re building a huge app!
Adding {get; set;} after a variable automatically creates two methods for you that you can use. For example, with a “name” variable
String name {get; set;}
// These two methods are automatically created in the background
public String getName() {
return name;
}
public void setName(String n) {
name = n;
}
So instead of editing the variable “name” directly, you use these two methods instead. Here are many documented reasons why we use these methods:
http://stackoverflow.com/questions/1568091/why-use-getters-and-setters
Hope this helps!
David
Way you make concept easy its really terrafic!!
Hi David,
Can you plz explain the concept of recursive triggers with a simple example……
Regards,
sfdc novice
Here’s a basic example:
Let’s say you have a trigger that creates an opportunity every time a case is created.
Then, you have another trigger that creates a case every time an opportunity is created.
What will happen is that each trigger will be fired after the other with no possible end! Thus, recursion =)
Salesforce will detect that recursion is happening and end it after a while. This is why Salesforce has governor limits!
David
Thnx a lot David….
Regards,
sfdc novice
Hi David,
I want to make the below query dynamic, In below code I am using hard-coded values (integer i=1;i<=5;i++)
I know I can use size() method but in this case number depends on fields on Address object.
Currently in Address object there are 5 Fields so I have taken i<=5. I want in future if someone adds few more fields to that object we should not change the code. Plz help.
public with sharing class abc123dynamic {
public list addr = new list();
public string initialquery=’select Name,’;
public string middlequery=”;
public string finalquery=’ from Addrress__c’;
public string strq=”;
public list getReccords() {
for(integer i=1;i<=5;i++)
{
if(i<=4)
{
middlequery += 'Address'+i+'__c'+',';
}
else
{
middlequery += 'Address'+i+'__c';
}
}
strq = strq+initialquery+middlequery+finalquery;
addr=database.query(strq);
return addr;
}
}
You can dynamically query the number of fields on on object =)
Start here:
http://bit.ly/1fvR2Tj
David
Eric – thanks so much for this! Reading about your experiences makes me realize that other non-techies are not alone in trying to figure this stuff out, and there’s hope, too!
Question on guidance… When would you recommend that people go through the links on this page (in order), versus starting off with 1 blog post and clicking the “next” link at the bottom of the post? Sometimes those go to additional articles that aren’t necessarily referenced on this page.
Definitely go in order on this page! If it’s not linked on this page, it’s probably not that important or it’s covered again elsewhere!
Hi David, you have done a wonderful job and I appreciate your efforts you put into to explain things in a very way.Best thing about you you respond to many of the mails and comments..please keep up the spirit
I would request you to please explain collections in a detail ways , as collections play a very important role. for example map collection requires lot of visualization to actually implement it.
Would appreciate if you explain collections in very details
Thanks Ashish
Ashish, I have a lot of fun doing it hahaha !
Maps are coming up in this chapter, promise! They are the #1 tool for getting around governor limits!
David
Hi,
this is my trigger code..how test this code i m trying but it;s not working they show error
@IsTest
public class TestDisplayerrormsg
{
static testMethod void insertmarkes()
{
Student__c std =new Student__c();
std.Student_Name__c=’sree’;
std.Name=’sre’; //roll number master detail ship filed
insert std;
Markes__c Mar = New Markes__c();
Mar.Roll_Number__c=” ; //master detail relation ship with student
Mar.Name=’jan’;
Mar.sub_1__c=19;
Mar.sub_2__c=18;
Mar.sub_3__c=17;
Mar.sub_4__c=19;
Mar.sub_5__c=18;
Mar.sub_6__c=17;
Mar.Esub_1__c=78;
Mar.Esub_2__c=79;
Mar.Esub_3__c=78;
Mar.Esub_4__c=76;
Mar.Esub_5__c=78;
Mar.Esub_6__c=79;
insert mar;
}
}
Hey Sree,
Happy to help! I will also need to see your trigger code to see why it is not working!
David
Not able to understand the topics like emailservices. Expecting you to have a lesson on that.
Thank you very much
Hi David,
I want to add two case fields in my custom VF page where i used Standard Controller= Account.
Is their any way to add case field in VF page using statndard controller as Account.
Below is my code.
Can you help me on this?As i am new in apex code.
Yes! Take a look at Controller Extensions!
http://www.salesforce.com/us/developer/docs/pages/Content/pages_controller_extension.htm
Thanks a Lot!!!
Hi David,
Great job !!! You are the best !!
I was reading our course and it was amazing. All my SFDC concepts were getting cyrstal clear.
But, I could not access after Chapter 5 Point 2.
Is it yet to be published or may be I am havng some browser issue ?
If its yet to published. Please let me know. I would be eagerly waiting for your update.
Thanks a lot man for helping us out with Apex coding. You are a genius.
Regards,
Avishek
Woot woot!
I’ve planned out 10+ chapters but only written to 5.2 as of today!
You can expect at least 1 – 2 posts a week, especially during the holiday season!
Also, planning to put a fun little challenge that will let readers join the Sfdc99 Hall of Fame!
Lots of fun stuff coming!
David
Hi David,
I want to start off by saying a big “THANK YOU”. The information provided in this site is clear and easy to understand. I found your website on LinkedIn from an answer to a question someone asked on “how beginners could learn Apex”. I actually have practiced all the workbooks and materials “everyone” recommends for beginners but did not get a solid grasp of Apex language until I started going through the lessons on this site. You nailed it for me with this site. The lessons on this site connected the dots for me.
I spent over five hours on this site yesterday. I enjoyed the humor in your teaching style and love the practical examples. I found your words of encouragement and tips very helpful too. I have now completed all the lessons and I am hungry for more lessons from you. I have already sent your website info to new folks in SF that I know.
I just thought to leave a comment to encourage your desire to help others and find out what I could do to show some more appreciation. I honestly feel a “Thank You” is just not enough for this brilliant work. Well done.
I appreciate!
Very honored to be able to help you learn!
Your comment is inspiring to say the least! Love is what keeps me going here =)
Lots more content to come, I promise!
David
Thanks a lot David for helping me understand the triggers,
your website is truely helpful for a beginner like me, if possible could you please add some simple Apex and Visualforce codes(apart from triggers) which will further help in understanding Apex and VF code.
Thank you Manish! There will definitely be lessons in VF and the non-trigger portions of Apex! I’d like to take it one step further even and talk about object oriented theory too!
David
looking forward to see next posts… Thanks for ur immense help… I was searching for all the sitesvery madly to learn the apex and got struck here with ur amazing site.. Its seriously soo helpful for me…
Hahaha, no problem, tell your friends!
Hey David,
I’m planning to take DEV 401 next month. could you please share some materials and suggestions?
Thank you!
Hey Semsem,
First off, remember that the DEV401 exam has no code in it. Absolutely zero! It’s actually very similar to ADM201 or ADM211.
There are two sites I highly recommend for passing DEV401:
1. Sample Recruiting App: this is good because it covers all the major features of Salesforce (workflows, validation rules, custom objects)
http://bit.ly/1bge5A3
2. Quizlet: Look for DEV401 flashcards, they are very helpful in letting you know what you need to study for!
http://quizlet.com/20548250/salesforce-dev-401-exam-study-guide-courtesy-peter-bosch-flash-cards/
I passed the exam on my first try mainly using the above two resources, so you can do it too!
David
Helllo David,
I am following ur video tutorials..They are superb for learning and ur videos make the coding thing easy on salesforce..please upload more tutorials.
Thanks
Hi David. Can you help me with this ? I’ve tried searching a lot for this but so far all my efforts are in vain.
I need to track ‘Days since last Event’ on every Account record. I need to prep a report for my org’s top mgmt. The default ‘Days since last Activity’ wont help me.
If you have come across any similar article which can help me on this, Please guide me. Thanks.
And Yeah, I’m a newbie. I’ve just started with Head First Java and loving it.
Hey Saif,
I love code, but you can do this one without it!
If you’re familiar with Roll-Up Summary fields, you can simply create one that gets the “MAX” date of associated Event records. You’d even be able to add criteria to your field to only get the MAX of certain Events.
Roll-Up Summaries aren’t available by default with Accounts and Events (since it’s not technically a master-detail relationship)… but you can simply install this very popular app to have the same functionality!
https://appexchange.salesforce.com/listingDetail?listingId=a0N30000009i3UpEAI
Then, simply have a formula field that calculates the number of days between TODAY() and your “roll-up” field.
Hope this helps!!
David
Hi David.
Thanks for the prompt reply. However I’m unable to get it to work.
I installed the App and followed the step by step procedure. However the field on the Account object ‘Date of Last Event’ isn’t updating for some reason. I used the MAX(Completed Date) field of Event with a filter stating: Event Status = ‘Completed’..
I’m pretty sure I did it properly. :(
Hey Saif,
Try doing it on a brand new set of accounts and events to see what happens! I suspect that it doesn’t work on older records unless you trigger it in a certain way!
If all else fails, give their support a call!
1.847.574.5742
Finally, if all else fails, let’s code!
David
Keep up the amazing work David. Chapter 5 and 6 are very important to me. can’t wait :)
Thanks Semsem – I can’t wait too!!!!!
Hi David,
U r Just Amazing…..plz Keep Posting..
T
Hi David,
Thanks for making this site and being so helpful in the support forum. I found your link there and came here and just want to express my thanks. I’ve been looking for a way to look down so I can write a trigger to update the children of a self-join when certain parent’s fields are updated. Most other code I found was way over my head. Your clear presentation made it easy to understand what I need to do. Also, your humor is greatly appreciated, too. That strawberry smoothy was delicious!
Gratefully,
-another David
Glad you enjoy the site David =)
More posts coming this weekend!
–David
Thanks for the reply David,
I’m exactly asking about the functionality and link between Salesforce Standard Objects like Opportunity, Products, Opportunity line items, Quotes, Forecasting like things.
Hey Santhosh,
Thanks for the inspiration! I’m going to have a future chapter on data models and the different relationships between objects. For now though I recommend looking at Salesforce standard documentation for this kind of stuff.
David
Hi David,
It’s a great work. I want to know the salesforce standard functionality.
If possible can you please post the content on it.
Thanks,
Santhosh
Hey Santhosh,
Is there any particular aspect of Salesforce standard functionality you’re looking to learn? Happy to educate!
David
Really loving this series and was delighted to see TWO in my mailbox!
Eagerly looking forward to more :)
You’ve inspired me to write more, Chris =)
David
I am loving it ..please carry on.. great work …dont stop..woould appreciate
More coming this week Ashish! Thanks for visiting my site!
David,
I posted some code to copy the task object’s activitydate on the success forum and you responded overnight, and I followed you to here. You are God-sent and may all the good that you are doing here on your site come back to you a million times – that is my blessing to you!
I clicked on your link to get the Java book you suggested. I hope you are being paid by Amazon for it.
I can’t wait for your next post – looking forward to it! Please keep doing what you are doing – you’re amazing!!!
Ales, your comment made my year!
More than happy to help with any coding questions you have, you know where to find me!
In the meantime, I’ll pump out more content so you can get rolling! Follow me on twitter for updates to new posts!
David
Hi David,
Hope you are doing well!! congratulations for this amazing and very helpful website.. i am new to this platform, i found your website, and i started studying but unfortunately after Chapter 3-3rd point onwards the hyperlink just disabled and i am not able to view further chapters, unable to proceed with the course..
Could you please check the pages and do the needful..
Thanks once again, waiting for your kind reply…
Thanks,
Jeet
Hey Jeet,
I’ve planned out many chapters but I’m still working on the posts! You can generally expect 1 post per week nowadays =)
You can find me often nowadays on the Salesforce Success community helping users out with their business problems!
Let me know if there’s anything in particular you’d like to learn!
David
Hi David,
Thanks a lot for your reply… i am new to this platform and i dont have coding background.. and would like to learn Apex, the way u explained Triggers and SOQL was very nice.. can u please suggest me how to go about it??
waiting for your kind reply…
Thanks,
Jeet
Hey Jeet,
Highly highly recommend learning the fundamentals of Java from this book:
https://www.sfdc99.com/2013/05/20/the-best-way-to-quickly-learn-how-to-code-in-salesforce/
You don’t even need to get more than halfway through it!
I’ll be posting once a week – stay tuned!
David
Hi David,
Thanks once again for your reply… and thank you so much for posting the 3rd chapter.. i was waiting to learn from your website.. also as you suggested will go through that link to learn Java Concepts.. Thanks once again.. keep up the good work..
God Bless!!!
Thanks,
Jeet
My pleasure Jeet, happy to help! –David
LOVE IT! Really looking forward to reading more. I will keep checking in.
Hi David Liu,
i am anand myself, i greatly appreciate your work here. your website is awesome for salesforce.
i would like to know some details, please guide me.
1. i am having JAVA/j2EE background, now i am interested in Salesforce, so is the programming in salesforce same like java..?
2. how long will it take to learn salesforce from scratch..? is apex and visual force are tough to code and learn..?
i am thankful for your valuable response. cheers David.
Hey Anand,
The programming in Salesforce is very similar to Java! You have a huge head start here.
The biggest is that Salesforce has governor limits, which you will have to work around. For example, you can only query 50000 records in a single execution in Apex. More info here:
http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_gov_limits.htm
Apex and Visualforce will be a piece of cake for you to learn! You’ll be pleasantly surprised how easy they are to use compared to a Java EE background =)
The hardest part (if you haven’t already learned this) is to get used to the non-code aspects of Salesforce. For example, permissions, sharing rules, when to use record types, object relationships, etc. You absolutely cannot be a good Salesforce developer unless you have a very strong grasp of what you can do without code first.
Hope this helps, and I’m glad you enjoy my site!
David
Hi David. I want to thank you for sharing this info which is very easy to pick up for a beginner like me. I have just started my career on this platform as a business analyst after my MBA and am planning to get certified as an admin in near future.I find your website very useful. I will be waiting for more articles like these. Thank You.
Please keep writing!!!
Hi, I’m a beginner in apex coding. will you help me create a test class for this. I do not have DML. my class do is just searching existing accounts.
Here’s my apex controller:
public with sharing class autoAccountSearchController {
public String strDebug1 {get;set;}
public List accounts {get;set;}
public autoAccountSearchController()
{
accounts = new List();
Account a = [select Id, Name, OwnerId, Site from Account limit 1];
}
public PageReference populateAccounts()
{
accounts = [select Id, Name, OwnerId, Site from Account where Name like :(strDebug1 + ‘%’)];
return null;
}
}
———————————————————————————————————————-
thank you.
cat
Hey Catherine,
I’m so happy you’re learning Apex that I started writing this as soon as I got home!
This test class will cover your code 100%. Make sure to read the comments – they’ll help you understand what is going on.
@isTest
public class TestAutoAccountSearchController {
public static testMethod void testAutoAccountSearchController () {
// This creates an account for testing
Account a = new Account();
a.Name = ‘Catherine’;
insert a;
// This creates your controller
AutoAccountSearchController controller = new AutoAccountSearchController();
// This sets the search parameter to the account we just created
controller.strDebug1 = a.Name;
// This does the controller’s search
controller.populateAccounts();
// This just makes sure everything worked
System.assertEquals(controller.accounts.size(), 1);
}
}