Sunday 2 November 2014

Salesforce Entitlement, Entitlement Process & Milestone Handling

Entitlement : 

Entitlements are the same as the normal objects we use in Salesforce like Account, Contacts etc.
Adding to it, its a child object to Case, Contracts etc.


Purpose of Entitlement in Salesforce is specifically for
  • Enforce service levels with time-dependent, automated processes that instruct agents how to resolve cases.
  • Defining Service levels.

Entitlement according to Salesforce-phere
Entitlement is driven by "Entitlement Process" Object (Look-up on Entitlement Object ) where we set "Milestones" and "Business Hours"

1. Milestones :- Milestones are actually automated time dependent workflow, which run on the time set by the user, in other words to automate the SLA, this is the key of whole Entitlement thing in Salesforce. You can define the actions in Milestone i.e. Field Update, Email Alerts same like normal workflow. 

2. Business Hours : It is used to define the limits of the Milestone Time that have been set by the user like working hours in which a case should be handled.

Enabling & Setting-up Entitlement

Go to Setup --> App Setup --> Customize --> Entitlement Management --> Entitlements

Click Check and Save

after saving you'll get this check according to your requirement and Save. Do check last check-box of Enable Milestone Feed Items, this will add milestone box in your feed item, where Milestone Status will be more visible to the users.


Now go to Entitlement Process create one Entitlement Process

Here is the Entitlement Process created


Above in the setup list there is Milestones, create one

Now create an Apex class, that will set the Trigger time for the milestone, create a custom Number field on Case named as "Milestone Time" and create this class which implements "Support.MilestoneTriggerTimeCalculator"


























Now whatever will be the value in the this field will be set as Time trigger of Case Milestone
We will use this class, while adding Milestone with an Entitlement Process.

Now return back to Entitlement that we have created earlier and and down to it click "new" button in Milestone section, and fill the values same as shown in below


We have done all the setup for the Entitlement Process and Milestone
Now we will create an Entitlement Record, (Don't get confused with Entitlement Process and Entitlement)

Entitlement Process

System object that have Milestones and is used while creating Entitlement (API name SLAProcess ) record.


Entitlement: 


Its an object, that will be associated with Case. It is as normal as other objects like Account, Contact. This is used to attach Case Milestone to the object.

We will create Entitlement record now, that we will attach to the case, search for the Entitlement Tab and click  new, create a new record as shown below, as marked below these field should be field to make Entitlement active otherwise you can't attache it to the Case as shown Status Icon it green check that means its active, you need to provide Start Date  for it, Entitlement process also need to be provided otherwise no Milestone Time will be on the Case, after saving entitlement record you can see the Milestone will be visible under the Milestone.


Now go the case, in the below snapshot, all those field which is used in Entitlement process are shown, we will create a new record of Case and in the Entitlement Name we will put the record that we have created above,
There is a Timeline field on Case layout,which show scale view of the Time that have been setup. Modify the layout and set Case Milestone related list as well

If user didn't close the case or whatever is the procedure to be done to close the case then case will be Violated that automated process, and then Milestone Status will be change.

Look we are done with Entitlement and Milestone thing of Salesforce
You can Milestone actions as well, go to the Entitlement process and Click on the related Milestone of it where you can action like Field Update and Emails alerts etc.

The biggest problem I faced with this functionality when I tried writing trigger on Case Milestone Violation, and attaching other Milestone with the Case. you can write on case on check of "Milestone Status" field that when the status changed to Open violation. but attaching other Milestone on the violation of the first one is not happening.

This is what I learned while working with Entitlement and Milestone of Salesforce.
Thank you, any queries will be appreciated, keep learning-keep coding.

Happy Coding!

Tuesday 1 July 2014

Basics of Apex Batch Class in Salesforce

What is batch class?

Batch class is just similar to Apex class except that batch class includes the Salesforce provide interface “Database.Batchable”.

Why we use batch class?

When we want to perform DML operations for bulk records or hit the web service then batch class comes in the picture.

Database.Batchable interface contains three method.
  • Start
  • Execute
  • Finish


Start Method

               global Database.QueryLocater start(Database.BatchableContext bc) {}

  • Use this method to get the records from database or object to be passed to “Execute” method.
  • This method returns Database.QueryLocater object that contains the records.
  • Query fired in the start method will return maximum 5,000,0000 records in a transaction.


Execute Method

           global void execute(Database.BatchableContext bc , List scope) {}


  • This method is used for do all the processing for data.
  • This method takes two arguments.
  • A reference of Database.BatchableContext object.
  • A list of sObject records.
  • The logical part of the code to process the data will be write in the execute method.


Finish Method

                global void finish(Database.BatchableContext bc) {}

  • This method takes only one argument a reference of Database.BatchableContext object.
  • This method is called when all the batches are processed.
  • This method is used for sending confirmation email to user or post-processing operations.


Here is the sample code

:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

global class batchAccountUpdate implements Database.Batchable<sObject> {

    global Database.QueryLocator start(Database.BatchableContext BC){

        String query = 'SELECT Id,Name FROM Account';
        return Database.getQueryLocator(query);
    }

   global void execute(Database.BatchableContext BC, List<Account> scope) {

        for(Account a : scope) {

             a.Name = a.Name + 'Updated';
         }
         update scope;
   }  

   global void finish(Database.BatchableContext BC) {
    }
}

:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::


How to execute/run batch class?

                   Id batchID = Database.executeBatch(new BatchClass() , Batch_Size);

  • This method is used for execute the Batch class.
  • This method returns the ID of the AsyncApexJob object.
  • This method takes two arguments.
  • An instance of the batch class
  • Batch size(Optional)
  • User can see the batch status or abort the batch anytime from the Apex Jobs.


How to schedule batch class ?

      Id schJobId = System.ScheduleBatch(new BatchClass() , ‘Job Name’ , Time_Interval , Batch_Size)

  • This method is used for schedule the batch job to run once in a specific time period in future.
  • This method will return the Scheduled Job Id(CronTrigger Id) click here for CRON.
  • This method takes four arguments                    
                              1. An instance of batch class
                              2. Job Name
                              3. Time Interval
                              4. Batch_Size(Optional)

  • To schedule batch class at a specific time scheduler class will be used.
  • Schedule class similar to Apex class except that it also includes Salesforce Provide Interface “Schedulable”.
  • Next, schedule the class either using Salesforce Apex page in user interface or using System.schedule method.


Why Database.Stateful ?

  • This is used for maintain the state across the transactions.
  • If you don’t specify the Database.Stateful, all Static and Instance member variables are set back to their original values.


Why Database.AllowCallouts ?

  • To use web service callouts in the batch apex, you must specify Database.AllowCallouts interface in the batch class definition.


Governor Limits for Batch Apex

  • Default batch size is 200.
  • Avoid SOQL queries inside for loop.
  • Maximum 5 batches can be run at a time in org.
  • Total number of sendEmail methods allowed per transaction is 10.
  • Total number of future methods allowed per transaction is 10.
  • Always use database methods like insert,update,upsert in the batch class.

Saturday 21 June 2014

#Salesforce Integration With Twilio

I was searching Twilio integration with salesforce on the web but didn't find any, so am posting this a simple POC of sending SMS to the mobile using Twilio from the Salesforce UI.


Its simple but just you need to do something extra two make this functionality working.

We will go step by step for this
First of all create a new account on Twilio click here 
Twilio will provide you a number, via which it will sent you SMS.

Now login to your salesforce account and create a Remote Site Setting.
In Remote Site URL enter https://api.twilio.com, like shown below

And then create a custom setting named as Twilio Configuration.
We are gonna use them in our apex classes.
Create fields on the custom setting you've just created, with same API name as below shown.


Now we need to provide some values to the fields ofthe custom setting click on Manage button shown above.

Before entering any values to the fields click on these links
For Auth Token and Account SID Click Here
For Test Credetials i.e. Test Account SID and Test Auth Token Click Here

For Account Name enter the name from which you registered like your email id.
For From Phone Number enter that number which got when you created account on Twilio.
After that save your custom setting.

Custom Setting should look something like this


After that you can save the code provided here GitHub 

Page will look something like this




See that was a piece of cake :)
Hope everything works just fine.
Happy coding..!!!

Tuesday 17 June 2014

Basics of Apex Trigger for beginners

The basic logic of trigger is too huge to cover, I have tried a bit to make everyone understand that how this Apex trigger, a "pain in ass" works, I'll go step by step process of writing apex triggers.

What is Apex Triggers ?

A Trigger is Apex code that executes before or after the following types of operations:
  • insert
  • update
  • delete
  • merge
  • upsert
  • undelete

Types of Apex Triggers


  • Before Triggers: Before triggers can be used to update or validate record values before they are saved to the database.
  • After Triggers: After triggers can be used to access field values that are set by the database (such as a record's Id or last Updated field), and to affect changes in other records, such as logging into an audit table or firing asynchronous events with a queue.
Example : before insert, after insert, before update, after update, before delete, after delete

Syntax of Trigger

Things to keep in mind while writing apex trigger

  • Bulkify your Code : Use Looping through Trigger’s collections variables instead of process through particular indexing.
  • All triggers are bulk triggers by default, and can process multiple records at a time.
  • Bulk triggers can handle both single record updates and bulk operations like: Data import, Force.com Bulk API calls.
  • Bulkify your Code : Use Looping through Trigger’s collections variables instead of process through particular indexing.
  • Avoid SOQL Queries or DML statements inside FOR Loops: An individual Apex request gets a maximum of 100 SOQL queries before exceeding that governor limit. 
  • Bulkify your Helper Methods: if a trigger uses some Apex methods written in a helper class, it's important that those shared Apex methods are properly designed to handle bulk records. These methods should be written to be invoked with a set of records, especially if the method has a SOQL query or DML operation.
Use @future appropriately:
Here is a list of governor limits specific to the @future annotation:
  • No more than 10 method calls per Apex invocation.
  • No more than 200 method calls per Salesforce license per 24 hours.
  • The parameters specified must be primitive datatypes, arrays of primitive datatypes, or collections of primitive datatypes.
  • Methods with the future annotation cannot take sObjects or objects as arguments.
  • Methods with the future annotation cannot be used in Visualforce.

Use efficient collection variable of apex triggers




Try using sets and maps to handle bulk record processing.



TRIGGER BEST PRACTICE

  • Always use helper class in your trigger, and in helper class perform all your logic. like below
  • Don't write more then one trigger on an object, try to add up all your new trigger in a single trigger using different-different helper classes to read more click Order of Execution
There is allot to take care of when writing apex triggers, but I found these to helpful.
Hope this helps 
Happy coding.!!!




Sunday 1 June 2014

Salesforce Multi-Select Picklist Using JQuery

I have implemented this good looking mulkti-select picklist on our Salesforce Visualforce pages.
It is so easy to handle and more user friendly as it looks.


User can select multiple option as it does in Salesforce Mutli-picklist fields, and values will be succesfully get saved in database.

User can choose more then one option by check options write in the front of the values.


You need to refer Jquery and Javascript from the static resource.

Here is the Visualforce Page code Visualforce Page

Here is the Apex class

Here is the link of github repo https://github.com/abhitripathi/MultiSelect-Jquery

Happy Coding..!!!

Wednesday 28 May 2014

Book Review : Getting started with SOQL

Recently I got an opportunity to review the book "Getting started with SOQL"by Magulan D.
The book contains all the aspects of Salesforce Object Query Language(SOQL). Here are my thoughts...

The books starts with the basics of SOQL, difference of SOQL and SQL and valuable implementation of SOQL and then all the clauses that we use in SOQL.
Most of the time developers didn't know what they can do with SOQL. As a developer or as an administrator in Salesforce.com, we write many SOQL statements to fetch and validate the data present in the objects.

The sample queries used in the book will help you to understand the SOQL features easily. the sample queries are intended for beginners and for developers or administrators who are new to Salesforce.com.
This book also addresses the standards and guidelines to be followed when writing SOQL statements. The standards and guidelines discussed in this book will help you to write SOQL statements without hitting any limitation set by Salesforce.com and to avoid unwanted data fetched through the queries.

Feature of SOQL is so vast, but for the beginners as well as for experts this book will teach something, even I learned allot those things that I was not using most of the time in SOQL like toLabel() method. The use of Date literals with their example implementation in the queries.

The traditional method of explaining clauses like how to write SOQL, Where to use Caps and where not, that we need to take care of whenever writing an apex class. Limitation is the one difficult thing to handle in salesforce and if we are talking about SOQL then its limitation are most important thing to take care off. In the book limitation of SOQL have been explained in a brief way.

In the end of the book author explained the some tools that we can use to execute queries, he have explained the steps of installation and how to take their best use with SOQL queries, I never used Force.com Explorer software but now am gonna to use this one.

I recommend especially those who want to expertise in SOQL or want to know the key things of SOQL at first place, surely it will help them out.
Book can be purchased from Packt, Goodreads, Amazon, Books.google

Monday 26 May 2014

Lazy loading tree with Force.com

I was trying to find something new to work, but nothing was making me eager to do that thing, and then I found out Jeff Douglas post of Original Post
Its an awesome post like he post every time, then I tried that thing in my personal salesforce org, and within few minutes I can see that tree in my org.

He's is using Jstree, its a jquery plugin, that provides interactive trees.
To know more about JsTree www.jstree.com

So that was so simple, and too much awesome, I would love to thank Jeff for doing such great things.
What he's exactly doing is to load an Objects tree, using Jquery, jsTree and Rest Javascript and using Lazy Loading.
There is a component that he created and called that component on the page.

Here how the tree looks

Here is the Steps need to perform

1. Create an Object named Parent Object.
2. Add a parallel look-up to the Parent Object of its own. Name the field "Parent Object".
3. Create a component named as "lazyLoadingTree". paste this code LazyLoadingTree
4. Create a Visualforce Page, name it ParentObject, paste this code ParentObject

5. Here is the Static Resource that you need to create, this is called from the Component that we created earlier, you cannot save your component without this restJavascript

Cheers..!!!
Happy Coding :)

Friday 16 May 2014

reCaptcha Using HTML and Javascript ONLY...

Googles reCaptcha , its so easy to use it using PHP and .NET plugins, but I was trying to make it work only by HTML codes,

You can read this post of for reCaptcha without plugin CLICK ME
Unfortunately I tried to search, but everybody is using PHP, and upload that PHP file on server, to use it and make reCaptcha working, but I want a single code to make reCaptha working.

Here how it looks


As my code is not perfect, I have not done anything for the errors, but yes the reCaptcha's verification is working just perfect, it fetches response and shows it to you.
Here is the code(just paste it buddy)
reCaptch HTML

Hope I've helped..!!!

CHEERS :)



Tuesday 6 May 2014

Opportunity "Probability" Field value assignment via "Stage" Field on VF Page

As you go to the Opportunity standard edit page, when you change the value of Stage field, the Probability fields value change accordingly like 10% or 30%. But the same functionality is not inherited by the VF page, so to perform this standard functionality we need to modify our VF page, as I have done.

This post is all about setting up the values of the Probability field of Opportunity associated to the Stage fields, as if you try this normally using VF page, this functionality doesn't work as standard salesforce functionality does, but doing some javascript stuffs, it can be done.

Here how it looks on VF page, by default these values are shown

Now change the Stage field value

Here the Probability field values changes with Stage value, as salesforce Standard functionality does.

Here is the small code for this,
VF Page Code


Happy Coding..!!!

Wednesday 23 April 2014

Branding Of Your Salesforce Login Page

Login Page Branding:
Salesforce winter 14 release Bring a New Feature Login Page Branding, able to customize salesforce login page with their own Brand. Now you can change the look and feel of your login page by adding a background color, custom logo, and right-frame content.
Follow the Below Simple Steps to Do It.

Step 1 :

Your Name --> Setup --> Domain Mangement --> My Domain


Step 2 :
Provide your Domain Name


Step 3:

You will receive an email on your Email which you have provided in Salesforce Org, Click on that URL and get Logged in.


Step 4:

GO TO --> Your Name --> Setup --> Domain Mangement --> My Domain

Then click on Deploy To Users


Step 5:

Click on Edit button under Login Page Branding Section.


Step 6:

Upload a Logo and Click Save


Step 7:

Go to your Domain URL, that you got in email, and you can have some thing like this.


Isn't is looks good :)

Monday 14 April 2014

Login Page With CSS Styling in Salesforce


Once I need to create a login page for salesforce sites, but it should look nice, so I used CSS to make my Login page look good, am sharing this, so that you don't waste time in just styling a Page.

Its as simply and perfect as it looks


Isn't it looks good,

Here is the CSS Style code, save this file in CSS format and make it a Zip file and save it in static resource.
"LoginStyles.css"

Here is the Apex Class (this is not perfect, You need to make changes to save)
"LoginController"

Here is Visualforce page.
"LoginPage"

Hope it will save some ones time.

Happy Coding..!!! CHEERS :)

Tuesday 8 April 2014

Dynamic Look-up of all Objects, To Make Your Life Easy #Salesforce

Some days ago, I got an requirement of mass updating, everything was just fine but got stuck at Dynamic look-up, where I need to make a single look field but if user want to that he can change it to the another Objects look-up and save the record.

That means if I want to create a single look field having dependent on another picklist of Object Names,
If user selects Account Object, then our look-up field will pop-up the records of Account object.

But if user change the Object in the picklist and now he selects Contact object, then our look-up field will pop-up Contact records.

Here is the Snapshot for more understanding.

When you chose Account

And when you chose Contact from the picklist

Then your pop-up window will show me Contact records

The code is so simple but I just like the functionality so I thought to post it.
Hope some of you will like it.

Here is Controller Class "DynamicLookupController"

Visualforce Page "DynamicLookup"

Happy Coding..!!!! CHEERS


Thursday 3 April 2014

Salesforce DEV 401 Certification Experience

I have just passed my Salesforce Developer Certification DEV 401, I was kind of afraid of it, because of the irony that I failed once already, so I don't want to repeat my past again.

My heart was gonna come out from my chest, when I was going to click on "SUBMIT" button, but let me tell you, its still in my chest.
Anybody, with determination can pass the examination, I found these questions usefull when I was preparing, hope this will help you all.
And I have some dumps, and study material to prepare, specially for DEV 401.

Only 3 things that I would like to refer all of you for the examination.

1. Sidhesh Kabe's Book of Salesforce.
2. Recruiter App. (Here)
3. Test yourself by propofs mock tests


Practice Test 1
Practice Test 2
Practice Test 3
Practice Test 4



And here is some question, that will help you, for more dumps you can email me.


Which of the following is related to View layer in MVC Model?


A. Workflow Rules
B. Validation Rules
C. Visual force Pages
D. Custom Objects
E. Apex Class



Which of the following represents controller in Model - View - Controller Model?


A. Tabs
B. Page Layouts
C. Custom Fields
D. Visual Force Pages
E. Apex Classes



Universal Recruiters wants to make access to records in such a way that all managers should be able to access records that are accessible to their team members. Which feature of Force.com's security should be used to implement this requirement. Select the one correct answer.

Object level access to profiles
Field level access to profiles
Organization wide defaults
Role hierarchy
Sharing rules
Manual sharing



Which of these is true about the Lookup Relationship. Select one correct answer.


Parent is not a required field and may be omitted.
Deleting an object deletes its children.
Roll-up summary field can be used to perform basic operations over all children of a parent record.
Security access of the child record is dependent upon the parent record.



Which of the following cannot be used to build a complete Custom Tab. Select one correct answer.


Display an external web page.
Display data using a VisualForce page.
Show data from a custom object using the native user interface.
Display the approval process using an Apex page.



Which of the following can not be translated via Translation Workbench?


A. Custom Report Type.
B. Standard Field Help.
C. Validation Error Message.
D. Report Name



Roll Up Summary fields work in which kind of relationship?



A. Many to Many Relationship.
B. One to One Relationship.
C. Master - Detail Relationship.
D. Lookup Relationship.



Based solely on the role hierarchy a manager can do all of the following EXCEPT:


A. View, edit, delete, and transfer his/her and his/her subordinate's records
B. Extend sharing on both his/her and his/her subordinate's records
C. View all folders his/her subordinate has access to, i.e., Reports, Documents, and Email Templates
D. View records his subordinate does not own but can view



Under what circumstances would the sharing button to be enabled on a detail view for a record.

A. A developer has added the button to the page layout
B. When record sharing is enabled in the user profile
C. When record sharing is set to public read only or private for the object
D. When record sharing is set to public read/write for the object



A developer has created a time-based workflow that escalates a Lead record 10 days after it has been created if no updates have occurred. What is the best way for the developer to test that the new time based workflow rule is functioning?


A. Create a new lead record; view the outbound messages queue
B. Setup the developer for time-based workflow queue; create a new lead record; view the time-based workflow queue
C. Create a new lead record; view the time-based workflow queue
D. None of the Above



All the very best for your Exam...!!!

Thursday 13 March 2014

Salesforce Cron Format

For those unfamiliar with "cron", this means being able to create a firing schedule such as: "At 8:00am every Monday through Friday" or "At 1:30am every last Friday of the month".

A "Cron-Expression" is a string comprised of 6 or 7 fields separated by white space. The 6 mandatory and 1 optional fields are as follows:


Field Name              Allowed Values           Allowed Special Characters

Seconds                         0-59                    , - * /

Minutes                         0-59                    , - * /

Hours                           0-23                    , - * /

Day-of-month                    1-31                    , - * ? / L W C

Month                       1-12 or JAN-DEC             , - * /

Day-of-Week                 1-7 or SUN-SAT              , - * ? / L C #

Year                    (Optional) empty, 1970-2099     , - * /

The '*' character is used to specify all values. For example, "*" in the minute field means "every minute".



The '?' character is allowed for the day-of-month and day-of-week fields. It is used to specify 'no specific value'. This is useful when you need to specify something in one of the two fileds, but not the other. See the examples below for clarification.

The '-' character is used to specify ranges For example "10-12" in the hour field means "the hours 10, 11 and 12".

The ',' character is used to specify additional values. For example "MON,WED,FRI" in the day-of-week field means "the days Monday, Wednesday, and Friday".

The '/' character is used to specify increments. For example "0/15" in the seconds field means "the seconds 0, 15, 30, and 45". And "5/15" in the seconds field means "the seconds 5, 20, 35, and 50". Specifying '*' before the '/' is equivalent to specifying 0 is the value to start with. Essentially, for each field in the expression, there is a set of numbers that can be turned on or off. For seconds and minutes, the numbers range from 0 to 59. For hours 0 to 23, for days of the month 0 to 31, and for months 1 to 12. The "/" character simply helps you turn on every "nth" value in the given set. Thus "7/6" in the month field only turns on month "7", it does NOT mean every 6th month, please note that subtlety.

The 'L' character is allowed for the day-of-month and day-of-week fields. This character is short-hand for "last", but it has different meaning in each of the two fields. For example, the value "L" in the day-of-month field means "the last day of the month" - day 31 for January, day 28 for February on non-leap years. If used in the day-of-week field by itself, it simply means "7" or "SAT". But if used in the day-of-week field after another value, it means "the last xxx day of the month" - for example "6L" means "the last friday of the month". When using the 'L' option, it is important not to specify lists, or ranges of values, as you'll get confusing results.

The 'W' character is allowed for the day-of-month field. This character is used to specify the weekday (Monday-Friday) nearest the given day. As an example, if you were to specify "15W" as the value for the day-of-month field, the meaning is: "the nearest weekday to the 15th of the month". So if the 15th is a Saturday, the trigger will fire on Friday the 14th. If the 15th is a Sunday, the trigger will fire on Monday the 16th. If the 15th is a Tuesday, then it will fire on Tuesday the 15th. However if you specify "1W" as the value for day-of-month, and the 1st is a Saturday, the trigger will fire on Monday the 3rd, as it will not 'jump' over the boundary of a month's days. The 'W' character can only be specified when the day-of-month is a single day, not a range or list of days.

The 'L' and 'W' characters can also be combined for the day-of-month expression to yield 'LW', which translates to "last weekday of the month".

The '#' character is allowed for the day-of-week field. This character is used to specify "the nth" XXX day of the month. For example, the value of "6#3" in the day-of-week field means the third Friday of the month (day 6 = Friday and "#3" = the 3rd one in the month). Other examples: "2#1" = the first Monday of the month and "4#5" = the fifth Wednesday of the month. Note that if you specify "#5" and there is not 5 of the given day-of-week in the month, then no firing will occur that month.

The 'C' character is allowed for the day-of-month and day-of-week fields. This character is short-hand for "calendar". This means values are calculated against the associated calendar, if any. If no calendar is associated, then it is equivalent to having an all-inclusive calendar. A value of "5C" in the day-of-month field means "the first day included by the calendar on or after the 5th". A value of "1C" in the day-of-week field means "the first day included by the calendar on or after sunday".

The legal characters and the names of months and days of the week are not case sensitive.


Pay attention to the effects of '?' and '*' in the day-of-week and day-of-month fields!

NOTES:

--> Support for the features described for the 'C' character is not complete.
--> Support for specifying both a day-of-week and a day-of-month value is not complete (you'll need to use the '?' character in on of these fields).
--> Be careful when setting fire times between midnight and 1:00 AM - "daylight savings" can cause a skip or a repeat depending on whether the time moves back or jumps forward.

A normal scheduling expression to for a Scheduler Class that will run on every Friday of the Week at 4 PM.

Sched_WeeklyStatus m = new Sched_WeeklyStatus();
String sch = '0 0 16 ? * FRI';
String jobID = system.schedule('Send Reminder for Work Status', sch, m);


To schedule every 15 minutes, use below one

System.schedule('Scheduled Job 1', '0 0 * * * ?', new ScheduledClass());
System.schedule('Scheduled Job 2', '0 15 * * * ?', new ScheduledClass());
System.schedule('Scheduled Job 3', '0 30 * * * ?', new ScheduledClass());
System.schedule('Scheduled Job 4', '0 45 * * * ?', new ScheduledClass());

Happy Coding..!!!!

Thursday 13 February 2014

Calender Home Page Component Using Visualforce Page

This is one of the simple, easy but good looking post. In this one I have done nothing extra effort. It is just a component on your home page layout where you can Write your note, Create event and task just by one click. No need to go to home page for the calender and all the stuffs related to it.

Here how it looks, not too bad I think..!!


To add this on your home page layout, first thing need to do is to create a Visualforce page
Click here Calender Component

After saving your Visualforce page

Go to ==> Setup --> Home --> Home Page Components --> New

Write the Name --> Select HTML Area --> Next

Then paste this code just as shown
<iframe src="/apex/Calender" width="100%" height="100%"></iframe>


Then click Save
Now go to SetUp --> Home --> Home Page Layouts --> Edit


Click Next --> Set the Position of your component and click Save.
Hope helped someone.

Friday 7 February 2014

Show IP Address on Visualforce Page Salesforce

This is one of the thing, that previously I never thought that it would be help full, but at some point it is.

When you want some where to show the current user's Ip address on page, OR weather you want to restrict a User of a particular IP then you can use this small code snippet with some booming functionality.

Apex Class ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

public class IPAddress {

    //Variable to hold the IP Address value for current logged in user
    public String ipAddress {get; set;}

    //Constructor
    public IPAddress() {

        //Map to hold current URL header parameters
        Map<String, String> mapHeaders = ApexPages.currentPage().getHeaders();  

    //Proceed further only and only if map of header parameter have not null value with it
        if(mapHeaders != null) {

            ipAddress = mapHeaders.get('True-Client-IP');
            if(ipAddress == null){
                ipAddress = mapHeaders.get('X-Salesforce-SIP');
            }
        }
    }
}

:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

VisualForce page ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

<apex:page controller="IPAddress">

<h1> Current Logged In User IP Address ::::: </h1>   {!IpAddress}

</apex:page>

:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

and here it is..!!!!


HAPPY CODING...!!!

Friday 3 January 2014

Javascript Data Table in Salesforce

Salesforce provides its own datatables attributes to show your data on visualforce pages, but its kind of slow and requires heavy coding to add Sorting and Paging things on it.
So if we try for javascript for this purpose, its so easy and fast on the UI.

Here I have created a Generic Component where, developer just need to pass the name of the list(having records of an Object), with Name of the headers of the list. and that component will do everything to show a multifunctional table on the page.

And then table will look something like below, having records of Account object.


You can check the functionality of the above table on this link Javascript Datatable

Here is the Visualforce page using a Component.

:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
<apex:page Controller="JQDatable">

  <!-- Calling component having list and Header of the table -->
  <c:DataTableComponent listOfRecords="{!accounts}" fieldHeader="Name,Phone,AccountNumber,Type,Owner.Name" />
</apex:page>

:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

Developer just need to pass the name of the List with correspinding name of the fields here is the Controller class of the above pages

:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
public with sharing class JQDatable {

  //List of Account
  public List<Account> getAccounts() {
     return [SELECT Id, Name, Phone, AccountNumber, Type, Owner.Name FROM Account];
   }
}

:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

All this simple code showing such functionality becuase of the component, refer these below links to have the Component as well as Jquery and CSS files that have been used.

Here is Component and its Controller
Datable Component Controller
Datatable Component

Jquery and Css files used in Static resource()
jquery.js
jquery.dataTables.js
Demo_table.css

After saving all above, you can have a Generic Component to show a multi-functional Data table in salesforce.

Happy Coding...CHEERSSS..!!!!