Play Games

Search This Blog

Saturday, December 28, 2013

visualforce tag

Most of the users have no clear idea about the usage of <apex:actionRegion> visualforce tag.In this post I will give a brief idea

<apex:actionRegion> :

         An area of a visualforce page that demarcates which components should be processed by the force.com server when an Ajax request is generated .

The <apex:actionRegion> component specifies the components to be processed on force.com server.If no <apex:actionregion> is defined the whole view functions as a region .
Here component means ,all visualforce tags like InputField,InputText,outputPanels etc.

Component processing includes

Conversion: converting from user inputted strings to date,numbers etc.
Validation :running validations like checking required fields.
model update :updating apex bindings i.e controller variables binded to visualforce page merge fields.


Note: Even when using <apex:region/>, the whole form is submitted but only part taken into region will be processed.

The example below will give an idea.

The following is the controller logic
public class regioncontroller {
    public String text1{ get; set; }
    public String text2{ get; set; }
}

The following is the visualforce page code.

<apex:page controller="regioncontroller ">
<apex:form >
   <apex:pageMessages id="messages1"/>
   <apex:pageBlock>
   <apex:pageBlockSection columns="2" >
      <apex:outputText value="name" />
      <apex:inputText value="{!text1}">
         <apex:actionSupport event="onkeyup" reRender="outname,messages1" />
      </apex:inputText>
      <apex:outputText value="Job" />
      <apex:inputText required="true" id="job2" value="{!text2}" />
   </apex:pageBlockSection>
<apex:outputText id="outname" style="font-weight:bold" value="Typed Name: {!text1}" />
</apex:pageBlock>
</apex:form>
</apex:page>


Now if u run the page and type something in the name textfield, u will get validation error because the entire form is submitted and everything in it goes for processing in server and since another inputtext field is made required,we are getting validation error as below



Now modify the visualforce page code as below

<apex:page controller="regioncontroller ">
<apex:form >
   <apex:pageMessages id="messages1"/>
   <apex:pageBlock>
   <apex:pageBlockSection columns="2" >
   <apex:actionRegion >
      <apex:outputText value="name" />
      <apex:inputText value="{!text1}">
         <apex:actionSupport event="onkeyup" reRender="outname,messages1" />
      </apex:inputText>
   </apex:actionRegion >
      <apex:outputText value="Job" />
      <apex:inputText required="true" id="job2" value="{!text2}" />
   </apex:pageBlockSection>
<apex:outputText id="outname" style="font-weight:bold" value="Typed Name: {!text1}" />
</apex:pageBlock>
</apex:form>
</apex:page>

Now when we run the page and type something in name text field,we will not get any validation errors because even though entire form is submitted,only the content present in <apex:actionRegion> will be sent for processing in server and  since no required field present in <apex:actionRegion> ,we donot get validation errors.The required field is present outside the <apex:actionRegion> .





Thursday, December 26, 2013

How to remove spaces from a string in salesforce

DeleteWhitespace() is used to remove all the spaces in a string.

For example "How to remove" is a string.In order to remove spaces do the following.

String str = 'How to Remove';
system.debug(str.deleteWhitespace()); //this line will give output as : HowtoRemove



Wednesday, December 18, 2013

How to get more information related to salesforce?

Most of the developers/administrators have a desire to learn more about salesforce.
The salesforce community is one of the best resource available to all.
Salesforce users are passionate about the product, and are willing to help others get the most of it.
 
Asking Questions: There are a lot of places you can ask for help. You get the best results when you ask the questions correctly.
 Do your research first. Use the custom Google search at findsf.info to search blogs, help docs and other Salesforce resources. Chances are you’re not the first person to come across the problem.

Answering Questions: Once you’ve gained a bit of experience, start answering some of the questions. Again, make sure your answers are high quality.

Answers: This is the official community at https://success.salesforce.com/answers.
This is one of the best places to get your configuration, formulas, and other “button-click”
questions answered.

StackExchange: This Q&A site at http://salesforce.stackexchange.com/ has some great answers.

Twitter: Use the #askforce hashtag to get in front of a bunch of people ready to answer your questions. Twitter also provides some great interactions with other Salesforce users. Start out by following the Salesforce MVPs.

So many salesforce users are helping others through their blogs.Go through them.
Salesforce also provides so much information here  http://developer.force.com/

In this u can find technical library,codebooks,blogs,codeshare etc.







How to access picklist values in Apex?

Sometimes we may have a requirement to get all the values of a picklist field in apex.
For example in account object ,active__c is a picklist field with values low,medium and high.
In this type of scenarios ,we need to use dynamic apex.

Dynamic apex allow us to interrogate a field or sObject, and  describe their characteristics.

The first thing we need to do, within our controller is use the getDescribe() method to obtain information on the  active__c  field:

Schema.DescribeFieldResult fieldResult = account.active__c.getDescribe();
We know that active__c is a picklist, so we want to retrieve the picklist values:
List<Schema.PicklistEntry> ple = fieldResult.getPicklistValues();
If we want to get picklist values in list do the following


 List<String> lstPickvals=new List<String>();

 
 for (Schema.PicklistEntry a : ple ) {
      lstPickvals.add(a.getValue());//add the value  to our list
   }
thats it,the lstPickvals  contains all the picklist field values 
i.e here low,medium,high.
 

Monday, December 16, 2013

How to display error message from trigger? (or) display validation error from trigger

We can display error messages from trigger.

field.addError(string):
     It places the specified error message on that field in the salesforce user interface and prevents any DML operation from occuring .
When used in visualforce controllers,if there is any inputfield component bound to field,the message is attached to the component.

This method is special because the field identifier is not actually the invoking object---the sobject record is the invoker.
 The following trigger example shows how to display error messages.

trigger testing2 on Account (after insert,after update) {

for (Account newOpp : Trigger.new) {
   
       newOpp .addError('See error  message will appear when u insert or update an account');
   

}
}

. 


  


Saturday, December 14, 2013

How to activate or deactivate a trigger in production?


step1 :
              Open your eclipse IDE and choose your project.

step 2:
            choose the trigger which u want to activate or deactivate.Below that you can see xml file related to that trigger.for example  testtrigger-meta.xml  file.The xml file  looks like this

<?xml version="1.0" encoding="UTF-8"?>
<ApexTrigger xmlns ="http://soap.sforce.com/2006/04/metadata">
<apiVersion >24.0 </apiVersion>
<status>Active</status> ---->  change this to Inactive or active as u require.


</ApexTrigger>

step 3:
            In the xml tag you can set inactive or active as required.Then deploy the trigger to server.



        

SALESFORCEA

What is SalesforceA?


It is a mobile based admin application or administrators that allows them to take actions such as remotely resetting passwords, deactivating users and receiving information about scheduled maintenance from Salesforce.com. Now you can reset password while walking on road, traveling on bus/train.


                         

Links to download app:

IOS:- https://itunes.apple.com/us/app/salesforcea/id404249815?ls=1&mt=8
Android:- https://play.google.com/store/apps/details?id=com.salesforce.chatter&hl=en

Functionality

Frozen Users
In Winter ’14 Salesforce introduced the “Freezing” function around a user which prevents that user from logging in, but isn’t deactivating them. This feature is useful if the user that needs to be deactivated is the default lead owner, has workflow rules, or an approval process associated to them. With The Salesforce Mobile Admin App this feature grows legs because now the Salesforce Admin on the go can quickly ‘freeze’ a user on their mobile device without the heavy lift of deactivating them. It’s almost like this feature was developed for the mobile app- and kudos for that.
Locked Out users
We all know that passwords and login attempts happen for users and they can lock themselves out. Having a locked out user can have an impact on key business functionality. With the Salesforce Mobile Admin App unlocking users is a couple taps away.

Viewing User Information

Viewing a User record is as simple as searching and tapping on Finally some fun returns to Salesforce and in this app it comes in the form of a rocket. Scrolling to the bottom of the homepage, holding the rocket till launches- opens the pillars of success for any Salesforce Admin: Ideas, User Groups, MVP Blog, Events, and Answers.the user. From the user record you can view and edit standard fields, reset the users password- how awesome is that- and assign permission sets. Having access to that many fields and that functionality is a game changer for any Admin who has had to wrestle a laptop out in an emergency and fuss with wifi to do those simple functions. The app also gives you the ability to view Login History- which is useful if HR or an executive is emailing you.

Permission Sets
This incredibly powerful and underused feature gets a spotlight in this app. Now your pre-defined permission sets can quickly be assigned or unassigned to a user. You can’t create a permission set yet in the app, so you will need to define your permission sets in the web interface. But having this ability again moves the power to manage your users from your desk to your pocket.


Release Notes
Critical to any Salesforce Admin’s day is the ability to quickly access the most recent release notes. With the Salesforce Mobile Admin app that is just 1 tap away from the home screen. Now, with over 300+ pages of release notes I don’t anticipate this being your only source to digest the notes, so I recommend using the search feature to find the topic that is of interest. But without a doubt, this features lets you respond to questions/ emails and keeps your laptop snuggled away.


Finally some fun returns to Salesforce and in this app it comes in the form of a rocket. Scrolling to the bottom of the homepage, holding the rocket till launches- opens the pillars of success for any Salesforce Admin: Ideas, User Groups, MVP Blog, Events, and Answers.





How to Use:

Once you Downloaded SalesforceA application from iTtune, double click on icon to open it, First time it will ask you to set the password, everytime you have to enter this passcode to access this application.

Now you are in, You can see  similar screen like below one .





 Launch the rocket and see the magic, it will open doors of success for you.Hold the rocket til launch.It will open Success community, Idea, User groups< MVP Blogs, Events and Answers Tab for you.







Tuesday, December 10, 2013

Salesforce1



 Salesforce redesigned it's own Chatter application to salesforce1, which has been described as the customer platform for the internet of customers.

Salesforce 1 is the new social,mobile and cloud customer platform built to transform sales,service and marketing apps .




Salesforce 1 is the first CRM platform for developers,ISVs,end users,admins and customers moving to the new social ,mobile and connected cloud.
Major ISVs such as Dropbox,Evernote,Kenady and LinkedIn,will be available on the salesforce 1 customer Platform
Salesforce.com customers are automatically upgraded,enabling leading companies such as ADP,Brown-Forman and Pernod Ricard to immediately run their business on salesforce1


Salesforce1 Features:


1)It offers 10x as many APIs as well as new components for building user interfaces.
2)Customers can build mobile opimized apps for any device
3)Ability to access publisher from your mobile device.
4)Salesforce1 includes the new mobile application for administrators,salesforceA that allows them to take actions from setting passwords  to deactivating users.
5)You can access all of your custom objects,fields,and any app you have built directly from your mobile device.
6)It delivers all new mobile app customization through visualforce1,a mobile oriented revamp of the visualforce page environment that customers and partners  use to create custom web user interfaces.

 Now all your sales,service and marketing data is right at your finger tips..

Look and feel of salesforce1 will be as given in below image.




Saturday, December 7, 2013

Batch processing

Batch Processing


why is it used?

 When there are large number of records(for ex thousands of records) to

process at a time,there may be problem of hitting governor limits.So,to avoid

this,we use batch processing in salesforce.

Advantage:

1)A large number of records can be processed.

2) Result of one batch cannot affect other batch.It means every batch is descrite.

How to use:

In order to use batch processing, first we need to create a class that implements

Database.Batchable<sObject> interface, then call that class in visualforce page.

Database.Batchable<sObject> interface has 3 methods

1) Global (Database.QueryLocator | Iterable<subject>)

 start(Database.BatchableContext bc){}

2)global void execute(Database.BatchableContext bc,list<p>){}

3) global void finish(Database.BatchableContext bc){}

The start() is used to get the records to be processed which are then passed as

parameter to execute().the processing is done in execute().

Finish() is used to send confirmation mails.

For example below is an example of processing all contacts and updating one

custom field in it to some value.

First is a class implementing the Database.Batchable<sObject> interface.

global class ContactReassignment implements Database.Batchable<sObject> {

 String query;

 String email;

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

 query='Select id ,Rich_Text__c from Contact ';

 system.debug('QUERY'+query);

 system.debug('hai');

 return Database.getQueryLocator(query);

 }

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

 system.debug('hai');

 system.debug('QUERY'+query);

 List<contact> accns = new List<contact>();

 for(sObject s : scope) {

 contact a = (contact)s;

 a.Rich_Text__c='testing';

 accns.add(a);

 }

 update accns;

 system.debug('#############3'+accns);

 }

 global void finish(Database.BatchableContext BC) {

 system.debug('hai');

 AsyncApexJob a = [SELECT Id, Status, NumberOfErrors,

JobItemsProcessed,

 TotalJobItems, CreatedBy.Email FROM AsyncApexJob WHERE Id

=:BC.getJobId()];

 system.debug('ksk'+a);

 String UserEmail = 'Any EMAIL';

Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();

 mail.setToAddresses(new String[] {UserEmail});

 mail.setReplyTo('ANY EMAIL');

 mail.setSenderDisplayName('Batch Processing');

 mail.setSubject('Batch Process Completed');

 mail.setPlainTextBody('Batch Process has completed');

 Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail });

 }

 Public Pagereference Updatecon() {

 ContactReassignment ACB = new ContactReassignment();

 Database.executeBatch(ACB);

 system.debug('***************'+ACB);

 return null;

 }

Next is the page calling that class.

<apex:page controller="ContactReassignment" action="{!Updatecon}">

 batch processing successful
</apex:page>


we can also schedule batch apex.
In order to schedule batch class,we need to write schedulable batch class

global class ContactReassignmentBatchSchedular implements schedulable
{
    global void execute(SchedulableContext sc)
    {
    ContactReassignment b = new ContactReassignment (); //ur batch class
     
        database.executebatch(b);
   }   
    
}


If u want to specify batch size,we can specify  in executebatch() as below
database.executebatch(b,100);

Once u wrote schedulable batch class,u need to schedule it as follows :

step 1:
Go to Setup--> develop--> apex classes
step 2:

click on  schedule   apex

step 3:

Here U can select schedulable batch class,date and time.
Thats it.Based on ur selection,the schedul apex runs..




Friday, December 6, 2013

Salesforce.com Announces New Performance Edition

Salesforce.com Announces New Performance Edition, Empowers Customer Companies to Achieve New Levels of Performance

Performance Edition will combine the world’s #1 CRM apps and platform—Sales Cloud, Service Cloud and Salesforce Platform—together with Data.com, Work.com, Identity, Live Agent, Knowledge and additional sandbox functionality in a single solution


Performance Edition will bring together the innovations companies need to drive amazing growth, achieve new levels of customer satisfaction and maximize sales and service success in today’s social and mobile world

• “Salesforce.com has consistently revolutionized the industry by delivering major innovations for sales and service, and we continue to get an incredible response from our customers,” said Alex Dayon, president, applications and platform, salesforce.com. “Performance Edition will combine these capabilities in a single solution to make it easier than ever to become a high performance customer company.”

• “Over the years, we’ve combined several salesforce.com innovations to create a holistic sales and service solution. As a result, we’ve been able to drive new levels of performance across every aspect of Enterasys’ business,” said Dan Petlon, CIO, Enterasys. “Salesforce Performance Edition is a one-stop-shop for customer success. It will put everything we need to drive performance into a single solution.”
• “Successful companies approach their sales and service strategy holistically,” said Michael Fauscette, group vice president of software business solutions, IDC. “With Performance Edition, salesforce.com is making it easier for companies to grow pipeline, shorten sales cycles and improve sales performance while delivering a consistent customer service experience across every channel—all in a single solution.”


With the rapid adoption of mobile devices, social networks and cloud computing, customer expectations have changed. During this time, salesforce.com has expanded its portfolio of #1 CRM apps and platform solutions—Sales Cloud, Service Cloud and Salesforce Platform—and introduced new offerings, including Work.com, Data.com and Salesforce Identity. With Performance Edition, salesforce.com is bringing together everything leading companies need to maximize performance across sales and service.


Salesforce.com’s most successful customers, including Facebook, Kelly Services, Schumacher Group and Varsity Brands have combined salesforce.com capabilities over time to transform into high performance customer companies. 


About Performance Edition :

 
Based on the feedback and best practices of salesforce.com’s most successful customers, Performance Edition will deliver the combination of capabilities that companies need to maximize performance and become customer companies. Performance Edition will be salesforce.com’s most comprehensive solution for sales and service, combining Sales Cloud, Service Cloud and Salesforce Platform with all of the additional capabilities in Unlimited Edition, as well as:


• Data.com: Provides access to accurate, actionable contact and business data to help sales reps immediately uncover and qualify new leads and keep their data clean
• Work.com: Unlocks peak performance of sales teams through consistent coaching, motivation and feedback available on any mobile device
• Salesforce Identity: Will provide a single, social, trusted identity service across all enterprise apps, delivered with the simplicity, transparency and trust of the Salesforce Platform
• Live Agent: Offers a web chat solution directly integrated into the Service Cloud and includes mobile capabilities that instantly connect customers with service agents to get answers in real time, from any device
• Knowledge: Provides a single place for service agents and customers to quickly and easily access knowledge articles and find solutions, directly from the Service Cloud console or on any mobile device via the company's public communities or web portals
• Additional Sandbox Functionality: Creates a copy (“sandbox”) of an organization’s production environment for integrating code, testing and user training to build and deploy customizations and apps faster


Pricing and Availability
• Performance Edition is scheduled to be available starting November 4, 2013, at the price of $300 per user, per month. 
• Unlimited Edition customers can choose to upgrade to Performance Edition or continue to use Unlimited Edition, which will continue to receive enhancements and innovations during salesforce.com’s regular upgrade cycles. 

 

Wednesday, December 4, 2013

How to escape special characters in formula?(or) How to escape special characters in javascript written in salesforce?

When we are writing  formulas or javascript code, if the values contains special symbols like aphostrope('),&(ampersand) etc sometimes we won't get expected results.

For example

account name contains O'Henry.Notice that  ' is a special character.When ever u r writing javascript if we write {!account.name}.It will give an error.



So to escape special symbols use JSENCODE function.


JSENCODE() :

                              Encodes text and merge field values for use in javascript by inserting escape characters ,such as a backslash( \ ), before unsafe javascript characters ,such as the apostrophe ( ' ).

Use:

              {!JSENCODE(text)}   and replace text with the merge field  or text string that contains the unsafe javascript characters


How to get colour code of particular color?

How to get colour code of particular color?


In most of the cases,we need to know the color codes.
For example in styling html document or in styling visualforce page.
Sometimes some images will be given and the client says i need the colors present in that images.
For this we need a tool to know color codes.

Color Pic is a tool  which will help u.
Just install color pic and use it.If we locate particular color in image,it will give that color color code.

Steps:
step 1:

Download the color pic tool software from the following url
http://www.iconico.com/colorpic/

Step 2:

Install it.
Step 3:click on start button of computer-->select all programs.In that click color pic.Thats it.If we move mouse pointer to any color,its color code is displayed.

Given below images will help u.

Color Pic Tool






Tuesday, December 3, 2013

How to create step by step progress bar in visualforce page

How to create step by step progress bar in visualforce page

There will be rquirement to show progress after completing each step for example while creating resume in job portals,we find step by step progress bar.

In order to do that,I am posting the sample code.

<apex:page>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js"></script>
<script>
function setProgress(progress)
{          

    var progressBarWidth =progress*$(".container").width()/ 100; 
    $(".progressbar").width(progressBarWidth).html(progress + "% ");
}
</script>
<style>

.container{
    width: 300px;
    border: 1px solid #ddd;
    border-radius: 5px;
    overflow: hidden;
    display:inline-block;
    margin:0px 10px 5px 5px;
    vertical-align:top;
}
</style>
<body>
<div class="container"><div class="progressbar" style="color: #fff;text-align: right;height: 25px;width: 0;background-color: #0ba1b5;
    border-radius: 3px; " >test</div></div>

<div onclick="setProgress(80);">testing</div>
</body>

</apex:page>


Note:1)In order to change progress just change width i.e argument to setProgress() .for example
setProgress(10),seProgress(20)  etc.

2)Must include jquery library files.



Hope U Enjoy..

Monday, December 2, 2013

How to use images in Email templates in salesforce

How to use images in Email templates in salesforce

If u place images in static resource and access them in email templates sometimes images would not display.So it is recommended to follow the below procedure.

Step 1:
Upload the image to document.

Step 2:

On the image right click-->copy image location

Step 3:
replace src with the copied url.
For example the url will be like this

In visualforce email template

<apex:image id="imageid"  value="https://na7.salesforce.com/servlet/servlet.ImageServer?id=015D000000Dpwc&oid=00DD0000000FHaG &lastMod=127057656800 height="70" width="80"/>

In custom email template

<img  id="imageid" src ="https://na7.salesforce.com/servlet/servlet.ImageServer?id=015D000000Dpwc&oid=00DD0000000FHaG &lastMod=127057656800 height="70" width="80"/>
 

Important Links to prepare for salesforce certification exams.(401,201)

Important Links to prepare for salesforce certification exams.

http://bulkified.com/Certifications/?certificationId=1

http://www.forceprepare.com/index.html

http://wenku.baidu.com/view/bfcdd74fc850ad02de804177.html

http://certification.salesforce.com/Developers

http://ajanya.com/


http://www.proprofs.com/quiz-school/story.php?title=salesforce-dev-401-mock-exam

http://www.proprofs.com/quiz-school/story.php?title=salesforce-certification-dev-401-2

http://www.proprofs.com/quiz-school/story.php?title=salesforce-certification-dev-401-3

http://www.proprofs.com/quiz-school/story.php?title=salesforce-certification-dev-401-4

http://salesforcedumps.blogspot.in/2012/02/dev-401-dumps-part-i-sf-dev-401-dumps-1.html

http://forum.aslambari.com/discussion/30/dev-401-dumps/p1

http://mysalesforcecode.blogspot.in/2009/03/developer-401-forcecom-exam-tips.html