Total Pageviews

Friday, April 4, 2014

Group Tasks in Salesforce - Facts and Fault lines




Group Tasks

Tasks which can be assigned to more than one user is called a group task. One can create a task so that up to 100 users are each assigned an independent copy of the task. 


To create a group task:
  1. On the New Task page, click the lookup icon (Lookup icon) next to the Assigned To field.
  2. In the lookup window, select the Multiple Users tab.
  3. Users can be organized into various categories such as personal groups, public groups, roles, or territories. In the Searchdrop-down list, select the appropriate option.
  4. Optionally, enter one or more characters in the text box and click Find to search.
  5. In the Available Members list, click one or more items to select them. Press CTRL+click to select multiple items individually, or SHIFT+click to select multiple adjacent items at the same time.
  6. Click the Add and Remove buttons to move your selections between the lists.
  7. When the appropriate choices are in the Selected Members list, click Done. If your selections total more than 100 users, you must reduce your selections before you can proceed.
  8. On the New Task page, see your selections display next to the Assigned To field. The total number of tasks you are creating also displays.
  9. Continue entering task details such as due date, status, and comments.
  10. When you save the task, your selected users will be assigned copies of the task. Note that these copies are independent and not linked; they can be edited, transferred, or deleted individually.
Problem Statement
Elena is the practice-head of her  Salesforce competency and has to assign a task to all her team members to take their maintenance exams.
Elena notices that a task can be assigned to a role in a workflow.
Elena plans to create a Role of all her colleagues who have to take this exam periodically , she names it "SFDC Competency" and assigned this role to all the users who take these exam periodically.
Elena planned to create a Learning Activity Custom object on which she create a workflow which will create a task for taking exam assigned to all the users who are assigned to the "SFDC Competency" role when she creates an instance of Learning activity Object.
Issue
When she tried to test the rule she noticed that only a single  task was getting created and was getting assigned to the creator of the "Learning Activity" object.
To test the issue further she removes all users from the "SFDC Competency"  and leaves a single user.
Then she tests it again - now she finds that a task gets created and is assigned to the user of the single user in the "SFDC Competency" role.

Analysis
In gist, there's no neat feature available in Salesforce for assigning Group tasks via workflows. But there are some workarounds that can be built to accommodate the business needs. As of now Salesforce does not recognize multiple people assigned to a role in a workflow. When there are more than a user assigned to a workflow task assignment rule, it will instead send the task to the rule initiator and not the intended recipients. You can create multiple roles and assigned single person to each one. alternatively, one can have each workflow rule to have multiple task assingment rules one for each role.
But this may not be a good solution from house-keeping / maintenance point of view , what when user leave or new users get added.

Will keep looking for a better and more automated solution. 

Sunday, March 30, 2014

Unraveling the mystery about Products , Price Books and Assets

Any technology if its a hot cake is lapped up by job-seekers, people try to subvert the system to get into it.
Why subvert the system when all resources related to current hot-cake salesforce is online and the platform also freely available for developer to use and develop and acquire skills.
I believe in equal opportunity in its true sense , hence I keep blogging at regular intervals so that I may contribute in my very minuscule way in  making information available freely to all concerned.
Leaving behind the small talk lets concentrate on something which forms the very backbone of all business entities- Products.
In context of salesforce - Product is a pivotal piece in its implementation -popularly called the "Sales Cloud"
So what do products signify in slaesforce?

Products
Product is some service or items that as an organization one may sell to people who may need them.
You may think that's fine , but are is there more to products - are they all same?
Do they have any categorization?
Are they grouped or categorized in any way?
Talking of classification or categorization - a term which rings a bell is "Product Family"
Now what is Product Family?
Say there is a home appliance manufacturer, they might make different types of appliances like:-
i. Kitchen appliances
ii. Bathroom appliances
etc.
You realize that products can be grouped into different categories based on some common characteristics- such a grouping is called "Product Family" in salesforce.
Generally whenever you shop online you try to find the Product list with the associated prices- such an compilation of products along with the associated prices is called a Price-book
Each Product -with its associated  Price is a Price-Book Entry or in short a price-book is a collection of PriceBook Entries
Every organization has at least one "Standard Price Book" which is the master list of all products with their associated standard price.

Now the question can we have price books which contain the selling price or also called the list price? Yes we can have more than one custom price books  each catering to a different market. For ex. most books have a cheaper Indian editions with economical prices and a International edition with prices at par with international market. So in this case one can create a Domestic Pricebook and an Overseas Pricebook .
P.S. Every product is always present in the standard pricebook and in one or more than one custom pricebook. Also an opportunity can contain only one pricebook.

Many times you might have created too many pricebooks and dont want to use them anymore , then what does one do ? You cant delete pricebooks with associated records. You can Archive them, but once archived but once archived they cannot be restored.


Organization wide / default Access on Pricebooks
1. Use Access - With this access all users of org can view pricebook and can add Price Books and products in price book to an opportunity
2. View Only- With this access all Users can view and report on Price book but not add them to opportunity. So in order people to add price book to opportunity you need to give people /users edit access to opportunity and give "use" access to the pricebooks you want them to use.
3. No Access- Users cannot see or add pricebooks to opportunity. We use this access when we want only specific users to use and view the pricebooks and the people whom you want to use pricebooks grant them "use" access if you want them to add pricebooks to opportunity or give "View only" access if you want them to view and report on pricebooks.
Another important aspect of Products is Scheduling. Its of 2 types :-
1. Revenue
2. Quantity

Enabling schedule from the Setup / Customize / Products/ Schedule Setup (refer to screenshot for clarity)











Enabling schedule adds a scheduling section to the Product page layout. More on Scheduling in later posts.
Enabling schedules also enables users to create reports on for tracking shipments, deliveries and payments using the report type Opportunity with products and schedules.

Assets
A product which is purchased by the customer is tracked in Asset. It may be a product purchased from you or your competitor - it may hold information about:-
1. Serial number
2. Expiration date
3. If it is competitor asset or not
Also asset can be tracked from Account, Contact and Product by adding it as a related list to these objects' layouts.
Also one can add a lookup to asset in cases and a case can be created linked to the asset purchased by the customer which will help the support and service folks.

Some questions about Products:-
1. Many times one faces queries like how do I add a check on restricting selection of a particular Pricebook for a particular profile or record type of opportunity?
Answer- You have to add validation rules at the Opportunity Product level and in case if its too complex one may have to write the validation rule logic in a trigger on Opportunity Product.
2. Can i add more that one pricebook to am opportunity?
Answer - No
3.How do I load data related to Products , Pricebooks , etc.?
Now that requires a dedicated post - may be next post will dwell on that.





Sunday, March 23, 2014

Lead Status field and the common queries which may bother you!!



Lead Status
Lead Status field the common pitfalls / concerns



Lead represents a Prospect or potential Opportunity.The field named "LeadStatus" (API name) indicates the state of the lead in the pre-sales process of turning a lead into an opportunity. Some default values for the Lead Status field include Open, Contacted, and Qualified.
Some of the things which need to be taken care of w.r.t. leads and Lead Status field in particular:-
I. Do we need to assign at least one picklist value in status field as Converted ? Yes , at least one of the picklist values in this field has to be marked as "Converted". 
One may ask you -How are converted lead status values setup?

How to set converted leads status values?
To set the values available for the "converted status" field on the convert page layout do the following:
1. Click on:
Setup | App Setup | Customize | Leads | Fields | Lead Status2. Click "Edit" next to a value3. Select the "converted" checkbox if you would like it to be an available value during lead conversion (NOTE: you can have more than one converted status value)

II. Can we have more than one picklist value as "converted"? 
Yes more than one field can be related to / or assigned as "Converted" picklist value.
III. Many times a user may find the presence of the picklist value confusing? 
They may ask the picklist value to be re-christened or renamed. Yes you can remove , rename picklist values assigned as "Converted" , only catch is atleast one picklist value has to be there which assigned as "Converted"
IV. How to remove converted status off lead status value?
In order to make a value no longer have a converted status you should click edit beside the value and uncheck the converted checkbox

V.  Many times while converting a Lead we come across errors , what causes them?
More often these error are caused due to presence of Mandatory fields on objects whose records are created as a result of conversion like Account, Contact, Opportunity, Task, etc. In case say you have created a custom mandatory field on Account, then lead conversion will give error if you do not map a mandatory field from lead onto the newly created mandatory field on account. 
VI. If we have multiple values corresponding to "Converted Status" how  is converted status values derived when a lead is converted?
If record types are not being used in Leads, all of the existing converted status values will be displayed on the lead convert page.  But , if record types are being utilized, the values displayed on the lead convert page are taken from the values available on the default record type of the profile assigned to the user who is triggering the lead conversion, and not from the converted status values that are setup on a lead record type / lead process that is assigned to the lead being converted.
Lead  is accorded special attributes and status like Opportunity and Task because of many native or in-built salesforce features / functionality running off them, hence lot of caution and thinking should be invested while customizing or changing the basic characteristics of this functionality.

Saturday, February 1, 2014

Batch Apex – What you should be careful about?


I have been writing or reviewing codes in Salesforce for over six years now. Whenever one comes across a tricky situation which involves processing huge volumes of data “Batch Apex” is the way to go, but every now and then you may be alarmed by someone telling you – that hey I hit the 10k limit while executing a Batch Job!

You would wonder- how is that possible? Soon you would realize that its the result of one the common slips that one does while designing a “Batch Job”. Most commonly we fetch records in access of 10,000 within the Execute() method. Treat all code written within execute() method as if you are writing for normal Apex.
Batch Apex surely has more flexible Governor Limits for example:-
·         200  SOQL per cycle (Please check the latest limit a s per latest release)
·         Records retrieved by SOQL query 50,000,000 as against 50k in the normal apex.
·         Heap Size is much larger than that compared to normal apex.
Why Batch Job is capable of handling huge data sets?
 One has to understand what makes Batch Apex successful in processing huge data sets:-
·         The large data set is processed in batches – which implies that the parameter “query” in  Start Method () that has to be the query which will return the bulk of data. Please refer to following code snippet for clarity:-
global Database.QueryLocator start(Database.BatchableContext BC){
 return Database.getQueryLocator(query);
Common Pitfalls
è You might say well what’s new in that we all know that. Well true but just reiterating -that the dataset which is the largest - it has to be fetched with the SOQL in “Query” and then processed in batches
è Always remember within the Execute() method never execute an Insert or update which will process more that 10k records in a cycle.
·         Also the enhanced governor limits enables the Batch Apex to process huge datasets, but one needs to cautious that though relaxed the governor still exist w.r.t. Batch Apex too. The following may be important for considering while finalizing your design and organization wide setup:-
o   Batch Apex Governor Limits
o   These are the governor Limits you need to keep in mind when dealing with Batch Apex
o   Up to five queued or active batch jobs are allowed for Apex.
o   A user can have up to 50 query cursors open at a time. For example, if 50 cursors are open and a client application still logged in as the same user attempts to open a new one, the oldest of the 50 cursors is released. Note that this limit is different for the batch Apex start method, which can have up to five query cursors open at a time per user. The other batch Apex methods have the higher limit of 50 cursors. Cursor limits for different Force.com features are tracked separately. For example, you can have 50 Apex query cursors, 50 batch cursors, and 50 Visualforce cursors open at the same time.
o   A maximum of 50 million records can be returned in the Database.QueryLocator object. If more than 50 million records are returned, the batch job is immediately terminated and marked as Failed. So if you have a requirement to process in excess of that value factor in the necessary checks and balances in your design.
o   If the start method returns a QueryLocator, the optional scope parameter of Database.executeBatch can have a maximum value of 2,000. If you set to a higher value it will anyways break it into smaller chunks, which is a blessing in a sense.
o   If no size is specified with the optional scope parameter of Database.executeBatch, Salesforce chunks the records returned by the start method into batches of 200, and then passes each batch to the execute method. Apex governor limits are reset for each execution of execute.
o   The start, execute, and finish methods can implement up to 10 callouts each.
o   Batch executions are limited to 10 callouts per method execution.
o   The maximum number of batch executions is 250,000 per 24 hours.
o   Only one batch Apex job's start method can run at a time in an organization. Batch jobs that haven’t started yet remain in the queue until they're started. Note that this limit doesn't cause any batch job to fail and execute methods of batch Apex jobs still run in parallel if more than one job is running.

Tuesday, September 10, 2013

SFDC quick heals ( 18-15 SFDC ID , Activating inactive stage picklist value, etc...)

Every now and then we stumble  upon small nagging issues which we research and resolve but few years down the line re-encounter them and proceed to reinvent the wheel.
One such trifling issue is that of the nagging 15 digit vs 18 digit id of salesforce (record id).

In salesforce each record Id represents a unique record within an organisation. 
These ids are in two formats /type /version for every record Id in salesforce :
  1. 15 digit case-sensitive version which is referenced in the UI (Detail pages / reports)
  2. 18 digit case-insensitive version which is referenced through the API
What do these 15 digit and 18 digit ids stand for:-
The last 3 digits of the 18 digit ID are a checksum of the capitalizations of the first 15 characters, this ID length was created as a workaround to legacy systems which were not compatible with case-sensitive IDs.
The API accepts the 15 digit ID as input but will always return the 18 digit ID.


How to get the 18 digit id in the UI?
One may write code to decipher the 18 digit id from the 15 digit id but an easier way out is to generate the 18 digit counterpart in a formula field by use of caseinsensitiveid() function.


Activating inactive/ re-activating picklist values in "Stage" field of Opportunity 

Activating the inactive picklist values of "Stage" field in Opportunity is bit cumbersome. Let me explain with an example. Lets assume I have an active stage called "stage1". Several opportunities are still assigned to "stage1" and one has to delete (de-activate it). One now has a "stage1" that cannot be reactivated. If one wants to "re-activate" it, one has to create a new stage with the same percent and other properties as the inactive "stage1". Then, one would delete the inactive "stage1" and, during this process, system will ask/prompt user to replace any opportunities that are associated with "stage1" with another stage. At that time one has to select "stage2". Now the "stage1" is deleted and all the previous "stage1" opportunities are now aligned to  "stage2".

Now one has to recreate the "stage1" as an active stage. The final step is to delete "stage2" and when prompted replace it with "stage1". "Stage2" will be deleted and stage1 will now will be active again.

Friday, August 9, 2013

Data Migration (Legacy system to Salesforce) a dummy’s guide


Data is distinct pieces of information, usually formatted in a special way.  Data is the most critical asset of any organization. The criticality of data makes any activity involving data crucial and delicate. The same logic makes projects involving “Data Migration” sensitive and mandates the handling with utmost care.


As the title suggests we are going to focus on Data Migration involving Salesforce as a platform in general and in particular we are going to reflect on:-

·        What are the “n” questions one should ask before planning a data migration project?

·        How Legacy Data should be moved over to Salesforce?

·        What are the “n” numbers of things to be careful about?

·        What are the “n” things to checked in Salesforce before embarking over a data migration project? 

Questions one should ask oneself while kicking off a Data Migration Project?


1.       What is the nature of system from where data which is being brought in?
a.       Legacy system like some Orcale Database, etc.
b.       Some CRM like Sugar CRM, Net Suite etc?
              The answer to the above question gives you the following vital inputs:-
·    So there is legacy data coming from another system
·    This means that we might need to bring in information like:-
1.       Created Date, Created by information
2.       The above information in SFDC is called “Audit fields/ Information
3.       For adding information about audit fields create a case with salesforce
           Audit Fields
System fields, which are read only and store information like “created date”, “created by id” (reference to user), “last modified date” and “last modified by id” are referred to as audit fields.
Ideally Salesforce treats these fields as “read-only” and these fields are set by the system by default and cannot be modified by the user.
Though under special condition these (audit) fields can be set by special permission from Salesforce by creating a case with “Salesforce” to that effect. The permission to set audit fields is not unlimited and is revoked after some time, if you need that you should be able to set audit fields longer do create another request with Salesforce.

Also note objects like:-
·          Account Feed
·          AccountShare
·          AccountTag
Don’t have audit fields


2.       What is the nature of Data?
a.       Is there currency related data? If yes is that data in different/ multiple currencies? If the answer is yes? Then we need to get “Multi-currency” enabled in our Salesforce organization/ instance.
3.       What is the numbers of  “users” that need to be created? Or how many users have to be created? Lets say if “X” users have to be created are these necessary number of seats in the “Salesforce Instance”?
a.       The answer will decide how you will frame the strategy for carry outing the data load vis-à-vis assigning of information like
·    “Created By Id”
·    “Last modified by Id”
4.       Are there users from different Time Zones? If yes then one has to handle time related data accordingly
5.       In what format data will be provided to you?
6.       What is the minimum information you need for each object, to successfully load data? In technical terms I means what are the “Required Fields”?
7.       What are the “business rules” that have to be taken care of? For example if there are certain business rules implemented in the system by way of “Validation rules or Triggers” then how such situations will be handled? For example if you have a validation that “Date of Sale” cannot be less that today, then how will you handle loading of legacy data, which will be in past. Answer will be perhaps deactivating such validations rules or commenting a portion of trigger during data load.
8.       When you get the data extracts (say csv files) from legacy system check the columns having dates are they in correct format and value?
a.       Many times you will see date represented as numerical date value, if yes-appropriate date conversions need to be done in excel using formulas.
b.        Check if the date values in legacy system and in csv files are same?
9.       W.r.t. text fields check the data length because if you are using excel or csv to massage and manipulate data then text fields which get truncated during such instances its advisable to use: -
a.       A database for data massaging and manipulation
b.       Informatica for making data extractions and loading into database and Salesforce.
10.    Also w.r.t. Salesforce always remember in the user object there are certain felds like “Community Nickname”, “Username” , etc which are unique across the Salesforce platform so if legacy data is coming from Salesforce, data massaging will involve making these data values unique.
There are scores of questions which come to my mind, but lets park them for the next blog …

Keep watching this space for more on “Data Migration”

Saturday, January 19, 2013

Custom Settings revisited !!!


I remember nostalgically the first major technical document I penned. It was for a product/project I had worked on - and the comments of the reviewer were Ispita why do you use such flowery language ~ I guess the person was being generous~ what was implied was ~ Ispita keep it short and simple.
Such comments are always priceless - and act as sharpening stones.
Apart from the two S mentioned above I now add a third dimension - spicy. So anything I write essentially has the three S- Simple, Short , Spicy ( na na don't run your horses of imagination - spice essentially  means -  the action on peppering your textual creation with anecdotes and personal touch , don't you look for yellow journalism - u will get none).

That reminds me this is not about - "How to write in Queen's language?" this blog will talk briefly about  "Custom Settings" and in particular about those which fall in the category of List custom settings.

So what are Custom Settings?

Custom settings are just like custom objects which act as placeholders to hold information which may tied to:-
1) an organization
2) a profile
3) a specific user

This leads us to the obvious question if its similar to custom objects then why create another data structure with similar traits? What purpose does it serve?
In pure technical terms you can say - "All custom settings data is exposed in the application cache, which enables efficient access without the cost of repeated queries to the database."  In layman's language lesser use of select statements and faster code execution.
Also they act as custom application wide global variables ( These are the List custom settings).
Now coming to the type of Custom settings . There are two types of custom settings:
List Custom Settings
This is the set of data which is available to the whole organization and remains the same irrespective of the profile or user accessing it. Its the socialistic type of custom setting same for everyone across the organization.Also since its cached and does not require issuing of costly SOQL queries they don't add to your overall tally of SOQL queries issued and thus help you in not breaching the governor limits.
Hierarchy Custom Settings
But what if you need a set of data which should morph or return different info based on which category of people is accessing it or which user is accessing it? So now the custom setting is not socialistic and return information based upon the rights of the user accessing it- or information is returned keeping in view the hierarchy- those are called the "Hierarchy Custom setting".
Click on the picture below for enlarged view.

Now how to access this via code in apex.
General syntax :-

Map<string , CustomSettingName > Variable Name = CustomSettingName.getAll();   

Here w.r.t. above diagram the syntax will be:-

Map<string , AppSetting> CST = AppSetting.getAll();   
string  strURL1 = CST .get('URL').compartment1__c;    
string  strURL2 = CST .get('URL').compartment2__c;    
So strURL1 contains àhttp://login.salesforce.com   and  strURL2 contains àhttp://test.salesforce.com  

I know you will say custom settings are so easy - but believe me whenever I start using them I always tend to forget some of the steps and go about re-inventing the wheel - so this time I thought of writing the steps for future reference.