You need to sign in to do that
Don't have an account?
Evan C. Decker
Visualforce page not saving value entered in field
Hello - I have a Visualforce page that's working in the sandbox but not production. There's one field that isn't being saved when the user saves the record, the field is called Date_of_Gift__c. It displays but the value isn't saved. I'm thinking there's an issue with the controller. Here it is:
Specifically I think the issue is on line 130, this one:
That line references the other fields that are visible on the Visualforce page, but when I try to add the new field (Date_of_Gift__c) it gives me the following error:
Error: Compile Error: Method does not exist or incorrect signature: [CharitableContributionEditLayoutCont.SaveHighLowShares].SaveHighLow(Id, Decimal, Decimal, Decimal, Date) at line 130 column 13
I'm not sure what I'm doing wrong. Anyone have any ideas? Thank you in advance!
public with sharing class CharitableContributionEditLayoutCont { private final Charitable_Contribution__c charity; public Charitable_Contribution__c newcharity {get; set;} public Charitable_Contribution__c oldcharity {get; set;} public String fromAccount {get; set;} public List<SelectOption> fromAccounts {get; set;} public Attachment attachment {get; set;} public String cloneValue {get; set;} public String toAccount {get; set;} public List<SelectOption> toAccounts {get; set;} public String fciRecordTypeId {get; set;} public String notfciRecordTypeId {get; set;} public CharitableContributionEditLayoutCont(ApexPages.StandardController sc) { this.charity = (Charitable_Contribution__c)sc.getRecord(); attachment = new Attachment(); cloneValue = ApexPages.currentPage().getParameters().get('clone'); if (String.isBlank(cloneValue) && String.isBlank(charity.Id)) { newcharity = charity; newcharity.RecordTypeId = ApexPages.currentPage().getParameters().get('RecordType'); } else { oldcharity = [SELECT Id, Amount__c, RecordTypeId, Additional_Comments_Requirements__c, Additional_Internal_Instructions__c, Client__c, Client_Analyst__c, Client_Specialist__c, New_Unlisted_Organization_Contact_Name__c, To_Account_Client_Lookup__c, Designation__c, RecordType.Name, Disposition_Method__c, Donor_s_Name_s__c, FC__c, Fidelity_Account__c, To_Account__c, High_Price__c, Low_Price__c, Need_Client_Signature__c, Notes__c, Organization__c, New_Unlisted_Organization_Name__c, Phone__c, Request_Date__c, Status__c, Stock_Ticker_Name_and_CUSIP_Lookup__c, Final_of_Shares__c, Pending_Collateral_Transfer__c, Date_of_Gift__c FROM Charitable_Contribution__c WHERE Id = :charity.Id]; } if (String.isNotBlank(cloneValue)) { newcharity = oldcharity.clone(false, true); newcharity.Status__c = Constants.CHARITABLE_CONTRIBUTION_STATUS_NEW; } else if (String.isNotBlank(charity.Id)) { newcharity = oldcharity.clone(true, true); } fciRecordTypeId = Utils.GetRecordTypeIdFromName(new Charitable_Contribution__c(), Constants.CHARITABLE_CONTRIBUTION_RECORDTYPE_FCI_MANAGED); notfciRecordTypeId = Utils.GetRecordTypeIdFromName(new Charitable_Contribution__c(), Constants.CHARITABLE_CONTRIBUTION_RECORDTYPE_NOT_FCI_MANAGED); if (String.isNotBlank(charity.Id)) { fromAccount = newcharity.Fidelity_Account__c; toAccount = newcharity.To_Account__c; getFromAccounts(); getToAccounts(); } } public PageReference getFromAccounts() { fromAccounts = new List<SelectOption>(); List<SelectOption> accounts = new List<SelectOption>(); for (Bank_Account__c ba : [SELECT Id, Name, Account_Type__c, Account_Number__c FROM Bank_Account__c WHERE Entity__c = :newcharity.Client__c ORDER BY Account_Number__c]) { accounts.add(new SelectOption(ba.Id, ba.Account_Type__c + ' - ' + ba.Account_Number__c)); } if (accounts.size() > 1) fromAccounts.add(new SelectOption('', 'Select One')); fromAccounts.addAll(accounts); return null; } public PageReference GetToAccounts() { toAccounts = new List<SelectOption>(); List<SelectOption> toaccts = new List<SelectOption>(); for (Bank_Account__c ba : [SELECT Id, Name, Account_Type__c, Account_Number__c FROM Bank_Account__c WHERE Entity__c = :newcharity.To_Account_Client_Lookup__c ORDER BY Account_Number__c]) { toaccts.add(new SelectOption(ba.Id, ba.Account_Type__c + ' - ' + ba.Account_Number__c)); } if (toaccts.size() > 1) toAccounts.add(new SelectOption('', 'Select One')); toAccounts.addAll(toaccts); return null; } public Boolean getIsLocked() { if (String.isNotBlank(newcharity.Id) && !(String.isBlank(newcharity.Status__c) || newcharity.Status__c == Constants.CHARITABLE_CONTRIBUTION_STATUS_NEW)) { return true; } return false; } public String getFinalValuationUserId() { String userName = FCICommunitySettings__c.getInstance().FinalValuationUserName__c; if(Test.isRunningTest()) userName = 'DeDe Connors'; return [SELECT Id FROM User WHERE Name = :userName AND IsActive = true LIMIT 1].Id; } public Boolean getCharitableContributionUser() { Group groupId = [SELECT Id, (SELECT UserOrGroupId FROM GroupMembers) FROM Group WHERE DeveloperName = 'Charitable_Contribution_Users' AND Type = 'Queue']; for (GroupMember g : groupId.GroupMembers) { if (g.UserOrGroupId == UserInfo.getUserId()) { return true; } } return false; } public PageReference save() { if (newcharity.Status__c == Constants.CHARITABLE_CONTRIBUTION_STATUS_FINAL_VALUATION && UserInfo.getUserId() == getFinalValuationUserId()) { SaveHighLowShares s = new SaveHighLowShares(); s.SaveHighLow(newcharity.Id, newcharity.High_Price__c, newcharity.Low_Price__c, newcharity.Final_of_Shares__c); return new PageReference('/' + newcharity.Id); } if (newcharity.Status__c == Constants.CHARITABLE_CONTRIBUTION_STATUS_DRAFT_VALUATION && getCharitableContributionUser()) { SaveHighLowShares s = new SaveHighLowShares(); s.SaveShares(newcharity.Id, newcharity.Final_of_Shares__c); return new PageReference('/' + newcharity.Id); } if (String.isBlank(fromAccount)) { ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR, 'The From Account is a required field.')); } else { newcharity.Fidelity_Account__c = fromAccount; newcharity.To_Account__c = toAccount; upsert newcharity; if (attachment.body != null) { attachment.ParentId = newcharity.Id; insert attachment; } if (String.isNotBlank(cloneValue)) { List<Attachment> attachmentsInsert = new List<Attachment>(); List<Note> notesInsert = new List<Note>(); for (Attachment a : [SELECT Name, Body FROM Attachment WHERE ParentId = :charity.Id]) { Attachment att = new Attachment( Name = a.Name, Body = a.Body, ParentId = newcharity.Id ); attachmentsInsert.add(att); } for (Note n : [SELECT Title, Body FROM Note WHERE ParentId = :charity.Id]) { Note nt = new Note( Title = n.Title, Body = n.Body, ParentId = newcharity.Id ); notesInsert.add(nt); } if (attachmentsInsert.size() > 0) insert attachmentsInsert; if (notesInsert.size() > 0) insert notesInsert; } return new PageReference('/' + newcharity.Id); } return null; } public without sharing class SaveHighLowShares { public void SaveHighLow(Id id, Decimal high, Decimal low, Decimal shares) { Charitable_Contribution__c c = new Charitable_Contribution__c( Id = id, High_Price__c = high, Low_Price__c = low, Final_of_Shares__c = shares ); update c; } public void SaveShares(Id id, Decimal shares) { Charitable_Contribution__c c = new Charitable_Contribution__c( Id = id, Final_of_Shares__c = shares ); update c; } } }
Specifically I think the issue is on line 130, this one:
s.SaveHighLow(newcharity.Id, newcharity.High_Price__c, newcharity.Low_Price__c, newcharity.Final_of_Shares__c);
That line references the other fields that are visible on the Visualforce page, but when I try to add the new field (Date_of_Gift__c) it gives me the following error:
Error: Compile Error: Method does not exist or incorrect signature: [CharitableContributionEditLayoutCont.SaveHighLowShares].SaveHighLow(Id, Decimal, Decimal, Decimal, Date) at line 130 column 13
I'm not sure what I'm doing wrong. Anyone have any ideas? Thank you in advance!
You have tried the code below and that didn't work ?
Alain
All Answers
You have tried the code below and that didn't work ?
Alain