You need to sign in to do that
Don't have an account?
joestuart
Update custom object field with Visualforce page form
Hi,
I have stripped my code back to the bare minumum as I am having lots of trouble trying to make a form with one field. The field needs to submit the string "submitted" when the user hits the submit button.
My Error in the VFP
<blockquote>Unknown property 'leadershipReadyCon.Leadership_Ready__c'</blockquote>
My APEX Class code
Here is my Visual Force Page code
Any help would be great, I don't know if this is the best way to submit data to a field in SFDC with APEX so if I am totaly on the wrong track, please let me know.
Thanks.
I have stripped my code back to the bare minumum as I am having lots of trouble trying to make a form with one field. The field needs to submit the string "submitted" when the user hits the submit button.
My Error in the VFP
<blockquote>Unknown property 'leadershipReadyCon.Leadership_Ready__c'</blockquote>
My APEX Class code
public with sharing class leadershipReadyCon { public final Leadership_Ready__c myLeadershipReady; //Constructor function public leadershipReadyCon() { myLeadershipReady = [SELECT Id, Automated_TP_Status__c FROM Leadership_Ready__c WHERE Id = :ApexPages.currentPage().getParameters().get('prodId')]; } Leadership_Ready__c lr = new Leadership_Ready__c(); public Leadership_Ready__c getLeadershipReady() { return myLeadershipReady; } public PageReference save() { //Add your custom logic to update specific fields here //e.g. myLeadershipReady.email = 'xx@xx.com'; update myLeadershipReady; return null; } }
Here is my Visual Force Page code
<apex:page controller="leadershipReadyCon" tabStyle="Leadership_Ready__c"> <apex:form > <apex:pageBlock title="Automated Training Plan Status"> You belong to Account Name: <apex:inputField value="{!Leadership_Ready__c.Automated_TP_Status__c}"/> <apex:commandButton action="{!save}" value="save"/> </apex:pageBlock> </apex:form> </apex:page>
Any help would be great, I don't know if this is the best way to submit data to a field in SFDC with APEX so if I am totaly on the wrong track, please let me know.
Thanks.
There are some modifications needed in your code. Please find the code below.
[If you got answer from my post please mark it as solution.]
Thanks,
Kapil
Email (mailto:forcecube@gmail.com)
I am getting 4 different errors with the new code. I have added them in the code as comments starting with //error at the related line.
Thanks Kapil
System.NullPointerException: Attempt to de-reference a null object
Error is in expression '{!save}' in component <apex:commandButton> in page inputfieldhelloworld: Class.leadershipReadyCon.save: line 28, column 1
Class.leadershipReadyCon.save: line 28, column 1
Do I need to return something?
Sorry for the late reply. I think you are not sending recordid while opening your page. Make sure your page url look like "https://c.ap4.visual.force.com/apex/yourpageName?id=0036F00002D4xt8"
https://c.ap4.visual.force.com ==> your org baseurl
id= YourRecordId
Regards,
Kapil
If you want to redirect on record's detail view.