You need to sign in to do that
Don't have an account?
Gulshan__c
Unknown property 'InsertByVF.Position__c
Hi getting the exception when trying to add records on my custom object Position__c
Here is my Controller :
public class InsertByVF{
public Position__c pos;
public String positionName{get;set;}
public Decimal MinimumPay{get;set;}
public Decimal MaximumPay{get;set;}
public InsertByVF()
{
pos=new Position__c();
}
public void doInsert()
{
pos.Name=positionName;
pos.Max_Pay__c=MaximumPay;
pos.Min_Pay__c=MinimumPay;
insert pos;
}
}
And below is my Apex page code :
<apex:page controller="InsertByVF">
<apex:form >
<apex:pageBlock title="New Position">
<apex:pageBlockSection >
<apex:pageBlockSectionItem >
<apex:outputLabel >Position Name :</apex:outputLabel>
<apex:inputField id="FirstName" value="{!Position__c.positionName}"/>
</apex:pageBlockSectionItem>
<apex:pageBlockSectionItem >
<apex:outputLabel >Max Pay :</apex:outputLabel>
<apex:inputField id="MaxPay" value="{!Position__c.MaximumPay}"/>
</apex:pageBlockSectionItem>
<apex:pageBlockSectionItem >
<apex:outputLabel >Min Pay :</apex:outputLabel>
<apex:inputField id="MinPay" value="{!Position__c.MinimumPay}"/>
</apex:pageBlockSectionItem>
</apex:pageBlockSection>
<apex:pageBlockButtons >
<apex:commandButton id="Save" action="{!doInsert}" value="Save"/>
<!--<apex:commandButton id="Cancel" action="{!Cancel}" value="Cancel"/>-->
</apex:pageBlockButtons>
</apex:pageBlock>
</apex:form>
</apex:page>
Here is my Controller :
public class InsertByVF{
public Position__c pos;
public String positionName{get;set;}
public Decimal MinimumPay{get;set;}
public Decimal MaximumPay{get;set;}
public InsertByVF()
{
pos=new Position__c();
}
public void doInsert()
{
pos.Name=positionName;
pos.Max_Pay__c=MaximumPay;
pos.Min_Pay__c=MinimumPay;
insert pos;
}
}
And below is my Apex page code :
<apex:page controller="InsertByVF">
<apex:form >
<apex:pageBlock title="New Position">
<apex:pageBlockSection >
<apex:pageBlockSectionItem >
<apex:outputLabel >Position Name :</apex:outputLabel>
<apex:inputField id="FirstName" value="{!Position__c.positionName}"/>
</apex:pageBlockSectionItem>
<apex:pageBlockSectionItem >
<apex:outputLabel >Max Pay :</apex:outputLabel>
<apex:inputField id="MaxPay" value="{!Position__c.MaximumPay}"/>
</apex:pageBlockSectionItem>
<apex:pageBlockSectionItem >
<apex:outputLabel >Min Pay :</apex:outputLabel>
<apex:inputField id="MinPay" value="{!Position__c.MinimumPay}"/>
</apex:pageBlockSectionItem>
</apex:pageBlockSection>
<apex:pageBlockButtons >
<apex:commandButton id="Save" action="{!doInsert}" value="Save"/>
<!--<apex:commandButton id="Cancel" action="{!Cancel}" value="Cancel"/>-->
</apex:pageBlockButtons>
</apex:pageBlock>
</apex:form>
</apex:page>
your VF page -->
All Answers
your VF page -->
Error: Could not resolve the entity from <apex:inputField> value binding '{!positionName}'. <apex:inputField> can only be used with SObjects, or objects that are Visualforce field component resolvable.
right, you can use <apex:inputField to set only sObject fields.
Use <apex:input, with attribute type (text, number): https://developer.salesforce.com/docs/atlas.en-us.pages.meta/pages/pages_compref_input.htm
Or <apex:inputText : https://developer.salesforce.com/docs/atlas.en-us.pages.meta/pages/pages_compref_inputText.htm (http://https://developer.salesforce.com/docs/atlas.en-us.pages.meta/pages/pages_compref_inputText.htm)
Thanks a lot Marek..Now its working fine...!