You need to sign in to do that
Don't have an account?
Marvin Castro 8
Help on Visual Force Page
Hi - I'm new to creating VF pages in salesforce. I created a simple lead form that captures basic profile information. I'm having issues with special character on the Company name and/or the city fields on the Lead object. It appears it doesn't save the record in this scenario - Company Name Re/Max Unlimited City: San Antonio
Here's the apex code for the page:
<apex:page standardController="Lead">
<apex:form >
<apex:pageBlock mode="edit">
<p/>
<p/>
<div align="center" draggable="false" >
<apex:commandbutton action="{!save}" value="Save"/>
<apex:commandbutton action="{!cancel}" value="Cancel"/>
</div>
<p/>
<apex:pageBlockSection title="Lead Information" columns="1">
<apex:inputField value="{!Lead.Salutation}"/>
<apex:inputField value="{!Lead.FirstName}" required="true"/>
<apex:inputField value="{!Lead.LastName}"/>
<apex:inputField value="{!Lead.Suffix}"/>
<apex:inputField value="{!Lead.Company}"/>
</apex:pageBlockSection>
</apex:pageBlock>
<p/>
<apex:pageBlock mode="edit">
<apex:pageBlockSection title="Contact Information" columns="1">
<apex:inputField value="{!Lead.Email}" required="true"/>
<apex:inputField value="{!Lead.Phone}" required="true"/>
<apex:inputField value="{!Lead.MobilePhone}"/>
<apex:inputField value="{!Lead.Street}"/>
<apex:inputField value="{!Lead.City}" required="true"/>
<apex:inputField value="{!Lead.state}" required="true"/>
<apex:inputField value="{!Lead.postalcode}"/>
<p/>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
</apex:page>
I appreciate any assistance.
Thanks,
Marvin
Here's the apex code for the page:
<apex:page standardController="Lead">
<apex:form >
<apex:pageBlock mode="edit">
<p/>
<p/>
<div align="center" draggable="false" >
<apex:commandbutton action="{!save}" value="Save"/>
<apex:commandbutton action="{!cancel}" value="Cancel"/>
</div>
<p/>
<apex:pageBlockSection title="Lead Information" columns="1">
<apex:inputField value="{!Lead.Salutation}"/>
<apex:inputField value="{!Lead.FirstName}" required="true"/>
<apex:inputField value="{!Lead.LastName}"/>
<apex:inputField value="{!Lead.Suffix}"/>
<apex:inputField value="{!Lead.Company}"/>
</apex:pageBlockSection>
</apex:pageBlock>
<p/>
<apex:pageBlock mode="edit">
<apex:pageBlockSection title="Contact Information" columns="1">
<apex:inputField value="{!Lead.Email}" required="true"/>
<apex:inputField value="{!Lead.Phone}" required="true"/>
<apex:inputField value="{!Lead.MobilePhone}"/>
<apex:inputField value="{!Lead.Street}"/>
<apex:inputField value="{!Lead.City}" required="true"/>
<apex:inputField value="{!Lead.state}" required="true"/>
<apex:inputField value="{!Lead.postalcode}"/>
<p/>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
</apex:page>
I appreciate any assistance.
Thanks,
Marvin
Try the Below code.Its working fine.Make sure you dont have any Validation rules on fields.
Best Regards,
Onesh.K
All Answers
Hi Marvin,
Your VisualForce page is almost correct except the line <apex:inputField value="{!Lead.Suffix}"/>. There is no standard field named Suffix in Lead Object. Incase you have created a new field in lead object, use the API name of the field.(API name looks like Suffix__c).
1) Try <apex:inputField value="{!Lead.Suffix__c}"/> if u have created a custom field Suffix.
2) OR Remove the line <apex:inputField value="{!Lead.Suffix}"/>
Let me know if it helps you.
Best Regards,
Onesh.K
Thanks for the response! I removed the Suffix line and the record is still not saving.
Marvin
Try the Below code.Its working fine.Make sure you dont have any Validation rules on fields.
Best Regards,
Onesh.K
First Name: David
Last Name: Castillo Test
Company: Re/Max Unlimited
Email: davidcastillo@remax.com
Phone: (713) 561-7925
City: San Antonio
State/Provice: TX
When I save this record - it loops to the VF page without any error messages.
Thanks,
Marvin
Lead is created from the VF page witout any errors, for the info provided above. The Company field accepts Special character. Maybe there is a validation rule on Company field preventing the entry of special character.
If possible share your Developer org credentials to my mailid : oneshreddy@gmail.com so that i can have deep glance on.
Thanks,
Onesh.K