public with sharing class SaveMContractFromReportController { public String newId { get; private set; } public void init() { String eid = ApexPages.currentPage().getParameters().get('eid'); newId = ApexPages.currentPage().getParameters().get('newid'); Event__c e = [select Id, Maintenance_Contract_Count__c from Event__c where Id = :eid]; e.Maintenance_Contract_ID__c = newId; if (e.Maintenance_Contract_Count__c == null) { e.Maintenance_Contract_Count__c = 1; } else { e.Maintenance_Contract_Count__c = e.Maintenance_Contract_Count__c + 1; } update e; } }