Showing posts with label salesforce. Show all posts
Showing posts with label salesforce. Show all posts

How to show a commandline/terminal menu

You might have seen a lot of command line tools offering a small menu with a number of options to choose from. Also you might have written some bash scripts that you want to make available in your terminal as a menu. Here you can find a good example to get started.

Sample



This menu sample code is organized into three main chunks. "show_menu" function takes care of styling and displaying options. option_picked function is used to show the option selected in a different color. Finally there is a while loop that is used to show the options continuously til you exit by hitting just enter.

Use cases

For an example, in Salesforce context you can use this script as a starter to get started with Salesforce DX commands. Salesforce DX commands are notoriously long and difficult to remember. You can setup a bash script with different options and user friendly labels. Then using the sample menu you can invoke necessary sfdx commands.
As final step you can alias the path to the bash script in you ".bash_profile" file. This will let you call your utility script anytime from terminal without worrying about path.

alias heydx="sh /Users/myname/Documents/Scripts/dxUtility.sh"

Using curl to authenticate to Salesforce REST API

If you are building an application that needs to connect to Salesforce, there are multiple ways you can do this. Same is true for authenticating against Salesforce also. You have a wide variety of methods available to authenticate against Salesforce. You can find details of different methods using OAuth in below link.

Authenticating apps with OAuth 

Salesforce REST API, provides an efficient way to access Salesforce data. It is common to use this API from mobile apps. In this article we will have a look about how to authenticate and access data using REST API. You can use this same process to authenticate mobile/desktop applications. To demonstrate this, we are using a tool cURL. This tool is preinstalled in Mac. If you are using a windows PC, go to cURL download page and install this application. Once you have installed this tool, you can make http requests with custom headers and JSON body from terminal or command line.

There are different ways to authenticate your application against connected app in Salesforce like “Web Server OAuth flow”, User Agent OAuth flow”, “Username-password flow” etc. We are going to use OAuth 2.0 Username-Password flow here.

Authentication and data operations

1) Create a connected app in Salesforce

    First you need to create a connected app in Salesforce. You can do this by going to “Create => Apps => Connected Apps => New” under setup. Fill in the details and save. UI will looks like below image,

image

2) Note down Consumer Key and Consumer Secret 

    Once you have saved your details, you will be able to get “Consumer Key” and “Consumer Secret” under “API(Enable OAuth Settings)” section. Note down the values. You need to use these values while authenticating against Salesforce.

3) Authenticate to get session token 

    First step of authentication is to get session token using username, password, customer key and customer secret. This is obtained by making http request to “https://login.salesforce.com/services/oauth2/token” or “https://test.salesforce.com/services/oauth2/token” for production and sandboxes respectively using cURL. If the authentication is success, it will return a session token/access token. You can make subsequent API calls using this token. This step will look like below,

4) Do REST operations – Query/Insert/Update/Delete etc 

    Once you have access token you can make different REST API calls. All API calls should go to the instance URL returned by login call. Also access token obtained in login call should be added as “Authorization” header parameter. You can find examples of query, insert, update and delete operations below,

Summary

    Now you should have a good idea of how to authenticate your mobile/desktop application against Salesforce using username-password OAuth flow and do operations using REST API. If you are not comfortable using cURL from command line for trying this process, same steps can be done through browser extensions/chrome apps like “Advanced REST Client” or “Postman”.

How to pass ADM 201–Salesforce certified administrator

ADM 201    ADM 201 or Salesforce certified administrator certification assesses you for the knowledge required to maintain a salesforce instance in a company. It checks candidates ability to configure an application in force.com application. But it does not evaluate against coding aspects like apex and visualforce.Difficulty wise it is a bit more tougher than DEV 401. ADM 201 syllabus contains all the topics needed for DEV 401 along with some additional contents like basic knowledge in sales cloud, service cloud, chatter, reporting, user setup, securing application etc. Detailed syllabus can be found in below link.

Syllabus / Study guide 

    First and mandatory thing to do while preparing is to go through the above study guide. It will give you a very good understanding regarding different areas against which you will be assessed.

Structure of Exam

    It is a multiple choice exam with 60 questions. You will get 90 minutes to complete the exam and need 65 percentage(39 correct answers) to pass the exam. Exam fee is $200. If you failed in first attempt, second attempt can be done with a fee of $100. Most of the companies have partnership with salesforce.com through which they will be able to get vouchers for exam. So if you are from a partner company of Salesforce, try to get a voucher from your company.  

Materials to prepare

    This certification is demanded by companies looking for administrators. The role of an administrator in small to medium sized companies includes tasks like maintaining the production sandbox, creating users, managing security, running reports etc. Many business analysts who does not have plan to go to development side of salesforce.com also takes this certification. Salesforce.com recommends its “Administration Essentials for new Admins” instructor led training program as a preparation for this certification. But it is a paid training. If you cannot afford paid training, you can pass it preparing with resources available online. Also there are many people who pasted notes from salesforce training online. For example check  ADM Notes in this blog. Please find the list of other free resources to prepare for the exam,

  • Force.com Fundamentals - You can find HTML/PDF version of the book in salesforce documentation. It walks you through creating a recruiting application in force.com platform. It might look bit time consuming initially, but it is a very good resource and gives clear understanding of most of the aspects of force.com platform. Try to build recruiting application on your own with the instructions given in the book.
  • Create your own Developer Org and practice – Salesforce offers free developer org for anyone who is interested to practice. You can create your own org in registration link.
  • Online Free Training – Salesforce offers free online training videos. Once you have registered for developer org, you can access these materials from the “Help” link in top right corner of your developer org. It will give you access to lot of videos regarding different aspects of force.com platform. Again if your company is a partner of salesforce, you can get access to premium online training videos. Out of those videos “Administration Essentials for New Admins”, “Administration Essentials for Service Cloud” etc are very useful. Salesforce offers trail head training which is free and gives practical experience.
  • Online blogs – There are many good blogs explaining about all the topics in the study guide. For example you can check – Cloudsocius blog. You can check salesforce documentation for additional materials regarding any topic related to force.com platform. Just search in Google for additional new blogs. There are many coming up every day.
  • Flash card training – These are basically sample questions very similar to the actual questions in exam. This you can use as the last step in practice. Once you have gone through all materials, you will be able to answer most of the questions. If there are some questions you are not able to answer, prepare more in that area and attempt again. Some good flash card training sites are – cram , Quizlet etc.

 

I am certified. Now what?

    Congrats. It is time to celebrate. But remember that now you have to maintain your certification. Salesforce require you to maintain DEV 401 and ADM 201 certifications. Every year there will be three releases(updates to the platform) for Salesforce. Associated with each of these there will be maintenance exams. So every year you have to write thee maintenance exams. But these are online exams, based on release updates. These are easy exams, which you can clear easily if you go through release notes. After your initial certification, two consecutive release exams are free for you. But after that you will have to pay $100 every year once for maintenance exams. So always remember to take maintenance exams on time, otherwise your certifications will become invalid.

Also ADM 201 certification is a mandatory requirement before you can take Sales cloud consultant, Service cloud consultant and advanced administrator certifications. Make a good study plan and start preparing towards it.

How to pass DEV 401 - Salesforce Developer Certification

DEV 401     DEV 401 or Salesforce.com certified developer is the easiest of the salesforce certifications. It asses the capability of the candidate to configure force.com applications. But it does not cover any coding topics like apex or visualforce pages. Detailed syllabus can be found in below link.

 
    First and mandatory thing to do while preparing is to go through the above study guide. It will give you a very good understanding regarding different areas against which you will be assessed.
 

Structure of Exam

    It is a multiple choice exam with 60 questions. You will get 90 minutes to complete the exam and need 68 percentage(41 correct answers) to pass the exam. Exam fee is $200. If you failed in first attempt, second attempt can be done with a fee of $100. Most of the companies have partnership with salesforce.com through which they will be able to get vouchers for exam. So if you are from a partner company of Salesforce, try to get a voucher from your company.  

Materials to prepare

    It is a very popular certification and so very good resources are available to prepare for this certification. Salesforce.com recommends its instructor led training program, but as it is costly and it is not a difficult certification, you can very well prepare on your own and clear this certification. Below are the list of free resources to prepare for the exam,

  • Force.com Fundamentals - You can find HTML/PDF version of the book in salesforce documentation. It walks you through creating a recruiting application in force.com platform. It might look bit time consuming initially, but it is a very good resource and gives clear understanding of most of the aspects of force.com platform. Try to build recruiting application on your own with the instructions given in the book.
  • Create your own Developer Org and practice – Salesforce offers free developer org for anyone who is interested to practice. You can create your own org in registration link.
  • Online Free Training – Salesforce offers free online training videos. Once you have registered for developer org, you can access these materials from the “Help” link in top right corner of your developer org. It will give you access to lot of videos regarding different aspects of force.com platform. Again if your company is a partner of salesforce, you can get access to premium online training videos. Out of those videos “Building Applications with Force.com – Part 1" and its part 2 are very useful for DEV 401. There are many other free online video trainings like – Udacity course
  • Online blogs – There are many good blogs explaining about all the topics in the study guide. For example you can check – Cloudsocius blog. You can check salesforce documentation for additional materials regarding any topic related to force.com platform. Just search in Google for additional new blogs. There are many coming up every day.
  • Flash card training – These are basically sample questions very similar to the actual questions in exam. This you can use as the last step in practice. Once you have gone through all materials, you will be able to answer most of the questions. If there are some questions you are not able to answer, prepare more in that area and attempt again. Some good flash card training sites are – quizlet , proprofs etc.

 

I am certified. Now what?

    Congrats. Now you have to maintain your certification. Salesforce require you to maintain DEV 401 and ADM 201 certifications. Every year there will be three releases(updates to the platform) for Salesforce. Associated with each of these there will be maintenance exams. So every year you have to write thee maintenance exams. But these are online exams, based on release updates. These are easy exams, which you can clear easily if you go through release notes. After your initial certification, two consecutive release exams are free for you. But after that you will have to pay $100 every year once for maintenance exams. So always remember to take maintenance exams on time, otherwise your certifications will become invalid.

Salesforce Apex Best Practices

Apex is the programming language used in Force.com platform.  It is an object oriented language with syntax similar to Java and working like database procedures. It is a powerful language which in conjunction with Force.com platform can help to build powerful applications with development time lesser than any other platform available today. Starting code development in apex language is very easy. But we should be very careful while developing in this platform as wrong coding practices will lead to hitting governor limits in Salesforce. Below I am listing some best practices for developing in force.com platform.
  • Apex is case insensitive. Try to follow naming conventions similar to Java. Camelcase can be used for variable names. It is better not to use underscores in variable names, even though it is allowed. If used, it can create confusion with field names in objects which contains underscores. Give one tab indentation as Java.
  • Never use queries (SOQL or SOSL) or DML Statements(Insert, Update, Delete, Upsert) inside loops.  Apex code is running in a multi-tenant environment. So Salesforce has implemented governor limits to avoid one user consuming all resources. Below screenshot shows common governor limits in Salesforce.
apex-limits
You can make only 100 SOQL queries and 20 SOSL queries in one transaction. One transaction includes all the actions that are carried out in one event. If you are calling any methods in helper classes and making some queries in that method, that also will be counted against governor limit. Also you are allowed to do DML operation on only 10000 records in a transaction. If you want to do more, you can go for asynchronous execution methods like Batch classes or @Future methods. But be careful not to call asynchronous methods also inside loops.
  • Bulkify all apex codes if possible. For the code to be efficient and avoid hitting governor limits in force.com platform, you have to bulkify all the codes.  For example check below code. Requirement is to update status of all child records when parent status is completed.


    This code may work fine initially in development if users are creating records from Salesforce UI. But if there are more than 150 child records under one completed parent record. Then this code will hit maximum number of DML queries limit. If we optimize this code we can write it as below.

    Note that query at Line number 4 will executed only once and it will pull all parent and child records.  Also there is only one DML statement at the end. If you cannot manage to achieve this through child query or relationship query, you can achieve this by using collections like Map. But you should be careful in this case, not to hit heap limit.
  • Try to externalize maximum parameters. Never hard code any Ids.  Ids changes between sandboxes (different in dev and production for same record type)Usually developers hard codes some values in code like record type id. It is not advisable. If at any place it is unavoidable, use it through custom labels or custom setting. It will be helpful if later you want to change the value.
  • Never use batch call or @future call or Email invocation in loops. It will result in hitting respective limits. Batches queues up usually. If more than 5 times same batch is queued up, it next queuing attempt will throw exception. Number of @future calls and email invocations that can be done in single transaction is 10. If it is in a loop, chances of exceeding this limit is very high.
  • Aim 100% test class coverage. It is mandatory to have a test class coverage of 75%. But more coverage means, all functionality are working as expected. Also add proper assert statements to assert test results are coming as expected.
  • Do bulk testing for triggers. If you have a trigger in any object, test it for bulk volume of records(at least above 200). This will ensure that your trigger will not fail hitting common limits. Also it ensures that your trigger is bulkified. Use organization independent test data using (seeAllData=false). It will ensure code portability between sandboxes.
  • Use indexed fields in WHERE clause of your queries in triggers. If there is an object that can contain more than 100k records. This is mandatory. Otherwise your trigger will fail, when the total volume of records crosses 100k. This is applicable only for triggers. You can find the details in Working with large SOQL queries.
  • Write test classes covering multiple profile scenarios. Use System.runAs() to run as different users. If any test method looks like reaching limit split it into many testmethods in on class, each covering different scenarios.
  • If in any test class, user data is inserted. append time stamp also to the user name. Usually if it is not append in second deployment onwards, duplicate user name error is thrown and test classes fails.
  • Use Test.StartTest() and Test.StopTest() properly to avoid hitting governor limits. If you are not trying to test triggers, keep all data insertion outside Test.StartTest() and Test.StopTest(). Test.StartTest resets governor limits. But make sure that the code that covers the class, is inside Test.StartTest().
  • Go for apex coding only if unavoidable. If it can be handled in out of the box functionality like workflow rule, approval process etc, try to do in that itself.

How to start a career in Salesforce?

As it is an emerging technology, and a cloud computing technology, lots of people are planning to start a new career in Salesforce.com or SFDC. But most of them are in doubt, where to start. As with most of the other technologies, to develop a career in salesforce, best way is to take any certification provided by Salesforce. Salesforce is offering certification in many streams. Depending on whether you are looking for a career as a developer or an Administrator or a Consultant, Salesforce is offering many certifications.

For Developers

For developers, the first certification you can start with is Dev401 exam. It is an online exam where you have to answer multiple choice questions. Its fee is $200. Questions are mainly coming from basic application configuration in Salesforce. The tutorial PDF provided by Salesforce with name ' Force.com fundamentals  will help you to answer most of the questions of this exam


Next level exam for salesforce developers is Advanced developer Exam. It is the next level exam for developers. This exam with fee $400 will, ask you to complete two steps in the exam. In the first step you need to clear an online exam with multiple answer questions. In the second level, you need to develop a small case study application.

For Administrators

For administration entry level exam in ADM201, which is almost similar to the DEV401 exam of developers. For this also most of the questions will be coming from the PDF provided by salesforce with name 'Force.com fundamentals'. For admin exam more than developing side, you can expect more questions from areas like application security settings, different sandbox limits etc. The exam will also test your understanding about most of the built in functionalities in salesforce like service, call center, sales apps in salesforce

Next level exam for administrators is Advanced Admin exam. This is equivalent to Advanced developer exam for developers.

For Consultants

There are exams for salesforce consultants also. Consultant exam depends on the area, in salesforce where we want expertise on. There are many consultant exams like service cloud, sales cloud etc. 
In addition to these salesforce is providing many other certifications in many other services provided by salesforce.


If any Salesforce.com Freelancer development tasks are there visit,

Salesforce freelance developer

Salesforce.com - Introdution



Salesforce is one of the leaders in "software as a service" aspect of cloud computing.   If you define cloud computing simply it is delivering hardware or software to end users without burdening them with backend details.

So Cloud computing can be generally classified as

Infrastructure as a service (IAAS) - Only hardware parts like Server space is shared with users.
Platform as a Service (PASS) - Servers and system software also shared by different users.
Software as a Service (SAAS) - software application, database etc also are shared.

Cloud providers will gather all these resources and give to users for a charge. There is no need to worry about purchasing server, database etc separately by user. Also a large initial investment for startup businesses can be avoided. At starting users can purchase only a small space and if found useful, later they can expand. This is scalable.

Salesforce will come under the category of Software as a service (SAAS). Salesforce is letting you to use their app and customize it according to your needs. Even though it is mainly a CRM oriented app, you can customize in the way you want. Also you can redesign the full app with your business look and feel, if you want. Also there is provision to add apps to your application from appexchange, which is the app store of salesforce applications.

In salesforce most of the things can be done using point and click activities. But in case you cannot achieve some of the functionality by the out of the box features, you can write custom classes in salesforce supported apex language. Also you can create custom looks using the HTML like markup language visualforce.

If any Salesforce.com Freelancer development tasks are there visit,

Salesforce freelance developer