I have Created the Visualforce Page and apex class which Means Controller Class to count the Viewers of users using the Visualforce Page
VisualForce Page:
<apex:page sidebar="false" showheader="false" StandardController="Page_View__c" extensions="DisplayPage" action="{!TotalRecordUpdate}">
<apex:pageBlock >
<apex:form />
<apex:pageBlockSection >
title="your record details of ID:{!CurrentRecordID}"
</apex:pageBlockSection>
</apex:pageBlock>
<apex:outputField value="{!Page_View__c.Count__c}" />
</apex:page>
Apex class:
public class DisplayPage {
public string CurrentRecordID {get;set;}
public list<Page_View__c> viewList {get;set;}
public static string CurrentRecordID1 {get;set;}
public DisplayPage(ApexPages.StandardController Controller) {
CurrentRecordID = ApexPages.currentPage().getparameters().get('id');
system.debug(CurrentRecordID);
viewList = [select id, Count__c from Page_View__c where id =: CurrentRecordID];
system.debug(viewList);
DisplayPage.TotalRecordUpdate();
}
public static void TotalRecordUpdate() {
CurrentRecordID1 = ApexPages.currentPage().getparameters().get('id');
List < Page_View__c > totalupdate = new List < Page_View__c > ();
List < Page_View__c > recDetails = [select id, Count__c from Page_View__c where id =: CurrentRecordID1];
for ( Page_View__c updateCount: recDetails)
{
updateCount.Count__c = updateCount.Count__c++;
totalUpdate.add(updateCount);
}
update totalUpdate;
}
}
I am getting the Debug Log of currentRecordId is Null,How to Rectify the Error,How to get the Id Value in CurrentRecordid Anyone Guide Me for the Answer