Sunday 1 October 2017

How to Implement Java script in VF Page Step by step

                What is the JavaScript & How to use in                                 Visualforce Pages


JavaScript is the programming language of HTML and the Web.

Below is the Link. In which you can read briefly.


How to define Java script in Vf page: Through Sript tag we can define Javascript in Vf Pages.

Example:

<apex:page >
    <apex:outputLabel>FirstName</apex:outputLabel>
    <script>
      alert("This is script");
    </script>
    <apex:outputLabel>LastName</apex:outputLabel>
</apex:page>

STEP - 1

Script is Executing in sequence order and we are not invoking the script from any where.


 You get a alert then click on ok , LastName will show because it's flow in sequence.

FirstName
Script
LastName












STEP - 2

I don't want to script executed itself. I want to invoke my script on my requirement.

Whenever any event is occurring Like - Onclick, Onchange, Onblur, Onfocus. Whenever event occur, I want to invoke script.

So for this we will use function in script.

Syntax: Function functionname(){}

Example: 

<apex:page >

    <script>
       function show()
           {
      alert("This is script");
           }
    </script>
        <apex:form>
    <apex:inputText onchange="show()"/>
    </apex:form>

</apex:page>









Example 2:

<apex:page >
    <script>
       function show()
           {
      alert("This is script");
           }
    </script>
        <apex:form>
    <apex:commandButton value="ClickJavascript" onclick="show()"/>
    </apex:form>

</apex:page>















When we will click on button then javascript function will call.

STEP - 3

Requirment is I want to my name in javascript pop up, So how we can do that.

For this we need syntax like that:

Document.getElementByid('{!$Component.id}').value
Document.getElementByName('{!$Component.name}').value

How to define the way:

Var name = Dcoument.getElementById('{!$Component.id}').value

Any type of variable we can store in var like: String , Double , Integer. 

Don't define any string , Integer , Double. Please define var, it's denote everything which variable you want to use.

var is commmon variable.

Example:

<apex:page id="pg">
  <apex:form id="fm">
      <apex:inputText id="name" onchange="show()"/>   
      <script>
               function show(){
               var myname = document.getElementById('{!$Component.name}').value;
               alert(myname);
              }
      </script>
  </apex:form>

</apex:page>

Whenever data will change in input text then in popup your text will display.









If you are not comfortable with Component. You think that it's difficult so you can define from another way.

Var myname = document.getElementById('page:form:id').value

Means that , Suppose you have declare ids.

<apex:page id="pg">
<apex:form id="fm">  
<apex:inputtext id="name"/>

// there is another way you can define

Var myname = document.getElementById('pg:fm:name').value;


Example:

<apex:page id="pg">
  <apex:form id="fm">
      <apex:inputText id="name" onchange="show()"/>   
      <script>
               function show(){
               var myname = document.getElementById('pg:fm:name').value;
               alert(myname);
              }
      </script>
  </apex:form>
</apex:page>


Full Architecture of running:

 var myname = document.getElementById('pg:fm:name').value;

Take the reference of page id after Take reference of form id after Take reference of input text id.

It fetch the ids and print the value in the popup which you will change in input text.

STEP - 4 

REQUIREMENT is I want to age along with name , How?

<apex:page id="pg">
  <apex:form id="fm">
      <apex:inputText id="name" onchange="show()"/>   
      <script>
               function show(){
               var myname = document.getElementById('pg:fm:name').value;
               var myage = document.getElementById('pg:fm:pb:age').value;
               alert(myname+'==='+myage);
              }
      </script>
      <apex:pageBlock id="pb">
          <apex:inputText id="age" onchange="show()"/>
      </apex:pageBlock>
  </apex:form>

</apex:page>










STEP - 5

Another Example is , I want to read the value and display the values in our component.

Read the value from the component and display the another component.

Example:

<apex:page id="pg">
  <apex:form id="fm">
      <apex:pageBlock id="pb">
          <apex:pageBlockSection id="pbs1">
              <apex:inputText id="one"/>
          </apex:pageBlockSection>
          <apex:pageBlockSection id="pbs2">
              <apex:inputText id="two"/>
              <apex:outputLabel id="three"/>
          </apex:pageBlockSection>
          <apex:commandButton value="Click" onclick="show()"/>
      </apex:pageBlock>
  </apex:form>    
  <script>
    function show(){
     
      // that get the value which we will give in input text
       var myname= document.getElementById('pg:fm:pb:pbs1:one').value;

     //in this we will set the value which we have get into input text
        document.getElementById('pg:fm:pb:pbs2:two').value = myname;

   // And print that value using innerHTML
        document.getElementById('pg:fm:pb:pbs2:three').innerHTML= myname;
    
    
    }
  </script>      
</apex:page>


innerHTML : The innerHTML property is used to get or set the HTML content of an element node.




Wednesday 20 September 2017

Most Asking Interview Question

These below questions are the favorite questions of the interviewer.


1. What is the User?

2. What is the Role?

3. What is the OWD?

4. What is the Permission Set?

5. Difference between Role and Profile?

6. What is the Profile?

7. What is the Sales Process?

8. Difference between workflow and Processbuilder?

9. How to call flow and Apex class from process builder?

10. How many editions in salesforce?

11.How many types of Deployment ways from salesforce.

12.What is the sharing setting?

13. What is the Trigger?

15. What is the before and after trigger?

16.What is the context variable?

17. Difference between Trigger.newMap and Trigger.OldMap?

18. How to update Contact corresponding to the account?

19. How to update Account field to contact field?

20. How to insert child when the parent is inserted/update?

21.What is the aggregate Query?

22. How to show the count of contact corresponding to account?

23.What is the SOQL/SOSL?

24. Limitation of SOQL/SOSL/DML?

25.What is the governor limit?

26. Why Salesforce make governor limit?

27. What is the Order of execution?

28. How to stop recursiveness in the trigger?

29. Best Pratic of Trigger? Any Five?

30. How many triggers we can make on one object but if you're making what is the best practice?

31. What is the Custom Label? Syntex of Custom label?

32. What is the Custom Setting? How to define Custom setting in class and trigger?

33. What is the difference between Custom Setting and Custom Objects?

34. What is the Purpose of making Custom Setting? Acutely Salesforce has already provided Custom Objects....WHY?

35. What are the get and set method and how they are works?

36. What is Trigger Handler?

37. What is Bulkifying Trigger?

38. Can we define two triggers with the same event on a single object?

39. Why we have to write Trigger Handler?

40. Could we update the same object using after event?

41. What is the Batch Class and Purpose?

42. What is the Syntex of Batch class?

43. Methods of the Batch class and Syntex?

44. What is the Database.ContextVariable and What the work of?

45.What is the QueryLocator in Batch class?

46. Could you please explain to me how to Batch class work step by step?

47. What is the Default, Min, Max Size of Batch?

48. How Many time execute method called?

49. How many time Start method called?

50. What is the connection of Start and execute method?

51. How to send the Email message through Batch class?

52. What is the purpose of Finish Method?

53. Finish Method is mandatory to write in batch class?

54. Can we call another Batch class from another batch class? How?

55. Can we call batch class from trigger? How?

56. How to run Batch class immediately? How?

57. What is the Test.StartTest() and Test.StartStop()?

58. What is the Schedule Class?

59. Why we have to write Schedule Class?

60. How many ways we can schedule batch class?

61. What is the Schedulable interface? Why we have written?

62. How many batches we can schedule at a time?

63. Suppose You have scheduled a batch and you want to do some change in your batch class. Could you save your Batch class after the change?

64. What is the synchronous and Asynchronous?

65. Batch class is synchronous process or Asynchronous Process?

66. What is Future Method?

67. What is the Queueable Class?

68. What are the Purpose of Future Method and Queueable class?

68. Difference between Future Method and Queueable class?

69. Syntex of Future Method and Queueable class?

70. Can we call the Future method from the batch class?

71. Could we monitor Future method?

72. How many batch we can schedule at a time?

73. What is the offset? Why we use?

74. What is the pagination? Please write the Algo of pagination?

75. Difference between Offset and Limit?

76. What is the Having, Include, In, Notin, GroupBy, All Rows, For update in Soql?

77. Suppose I want to make a VF page and in VF page, I want to search any keyword then related keyword records should be shown. How?

78. What is the Ajax function in vfpage?

79. What is the View State and Purpose?

80. What is the Wrapper class? Why we written Wrapper class? Give an example.

81. What is the Standard Controller and Controller? Purpose of use?

82. What is the extension in VF Page? Why we used?

83. Difference between Controller and extension?

84.what is the email services and What type of?

85. What is the Inbound and outbound Email services?

86.  What is the Single and Mass email service?


















Tuesday 29 August 2017

Pagination with a List Controller

You can add pagination to a page using a list controller by utilizing the next and previous actions. For example, if you create a page with the following markup:


<apex:page standardController="Account" recordSetVar="accounts">
   <apex:form >
   <apex:pageBlock title="My Accounts">
   <apex:pageBlockSection >
   <apex:dataList value="{!accounts}" var="a">{!a.name}
    </apex:dataList>
   </apex:pageBlockSection>
   <apex:panelGrid columns="2">
   <apex:commandLink action="{!previous}">Previous</apex:commandLink>
   <apex:commandLink action="{!next}">Next</apex:commandLink>
   
   </apex:panelGrid>
   </apex:pageBlock>
   </apex:form>    
</apex:page>


<apex:dataList>

An ordered or unordered list of values that is defined by iterating over a set of data. The body of the <apex:dataList>component specifies how a single item should appear in the list. The data set can include up to 1,000 items.

By default, a list controller returns 20 records on the page. To control the number of records displayed on each page, use a controller extension to set the pageSize.



Limits in Salesforce

In Trigger and Apex class sales force provide us some limits. Below are the limits.

You can take idea what Salesforce provide us limits.


Limits in Trigger:

1.Number of SOQL queries:  100

2.Number of query rows(records):  50000

3.Number of SOSL queries: 20

4.Number of query rows(records):  2000

5.Number of DML statements: 150

6.Number of DML rows:  10000

7.Maximum CPU time:  10000

8.Maximum heap size: 6000000

9.Number of callouts:  100

10.Number of Email Invocations:  10

11.Number of future calls:  50

12.Number of queueable jobs added to the queue: 50

14.Number of Field one Per Object:  500

15.Number of Relationship Fields:  40

16.Number of Active Workflow on per object:  50

17.Number of Workflow on per objects:  500

18.Number of Approval Process on per object:  500

20.Number of Active Lookup Filters:  5

21.Number of Active Validation Rules:  100

22.Number of VLOOKUP on per object:  10

23.Number of Sharing Rules (Both Owner- and Criteria-based):  300

24.Number of Sharing Rules (Criteria-based Only): 50


Limits In Salesforce:

Feature

Personal Edition

Contact Manager

Group Edition

Professional Edition

Enterprise Edition

Unlimited and Performance Edition

Developer Edition

Action plans: maximum tasksN/A75
Active lookup filters5 per object
Active validation rules per objectN/A20100500100
Attachments: maximum size in the Notes & Attachments related list125 MB for file attachments. 2 GB for feed attachments.
Categories: maximum default categories and hierarchy levelsN/A
  • 100 categories in a data category group
  • 5 levels in a data category group hierarchy
Category groups: maximum default5 category groups, with 3 groups active at a time
Certificates: maximum50
Content deliveries: default delivery bandwidth per rolling 24-hour window20 GB
Content deliveries: default delivery view counts per rolling 24-hour window20,000
Content deliveries: maximum file size for online viewing25 MB
Content: maximum file size
  • 2 GB
  • 2 GB (including headers) when uploaded via Chatter REST API
  • 2 GB (including headers) when uploaded via REST API
  • 38 MB when uploaded via SOAP API
  • 10 MB when uploaded via BULK API
  • 10 MB for Google Docs
  • 10 MB when uploaded via Visualforce
Content: maximum libraries2,000
Content: maximum number of documents30,000,000
Content: maximum number of documents and versions in a 24–hour period (adjustable)200,0002,500
Content packs: maximum filesN/A50
Custom apps2N/A1255
To exceed this limit, contact Salesforce.
260
To exceed this limit, contact Salesforce.
Unlimited10
Custom fields per object3525100500800500
Custom labelsN/A5,000
Custom links: maximum label length1,024 characters
Custom links: maximum URL length3,000 bytes4
Custom objects5N/A5502002,000400
Custom objects: deletion of parent records in a many-to-many relationshipN/AAvailable unless more than 200 junction object records are associated with the deleted parent record and the junction object has a roll-up summary field that rolls up to the other parent.
Custom objects: maximum master-detail relationships26
Custom permissionsN/A1,000
Custom profiles: maximumN/A21,500 per user license type
Custom settings: cached data limitThe lesser of 10 MB or 1 MB multiplied by the number of full-featured user licenses in your org (N/A in Contact Manager and Professional Editions)
Custom settings: maximum fields per setting5N/A100N/A300
Divisions: maximumN/A100N/A
Documents: maximum size of custom app logo20 KB
Documents: maximum size of document to upload5 MB
Documents: maximum size of file name (with extension)255 characters
Entitlement processes and milestonesN/AYou can create up to 1,000 entitlement processes total, with up to 10 milestones per process. If your org was created before Summer ’13, its maximum entitlement processes can be lower. Contact Salesforce to increase it.
External objects7N/A100
Field history tracking: maximum standard or custom fields tracked for standard or custom objectsN/A20
File size: maximum in Chatter and on the Files tab2 GB
Fiscal years: maximum custom250
Formulas: maximum displayed characters after an evaluation of a formula expression1,300
Formulas: maximum length3,900 characters
Formulas: maximum size when compiled5,000 bytes
Formulas: maximum size when saved4,000 bytes
Formulas: unique relationships per object15
Formulas: VLOOKUPfunctions per object10
Ideas: maximum size of HTML idea commentN/A4 KB
Ideas: maximum size of HTML idea description32 KB
Lightning AppsN/A1025UnlimitedN/A
Lightning pages: maximum components in a region25
Master-detail relationship: maximum child records10,0008
Objects: maximum number of deleting combined objects and child records100,000
Omni-Channel: maximum pending routing requests9N/A30,000
Omni-Channel: maximum queued work items105,000 per hour
Opportunity Teams: maximum membersN/A30
Permission sets: maximum (created)N/A1101,000
Permission sets: maximum (created and added as part of an installed managed AppExchange package)N/A1,500
Question: maximum charactersN/A1,000N/A
Question: maximum characters (with Chatter Answers Optimize Question Flowenabled)32,000
Quote PDF: maximum logo heightN/A150 pixels
Quote PDF: maximum logo size5 MB
Recycle Bin: maximum records25 times your storage capacity in MBs
Reply: maximum charactersN/A1,000N/A
Reply (private): maximum characters (with Chatter Answers Optimize Question Flowenabled)4,000N/A
Reply (public): maximum characters (with Chatter Answers Optimize Question Flowenabled)32,000N/A
Shared ActivitiesYou can relate up to 50 contacts to nonrecurring tasks, nongroup tasks, and nonrecurring events. You can assign one primary contact. All others are secondary contacts.
Sharing rulesN/AYou can create up to 300 sharing rules per object, including up to 50 criteria-based rules.
Static resourcesN/AA static resource can be up to 5 MB. An org can have up to 250 MB of static resources total.
Tabs2351,210
To exceed this limit, contact Salesforce.
1,225
To exceed this limit, contact Salesforce.
1,225
To exceed this limit, contact Salesforce.
100
Tags
A user is limited to a maximum of:
  • 500 unique personal tags
  • 5,000 instances of personal tags applied to records
Across all users, your org can have a maximum of:
  • 1,000 unique public tags
  • 50,000 instances of public tags applied to records
  • 5,000,000 instances of personal and public tags applied to records
Territories: maximum account assignment rulesN/A15
Users: maximum created1510Unlimited2
Users: maximum created (Chatter Free)N/A5,000
Visual WorkflowN/AEach flow can have up to:
  • 50 versions
  • 2,000 steps
Each org can have up to:
  • 500 active flows
  • 1,000 flows total
  • 30,000 waiting interviews at a given time
  • 1,000 events processed per hour
  • 20,000 defined relative alarm events across all flows and flow versions
Web-to-Case: maximum new cases generated in a 24–hour periodN/A5,00011
Web-to-Lead: maximum new leads generated in a 24–hour period50011

One particular lead takes how many days to change it's stage from one stage value to another

/*************** Ceated By    : Mohit Dwivedi( KVP Business Solution Pvt Ltd) . Created Date :  Purpose      : This  controller is for Lead ...