About this question
I have a link referencing one contact record in Visualforce page. On click of the said link, a number field from Contact object must be equal to 1. But field is blank each time I click the link.
Meanwhile, here are the apex class and the visualforce page:
Apex Class:
public with sharing class OutputLinkController { private ApexPages.StandardController controller {get; set;} private Contact contact {get;set;} public Integer viewCount {get; set;} public OutputLinkController(ApexPages.StandardController controller) { this.controller = controller; this.contact = (Contact)controller.getRecord(); } public void processLinkClick() { viewCount = 1; } }
Visualforce Page:
Modified Apex Class:
public with sharing class OutputLinkController { public Contact contact { public get; private set; } public OutputLinkController(ApexPages.StandardController controller) { this.contact = (Contact)controller.getRecord(); } public PageReference UpdateClickCount() { UpdateContact(contact.Id); return new PageReference('https://ap7.salesforce.com/?id=0032800000R4Cz3AAF'); } @future public static void UpdateContact(Id contactId) { Contact c = [SELECT Id, Record_View_Count__c FROM Contact WHERE Id = '0032800000R4Cz3AAF']; c.Record_View_Count__c = 1; update c; } }
Modified Visualforce Page: