Monday, 11 March 2019

Export Salesforce Apex Test Coverage

Salesforce is a very dynamic platform which provides us(Developers - wink :P) different ways to accomplish the tasks. The sole choice lies with the developer to adapt the method in such a way to perform the task in an automated fashion. 

Problem Case:

The main block which everyone doesn't like(as per the feedback from my friends) is the Apex Test Coverage as it hinders the developers to deploy to other instance(although it is a best practice to write the test coverage above 85%) but what if when we are working on a project where we are dealing with huge no of apex classes, how to deal with the coverage of so many classes. Unfortunately, Salesforce do not provide us a direct way where we can export it in portable format. Here in this post i will try to explore new technique by which we can export the Latest Org Test Coverage.


Pre-Requisites:
1) The Apex page and Apex class should be present in Org(Our technique to export the coverage in excel)
2) We should have executed Run All Test in Org before exporting coverage
3) The Admin user should be used to export the results

Solution:
Salesforce exposes the Test coverage results on classes through Tooling REST API, hence there are many ways to consume the API and create our utilities such as - create java based code to connect to SF and get results in local to parse the response. Here is my case, I have developed a Salesforce VF page which is rendered as excel doc after querying & parsing Response from Salesforce Tooling API to fetch coverage results.

API details:
/services/data/v43.0/tooling/query/?q=Select+id,ApexClassorTrigger.Name,NumLinesCovered,NumLinesUncovered+from+ApexCodeCoverageAggregate+order+by+ApexClassorTrigger.Name

In above query, we are querying results from "ApexCodeCoverageAggregate" and fetching the response to parse it into table(with some obvious calculations).

Code:
SFDC_ExportTest - GitHub Repo

Monday, 11 February 2019

Agile Methodology




What is Agile Methodology and why use it?

There have been a lot of hype for Agile Processes. Agile has become one of the most common and effective methods for developing and delivering software solutions to customers. 
In Development practice, we use the Agile process to run our Salesforce development and Implementation. From the beginning, we have found that Agile not only makes the most sense from an internal perspective but that it helps us deliver the best possible results for our clients.
However most of IT folks are confused about the Agile Ways of Working and proper alignment with this model while working. In this post I will try to guide you through the quick overview of Agile.

Agile VS Traditional

Agile is basically a methodology and project management concept for software development. It is an umbrella under while many different methods live. E.g. Scrum, Kanban etc.
Traditional project development can be thought of a waterfall model. It requires a thorough plan from the beginning, (which can take a lot of time) and then the different parts are developed from the top down. Which this process can deliver quality results, it has enough drawbacks that people began looking for new solutions.
Agile was introduced as a reaction to traditional method. Which everyone realized was in-efficient, wasted resources and could not deliver the needed results. Agile methods allow developers to respond quickly to changing circumstances or new requirements. Rather than running from the top down, Agile processes allow for a fluid development, often based on levels of priority, and allowing for constant re-evaluation of how the project is doing and where it is going along the way.

What are some of the benefits and characteristics of using Agile?
  • Projects are completed faster than traditional development
  • Stakeholders and clients are actively involved, which helps ensure satisfactory results
  • Agile helps us develop the right product – and not be handcuffed to a project that won’t deliver the needed results
  • Project costs are predictable and can be regularly assessed or modified.
  • Results in higher quality results
  • Ongoing development and change allow the project to continue to evolve and meet whatever new requirements may arise
  • Agile creates transparency that holds all peers accountable for their actions.
  • The agile hierarchy is based on competence, not authority 


In this post, we will be explaining 2 practices under Agile: Kanban and Scrum

Kanban

Kanban is primarily a way of organizing, visualizing and prioritizing what work is being done, and when. Kanban is always done on a ‘board’, either virtual or physical. Kanban boards are generally divided into 3 sections, “to-do”, “in progress” and “done”.



Each task that needs to be done will be placed into one of these divisions, allowing us to manage the entire project in this way. By being able to visualize everything in the scope of the project, we can prioritize what needs to be done and have an overall sense of where things are.

Scrum

Scrum is where we get our practice of using sprints to divide and organize what is always being done. Sprints often range from 1 week to 1 month, depending on the project.

At the beginning of each sprint, our team sits down, discusses what was done in the previous sprint, what needs to be done in the next sprint (based on what is remaining “to-do”), and how we are going to go about it. Once roles are assigned and everyone knows what needs to be done, the team can break and get into their individual projects.

The Scrum process has a few major benefits:
  •         It streamlines the project management process
  •         It ensures everyone has something to do
  •         It allows us to regularly evaluate what has been done, and make any changes to the scope or content of the project
  •         The entire project gets done fast!


Sunday, 27 January 2019

“Android.process.media has stopped unexpectedly” error for Android Phones


The process name implies that it is related to SD card. FAT filesystem is very old and unreliable filesystem. Android stop apps to prevent further damage to your data.
Solution: Eject MicroSD card. Insert in card reader, plug to PC. Run chkdsk i: /f /x, where i- drive letter for your SD partition in Windows OS. Chkdsk shall find and fix the problem. Problem solved.

Chkdsk is very good utility command to flatten the storage disk and resolves out any issues and inconsistencies. Here are the options for chkdsk.
 chkdsk [volume[[path]filename]]] [/F] [/V] [/R] [/X] [/I] [/C] [/L[:size]]
The options and switches for Check Disk are used as follows: 
Volume Sets the volume to work with. 
filename FAT/FAT32 only: Specifies files to check for fragmentation. 
/F Fixes errors on the disk. 
/V On FAT/FAT32, this displays the full path and name of every file on the disk. On NTFS, this displays cleanup messages, if any. 
/R Locates bad sectors and recovers readable information (implies /F). 
/L:size NTFS only. Changes the log file size. 
/X Forces the volume to dismount first if necessary (implies /F). 
/I NTFS only. Performs a minimum check of index entries. 
/C NTFS only. Skips checking of cycles within the folder structure. 
-
Another command :
Diskpart (used for maintaining disk partitions)
List Disk (used for listing All disk)
Select Disk 1(used for selecting Disk 1)
Clean (The drive's partition, data, and signature is now removed. You will return to the diskpart prompt. Warning: Once you type clean and hit enter the drive will be erased. No warning will be provided.) Handle with Care!!!

File Storage on Hard Drive


To know the actual changes of hard drive after file deletion, we must know the storage of a file on hard drive at first. In Windows OS (Operating System), a hard drive is divided into 5 areas: MBR, DBR, FAT, DIR and DATA. 

mbr MBR (Master Boot Record): generated by Fdisk – the partitioning command, it is located in cylinder 0, head 0 and sector 1. When you see "55 AA", you should know it’s the end of MBR. 

dbr DBR (Dos Boot Record): generated by formatting command, it is located in cylinder 0, head 1 and sector 1. It’s the first sector that OS could have access to. It includes a bootstrap program and a BIOS parameter block. 
fat FAT (File Allocation Table): in Windows, a file is actually divided into several segments and each segment is saved into dispersed hard disk clusters. The connection information among different segments is saved in FAT. So when accessing a file, the system can find certain segments quickly and accurately according to records in FAT. 

dir DIR (Directory): this area is also known as FDT (File Directory Table), which records the information of each file (directory), such as starting & ending unit and attributes, in the root directory. 

data DATA: this is the exact place where the real content of files is stored. 

Popular Git Cammands

In today's digital modern era, Every IT company wants to use most collaborative form of development technique. Hence keeping that in mind today, i will try to cover most popular git commands which are normally used in project development.

Image result for git image


• git clone: clone a remote repository to your local.
• git add .: add all the changes in repository to staging.
• git pull : pull all branches with latest changes to your local.
• git status : to see what files have been created, modified or deleted.
• git add hello.js : to stage or simply add files.
• git reset HEAD : remove all staged files.
• git commit -m "comments" : commit the staged changes.
• git reset --soft HEAD~1 : undo your most recent commit and put those changes back into staging.
• git push : push your committed changes to a remote repository.
• git stash : save changes that you don’t want to commit immediately.
• git branch : list out all the branches.
• git checkout <branch> : switch to different branches.

Complete tutorial can also be found @ https://git-scm.com/docs/gittutorial

Monday, 15 January 2018

Salesforce Certified Administrator Winter ’18 Release Q & A

1 of 5. What functionality is available to users when adding files in Lightning Experience?
 
A. Mass upload Quip documents using the data loader
B. Access an external file provider and request secure Quip access
C. Create a new Quip file and add security from a downloaded file in Chatter
D. Create, share, and collaborate on documents with Quip without an external file provider

Correct Answer : D

2 of 5. What functionality enables sales representatives to manage their own sales territories in Lightning Experience?
 
A. Advanced Territory Management
B. Community Territory Management
C. Enterprise Territory Management
D. Corporate Territory Management

Correct Answer : C

3 of 5. Which three functions are available to a Collaborative Forecast user in Lightning Experience?(Choose 3 answers)
 
A. Designate a Delegated Forecast Administrator
B. See User Quota Attainment information
C. Adjust their own Product Family Forecast
D. Access Collaborative Forecasts in Lightning Sales Console
E. Create a Locked Forecast to prevent editing

Correct Answer : B,C,D

4 of 5. The sales teams at Universal Containers need to easily access the Sales Pipeline Dashboard. How can an administrator accomplish this in Lightning Experience?
 
A. Create a cross object dashboard component and add to the record
B. Create a new object and add a dashboard component
C. Create a new component for each sales user and add to their profile
D. Create a embedded dashboard and add to the Home tab

Correct Answer : D

5 of 5. When does an emoji icon appear in the Chatter publisher in Lightning Experience?
 
A. When a user creates a new Chatter group
B. When a user creates a new Chatter Quip file
C. When a user creates a new Chatter profile
D. When a user creates new Chatter posts and comments

Correct Answer : D

Salesforce Certified Platform Developer I - Winter '18 Release Q & A



1 of 6. Which two statements are true regarding Lightning component JavaScript code validation?(Choose 2 answers)
 
A. Code validations are applied only to components set to API version 41.0 and later.
B. Code validations can be temporariy disabled by setting the component version to API 40.0 or earlier.
C. The validation service ensures good software design and prevent bugs.
D. Code validations enforce all ESlint rules.

Correct Answer : A,B

2 of 6. In which two ways does Lightning Data Service (LDS) eliminate redundant server calls in Lightning Components?(Choose 2 answers)
 
A. LDS allows each component within an app to make independent, but concurrent, calls to perform CRUD operations on the same record data.
B. LDS identifies requests that involve the same record data and sends a single shared data request that updates all relevant components.
C. LDS acts as a publisher hub that notifies components of data changes.
D. LDS can be configured as a publisher hub with simple Apex code.

Correct Answer : B,C

3 of 6. In which two ways does Salesforce DX facilitate source-driven development?(Choose 2 answers)
 
A. Salesforce DX provides an efficient, end-to-end life cycle designed for waterfall development.
B. Salesforce DX shifts the source of truth from the org to the version control system.
C. Salesforce DX allows agile, local test runs.
D. Salesforce DX provides an integrated, end-to-end life cycle designed for high-performance agile development.

Correct Answer : B,D

4 of 6. What is the correct annotation to indicate test classes that can run in parallel?
 
A. @isTest(runParallel=true)
B. @isTest(isParallel=true)
C. @isTest
D. @isTest(isParallelrun=true)

Correct Answer : B

5 of 6. Which Content Security Policy (CSP) configuration is required to access the Streaming API and call Apex methods from within a Lightning container component?
 
A. CSP set to low
B. CSP set to custom
C. CSP set to Lightning
D. CSP set to minimum

Correct Answer : A

6 of 6. What are two valid scenarios for automatic recompilation of Apex classes?(Choose 2 answers)
 
A. All Apex classes are automatically recompiled when Apex transactions are run.
B. Specific Apex classes are automatically recompiled before completing a metadata deploy.
C. All Apex classes are automatically recompiled before completing a metadata deploy.
D. All Apex classes are automatically recompiled before a package is installed.

Correct Answer : C,D

Salesforce Certified Platform App Builder - Winter '18 Release Q & A


1 of 5. How can an App Builder reference a Queue in the Lightning Process Builder?
 
A. Update Records Action Type and a value of the Queue Name
B. Build a process on Queue that finds and changes the owner
C. Use the Queue Label
D. Add a Lookup(Queue) field to the Case and set the Owner to the Queue

Correct Answer : D

2 of 5. In which way have Lightning Bar Chart Dashboard components been enhanced?
 
A. Horizontal Bar Charts can have up to four measures
B. Line Charts can have up to four measures
C. Pie Charts can have up to four measures
D. Donut Charts can have up to four measures

Correct Answer : A

3 of 5. How can an App Builder implement File privacy on records in Lightning Experience?
 
A. Enable private file settings from Salesforce Files setting
B. Add the file privacy permission to a Permission Set
C. Add the file privacy on Records field to the Files page layout
D. Add file privacy feature on Content Deliveries setting

Correct Answer : C

4 of 5. How can a App Builder add a Flow-based Customer Survey in a Customer Community?
 
A. Create a Login Flow for Community Users
B. Add a Flow Component to a Community page
C. Add a Flow Quick Action to the page layout
D. Create a Visualforce page with an embedded Flow

Correct Answer : B

5 of 5. How can an App Builder configure a Lightning Page so that a Page component only displays for Accounts in Europe?
 
A. Add a component that only supports dynamic display
B. Add a component to a new page layout for Eurpoean Accounts
C. Add filter conditions and logic to the component properties
D. Set the component visibility by Profile and Record Type

Correct Answer :  C

Tuesday, 12 September 2017

Salesforce Certified Platform Developer-1 Summer ’17 Release Exam

1 of 5: How can a validity check be performed on a component?
A. cmp.get() == true
B. cmp.get(“v.isValid”) == true
C. cmp.get() != null
D. cmp.get(“v.isValid”) != null

Answer: D

2 of 5: What are the two considerations when overriding standard actions? Choose 2 answers
A. Overriding standard actions with a Lightning component applies only to Lightning Experience and Salesforce 1, but not to Salesforce Classic.
B. Overriding standard actions with a Visualforce page applies only to Salesforce Classic and Lightning Experience, but not to Salesforce1.
C. Overriding standard actions with a Visualforce page applies to Salesforce Classic, Lightning Experience, and Salesforce1.
D. Overriding standard actions with a Lightning component applies to Lightning Experience, Salesforce1, and Salesforce Classic.

Answer: A,C

3 of 5: Which standard actions can be overridden with Lightning Components?
A. List, Edit, New, Delete
B. Tab, View, Edit, New
C. View, Edit, New, Delete
D. List, View, Edit, New

Answer: B

4 of 5: How do the CSS enhancement to the Lightning Design System inprove the developer experience?
A. Class names are abbreviated to reduce code length.
B. Class names are available in upper and lower case.
C. Uppercase is used to distinguish from custom class names.
D. Single dashes are used in class names to enable commenting.

Answer:D

5 of 5: What is a consideration for Locker Service Enablement?
A. Locker Service is enabled for custom Lightning Components implementing the interface force:enforceLockerService
B. Locker Service is enabled for all custom lightning components with API version 40.0 or greater.
C. Locker Service is disabled for custom Lightning Components implementing the interface force:ignoreLockerService
D. Locker Service is disabled for all custom Lightning Components, regardless of the API version.

Answer: B

These questions are just for knowledge sharing but it would be great to go through the Summer '17 release notes.

Thanks for visit!!!
Cheers!!

Monday, 11 September 2017

Salesforce Certified Administrator – Summer ’17 Release Exam


1 of 5. Which two features best describe the new Lightning-optimized Log a Call action?

    Choose 2 answers
    A. Autolink the Call Log to the Case
    B. Autolink the Audit Log to the Case
    C. Autopopulate the Case Contact
    D. Autopopulate the Case Team

Ans: A & C

2 of 5. How can an administrator allow users to choose different views of a dashboard in Lightning Experience?
    A. Dashboard filters
    B. Dashboard designer
    C. Report filters
    D. Report creator

Ans: A

3 of 5. Where are the files and related records attached when a sales user converts a lead?
    A. Contact, account, person account, opportunity records
    B. Contact, account, opportunity, quote records
    C. Contact, account, opportunity records
    D. Contact, account, person account records

Ans: A

4 of 5. What action can be taken in Lightning, if you receive an approval request that someone else should approve?
    A. Delete the associated record
    B. Change Approval Entry Criteria
    C. Edit Approval Process Manager
    D. Re-assign the approval request

Ans: D

5 of 5. Which two Chatter Groups will show a seen-by count of people who viewed the post, in the Lightning Experience?

    Choose 2 answers
    A. Restricted
    B. Private
    C. Unlisted
    D. Public

Ans: B & C

These questions are just for knowledge sharing but it would be great to go through the Summer '17 release notes.

Thanks for visit!!! 

Sunday, 3 July 2016

Salesforce Spring - 16 Administrator Release Questions

1. What object types is Work Orders object associated with?(Choose 2 Answers)

A. Leads
B. Products
C. Cases
D. Service Contracts
E. Milestones

Ans: Cases, Service Contracts

2. What does the Customize Application permission setting allow?

A. To modify custom picklist values.
B. To create article types.
C. To create a new user.
D. To edit contract settings.

Ans: To edit contract settings

3. Which areas are calculated for the Health Check score?(Choose 2 Answers)

A. Session Setting
B. Profiles and Permissions assigned
C. Password Policy
D. Number of users
E. Login attempts

Ans: Session Setting, Password Policy

4. What is true regarding the new Data Loader?

A. It works with all legacy security protocol.
B. It supports Web Server OAuth Authentication for Windows or Mac.
C. It has a new column flagging duplicate files.
D. It has downloadable add-ons published through the AppExchange.

Ans: It supports Web Server OAuth Authentication for Windows or Mac

5. What key user access data is included in login forensics?

A. Who logged in more than the average number of times.
B. Who logged in from a new browser more than once in a day.
C. Who logged in during business hours.
D. Who logged in more than the number set in the profile.

Ans: Who logged in more than the average number of times

Thursday, 12 May 2016

Apex batch Auto Monitoring

Many a times you may have been in a situation where Salesforce Apex jobs gives a strong time and you are left with scratching your head due to Apex Job status unavailability. Salesforce Geeks can use an awesome object provided by Salesforce for Apex job Monitoring i.e.- AsyncApexJob . It is a backend object automatically maintained by Salesforce to track past/current Jobs. 

Although Salesforce has provided a great User Interface for same purpose i.e. Setup>Monitor>Jobs>Apex Jobs but sometimes it behaves strangely or you are not able to get proper status for your batch job, so in that case you may use Developer Console/Workbench(My personal favorite) to query AsyncApexJob object and check other details about your Apex Jobs

Lets assume your batch class is names "myBatch" then below SOQL would help you to get data related to your batch job Record

SELECT Id, MethodName, JobItemsProcessed, ApexClassId, ApexClass.Name, CompletedDate, NumberOfErrors, Status, ExtendedStatus, TotalJobItems FROM AsyncApexJob where ApexClass.Name='myBatch' order by CompletedDate Desc Limit 10

Above SOQL will return Status(and other fields) for Batch Job and hence you can identify the exact stage, number of records processed, Reason for failure etc.
********Hopefully it helps your Debugging********
Keep doing Great Work

Tuesday, 16 February 2016

Brain Bout for Salesforce Sandbox

What is a sandbox?
Sandbox is a term used for replica copy isolated from the production environment. It is used for development, testing , backup and training purpose for an organisation. These environment are near to exact copy of the schema and data model of the production instance.

Changes done to each of the environment(sandbox or prod) don't affect each other's date state/schema state. Sandbox  Login  URL :  https://test.salesforce.com

NOTE: Sandboxes can only be created from Production Instance and Information about various sandbox is listed in production.

To create a Sandbox:

  1. Goto Setup, click Sandboxes or Data Management |Sandboxes.
  2. Click New Sandbox.
  3. Enter a name and description for the sandbox.
  4. Select the type of sandbox.
  5. Select the data to include in your Partial Copy or Full sandbox.
  6. Click Create.
Depending upon type of sandbox chosen in above steps, Data and various configuration will be copied to the metadata while creating a sandbox. Sometimes the users are not with Full copy sandbox(Dont' worry read along to know about Types of Sandbox and their features) which enables to copy production data along with schema so in that case we can use DataLoader tool or Dataloader.io to import desired data from production into newly created sandbox.

  1. Developer Sandbox : It is the most basic type of sandbox available to most of the customers.These environments include a copy of your production organization’s configuration (metadata) only. This type of sandbox is mostly suitable for Development purpose.
  2. Developer Pro Sandbox : It is a superset of Developer Sandbox i.e Developer pro sandbox consists of all the features associated with Developer sandbox plus it has larger Data Storage which is very helpful in maintaining the unit test record for quality assurance tasks. No production data is copied for this type of sandbox.
  3. Partial Copy Sandbox : It is capable of including a copy of your production organization’s configuration (metadata), and a subset of your production data as defined by a sandbox template. This environment is mainly used for quality assurance tasks, acceptance testing , integration testing etc.
  4. Full Copy Sandbox : It is the most advanced type of sandbox which are mainly intended for UAT, backups, training purpose, performance testing, load testing, and staging. It can be assumed as an exact copy of production environment. It has long refresh time intervals which makes it difficult to use Full sandboxes for development.
Tasks performed by Salesforce while creating or refreshing a Sandbox: 
  • Usernames are modified by appending them with sandbox name to each username.
  • Email fields for each user is also changed in a format like salesforcel1support3=abc.com@example.com

Thursday, 11 February 2016

Salesforce Dynamic Visualforce Components

Use Salesforce Dynamic Visualforce Components and Custom Label for predefined String(helpful for displaying Apex Messages etc)

Visualforce is mainly intended for create static pages by using Different namespace tag and dynamically populating the values based on controller binded variables but sometimes Developers need to customize the Pages in such a way to reduce maintainance Development effort and the changes could be carried out in few point and clicks. To adapt this strategy, Salesforce provided -"Dynamic Visualforce Components", Under this approach VF components are dynamically populated in APEX class and then rendered onto the VF page.

Custom Label usage: Developers can use Custom Labels in Apex by using following expressions - System.Label.labelName

VF Page :
1:  <apex:page standardController="Contact" extensions="DynCompExample">  
2:    <apex:dynamicComponent componentValue="{!headerWithDueDateCheck}"/>  
3:    <apex:dynamicComponent componentValue="{!ErrorLabelString}"/>  
4:  </apex:page>  

APEX Class:
1:  public class DynCompExample {  
2:    public DynCompExample(ApexPages.StandardController con) { }  
3:    public Component.Apex.SectionHeader getHeaderWithDueDateCheck() {  
4:      date dueDate = date.newInstance(2016, 2, 8);  
5:      boolean overdue = date.today().daysBetween(dueDate) < 0;  
6:      Component.Apex.SectionHeader sectionHeader = new Component.Apex.SectionHeader();  
7:      if (overdue) {  
8:        sectionHeader.title = 'This Form Was Due On ' + dueDate.format() + '!';  
9:        return sectionHeader;  
10:      } else {  
11:        sectionHeader.title = 'Form Submission';  
12:        return sectionHeader;  
13:      }  
14:    }  
15:       // This method return the String value for the Error Label id   
16:    public Component.Apex.OutputText getErrorLabelString(String labelName){   
17:            Component.Apex.OutputText outputError = new Component.Apex.OutputText();   
18:            outputError.expressions.value = '{!$Label.' + labelName + '}';   
19:            return outputError;   
20:       }   
21:  }  

Note from Salesforce : Dynamic Visualforce components are not intended to be the primary way to create new Visualforce pages in your organization. Existing Visualforce pages shouldn’t be rewritten in a dynamic manner and, for most use cases, standard Visualforce components are acceptable and preferred. You should only use dynamic Visualforce components when the page must adapt itself to user state or actions in ways that can’t be elegantly coded into static markup.

Documentation  Link : https://help.salesforce.com/HTViewHelpDoc?id=cl_about.htm&language=en_US

Wednesday, 10 February 2016

Using NewLine in APEX String

String is an awesome DataType provided by Language designers to store any Text Literals(alphabets, numbers, special chars etc) but sometimes Developers need to display Newline Character in the APEX String which can be used on VisualForce Page.

Trick : This can be easily done adding \n for NewLine Character in Apex String and then each \n will be replaced by <br/> in VF page with help of SUBSTITUTE(JSENCODE(Variable), '\\n', '<br/>').

VF Page :
1:  <apex:page controller="Returns">   
2:    <apex:outputLabel value="{!SUBSTITUTE(JSENCODE(choosenText), '\\n', '<br/>')}" escape="false"/ >   
3:   </apex:page>  

Apex Class :
1:  public class Returns{  
2:  public String choosenText{get;set;}  
3:  public Returns(){  
4:  choosenText = 'Hi Salesforce' + '\n' + ' This is a Salesforce Techie Blog.' + '\n' + 'Please share your Feedback';  
5:  }  
6:  }  

Output :
 

Hope this trick is Helpful!!!

Tuesday, 12 January 2016

Deploying Profiles using Changeset : Salesforce

Many a times Salesforce developers are confused about the point of deploying Salesforce profile using Changeset Deployment. To be Concise, Earlier it was not possible to deploy Profiles using Changeset in Salesforce but due to evolving Salesforce platform, the developers are blessed with this feature in SF Release v30.0. 

Following points would help in clearing some doubts regarding profile deployment through Changeset:

- Adding profiles or permission sets to outbound change sets is designed to allow administrators to migrate permissions for users so they can access new functionality.  Including profiles in change sets is NOT designed to be a tool or method to update profile settings and permissions for functionality already existing in the target environment as per the Change Sets Best Practices documentation.

- Starting in API version 30.0, when deploying a new custom field, the default values for the editable and readable fields in profile field permissions are false. To override the default values, include field permissions for the new field in your profiles.

- A deployment containing a profile and record type, but not the assigned page layout for that record type, removes the existing layout assignment from the profile for that record type. Always include all page layouts for all required record types in the change set. See the Special Behavior in Deployments documentation for more details.

- Profiles or permission sets and field-level security — The contents of a retrieved profile or permission set depend on the other contents of the retrieve request. For example, field-level security for fields included in custom objects are returned at the same time as profiles or permission sets.

Thursday, 7 January 2016

Convert Date field to Days of Week in Salesforce

Sometimes the Salesforce requirements are so over-hyped that we do not realize their solution would be so easy. I got a similar requirement in Salesforce where a date field on the case object need to be converted to Days of week for SalesforceCommunication email templates. The formula is really simple to achieve this requirement.

  • Create a Text Formula field on Case object and use the below formula to achieve the goal.

Formula for converting a Date into Days of Week:

CASE( MOD( Date__c - DATE(1900, 1, 7), 7), 0, "Sunday", 1, "Monday", 2, "Tuesday", 3,
"Wednesday", 4, "Thursday", 5, "Friday", 6, "Saturday","Error")

Explanation: This formula is an example of CASE() function in Salesforce. The crux of the formula is that 1/7/1900 is subtracted from the desired date and the result is divided by 7 to get an index of Day of week.


Saturday, 31 May 2014

Salesforce Key management

Step for Generating a PKCS#12 Private Key and Public Certificate

Last week I was jumbled up with creating a secure certificate and PKCS key which i need to use into a connected app for Salesforce. While i was searching some some good resources I have found an awesome link: 


These instructions assume you have downloaded and installed the Windows binary distribution of OpenSSL. Refer to Using OpenSSL for the general instructions

  1. Generate an RSA private key:
  2. >C:\Openssl\bin\openssl.exe genrsa -out <Key Filename> <Key Size>

    Where:
    • <Key Filename> is the desired filename for the private key file
    • <Key Size> is the desired key length of either 1024, 2048, or 4096
    For example, type:
    >C:\Openssl\bin\openssl.exe genrsa -out my_key.key 2048

  3. Generate a Certificate Signing Request:
  4. In version 0.9.8g:
    >C:\Openssl\bin\openssl.exe req -new -key <Key Filename> -out <Request Filename> -config C:\Openssl\bin\openssl.cnf

    -OR-

    In version 0.9.8h and later:
    >C:\Openssl\bin\openssl.exe req -new -key <Key Filename> -out <Request Filename> -config C:\Openssl\bin\openssl.cfg

    Where:
    • <Key Filename> is the input filename of the previously generated private key
    • <Request Filename> is the output filename of the certificate signing request
    For example, type:
    >C:\Openssl\bin\openssl.exe req -new -key my_key.key -out my_request.csr -config C:\Openssl\bin\openssl.cnf

  5. Follow the on-screen prompts for the required certificate request information.
  6. Generate a self-signed public certificate based on the request
  7. >C:\Openssl\bin\openssl.exe x509 -req -days 3650 -in <Request Filename> -signkey <Key Filename> -out <Certificate Filename>

    Where:
    • <Request Filename> is the input filename of the certificate signing request
    • <Key Filename> is the input filename of the previously generated private key
    • <Certificate Filename> is the output filename of the public certificate
    For example, type:
    >C:\Openssl\bin\openssl.exe x509 -req -days 3650 -in my_request.csr -signkey my_key.key -out my_cert.crt

  8. Generate a PKCS#12 file:
  9. >C:\Openssl\bin\openssl.exe pkcs12 -keypbe PBE-SHA1-3DES -certpbe PBE-SHA1-3DES -export -in <Public Certificate Filename> -inkey <Private Key Filename> -out <PKCS#12 Filename> -name "<Display Name>"

    Where:
    • <Public Certificate Filename> is the input filename of the public certificate, in PEM format
    • <Private Key Filename> is the input filename of the private key
    • <PKCS#12 Filename> is the output filename of the pkcs#12 format file
    • <Display Name> is the desired name that will sometimes be displayed in user interfaces.
    For example, type:
    >C:\Openssl\bin\openssl.exe pkcs12 -keypbe PBE-SHA1-3DES -certpbe PBE-SHA1-3DES -export -in my_cert.crt -inkey my_key.key -out my_pkcs12.pfx -name "my-name"

(Optional) Delete unneeded files. At this point, you only need the PKCS#12 format file, so you can delete the certificate signing request (.csr) file, the private key (.key) file, and the public certificate (.crt) file.
The resulting PKCS#12 format file may now be used within Secure FTP Server - FIPS.



Salesforce Live Agent

Now a day the competition has raised its bar and in each industry everyone believes in quick reception to his/her queries. Live agent is an awesome functionality provided by salesforce for managing chats with client contact on various standard object/Custom objects. It enables the external users to have a web chat with agents to know more about their product queries (or solution)
This feature is available at Developer and Performance editions organizations created after June 14, 2012 and for Enterprise and Unlimited Editions it’s available with an additional cost.

Steps to enable Live agent for an Org:
1. Navigate through Name>Setup>App Setup>Customize>Live Agent>Settings

2. Check the checkbox for “Enable Live agent”.
3. Enable Live Agent user check box in your user detail page. 
(Note: - Live Agent users require API Enabled administrative permission on profile. Agents also need at least the “Read” permission on Live Chat Visitors and Live Chat Transcripts to review visitor and transcript records.)
4. After enabling live agent for your org, several objects are automatically enabled and created in your org e.g.
a.       Live Chat Visitors – The Live Chat Visitor tab contains information about visitors that have participated in chat sessions. Below you can see sample live chat visitor record
b.      Live Chat Transcripts: - The Live Chat Transcripts tab contains the transcripts of completed chat sessions. Below you can see sample live chat transcript record
c.       Live Chat Transcript Events: - Contain all information that contains chat request; accept request or route details and Visitor Left. Below you can see sample live chat transcript event record
d.      Live Agent Sessions: - This Live Agent Sessions tab contains information about agent session, time spent online, time spent on chat etc. Below you can see sample live chat session  record
e.      Live Agent Supervisor:-This tab contains information about your department’s chat buttons and chat agents, all in one place. It will look like below screen shot
f.        Live Agent :- This tab contains information about Chat transcript and from here you can launch live agent console
g.       Quick Text: - Quick Text lets users create standard messages, such as greetings and answers to common questions, which support agents can easily insert into communications with customers. Quick Text is automatically enabled for organizations that have enabled Live Agent. If you want to create quick text click on Quick text (Tab) | New and fill the details as per your choice, you can take help from below screen shot
Setup Skills for the Live Agent
1. Go to Name>Setup>App Setup>Customize>Live Agent>Skills.

2. Create new Skill by clicking “New” Button.(as shown below)
3. After setting Skills, Go to Name>Setup>App Setup>Customize>Live Agent>Chat Buttons and create one by clicking “New” (as shown below).
4. Select type, Name, Skills (Mandatory fields). Also you can set various other attributes like Custom agent name, Auto greeting message, Language, online image, offline image etc.


5.  After setting up button, the detail page would provide a code snippet for chat button copy the code and paste it in a text file.
6. Then Go to Name>Setup>App Setup>Customize>Live Agent>Deployment. Create a Deployment record by inserting required fields (or you can customize it according to the company branding). After creating deployment record it would also result in a short code snippet. Copy this code snippet and paste it in same file(as previous) and save it as filename.Html
Test the Live agent:  You have to embed this live agent configuration into an application
1. Create a Service Cloud Console Application from Create --> Apps and click "New" button.
2.  While creating a service cloud Application enable the checkbox for “Include Live agent in this App” and choose the records or pages to open as sub tabs
After Creating App in Salesforce, Select the App and Open the .html file which contains the code snippet generated during the process. On click of online image on html page, A Request to Agent would be sent to accept the Chat Conversation. After the agent accept the chat, they can start chatting and the agent can save or create appropriate object record related to this chat conversation.(as shown below)