You need to sign in to do that
Don't have an account?

Creating web form to insert records in custom objects
Hi All,
I have a requirment to create Web Form to get the details from new customer and update a custom object in salesforce platform.
I have created a VF page and a custom controller which can do this. But I want that form (VF page) to be available to the customer who access our main website. i.e., Customer should navigate to this form from our main WEBSITE, not through salesforce.
How can I achieve that?
I have a requirment to create Web Form to get the details from new customer and update a custom object in salesforce platform.
I have created a VF page and a custom controller which can do this. But I want that form (VF page) to be available to the customer who access our main website. i.e., Customer should navigate to this form from our main WEBSITE, not through salesforce.
How can I achieve that?
What is the platform are you using for your main website..?
If the website platform is other than salesforce you do not directly create the records in salesforce..until your integrate both the platform.
Workaround:
You can create a public visualforce page and embed in your website and give access to your class visualforce and object to external users.
To do this you need a community or site license.
https://help.salesforce.com/articleView?id=users_license_types_sites.htm&type=5
--
Thanks,
Prashant
Thanks for your suggestion. I have created a vf page and added it to a site that I have created to make a public vf page .
The issue is that if I open the public url, it is only showing the lables but not the text boxes. Does it have anything to do with permission?
Because when I open the vf page from salesforce then I am able to see those text boxes, but not on the public URL.
Below is the public URL I created to test this functionality.
https://webformtrial-developer-edition.na72.force.com/createCase
I am trying to make a form in this vf page and embed this public URL into my website, so that new users can use this link to register.
Can you suggest me on this?
Thanks,
Sumant
Did give field access to site guest user profile..
Also, can you show me your vf code..
--
Thanks,
Prashant
<apex:page controller="SubmitCaseController">
<h1>Register</h1>
<apex:form >
<apex:pageMessages />
<table>
<tr>
<th>Issue Summary:</th>
<td><apex:inputText required="true" value="{!c.Issue_Summary__c}"/></td>
</tr>
<tr>
<th>Type of Issue:</th>
<td><apex:inputText required="true" value="{!c.Type_of_Issue__c}"/></td>
</tr>
<tr>
<th>Issue Description:</th>
<td><apex:inputTextarea required="true"/></td>
</tr>
<tr>
<th>Your Email:</th>
<td><apex:inputText required="true" value="{!c.Email_ID_to_receive_notification__c}"/></td>
</tr>
<tr>
<td><apex:commandButton value="Submit" action="{!submitCase}"/></td>
</tr>
</table>
</apex:form>
</apex:page>
--
Thanks,
Prashant
You will see a button called Public access setting and just click on that..and you can see a site guest profile there you need to give access to the object and related fields.
--
Thanks,
Prashant
but if I don't use "value" attribute then I cannot add those values to my custom object.
I will have to figure out the solution for this. Please let me know if you have any other solution for this situation.
--
Thanks,
Prashant
below code has both inputfield and inputtext.
Here is the public link
http://webformtrial-developer-edition.na72.force.com/RegisterNew
You can see the difference.
<apex:page controller="SubmitCaseController">
<h1>Register</h1>
<apex:form >
<apex:pageMessages />
<table>
<tr>
<th>Issue Summary:</th>
<td><apex:inputField required="true" value="{!c.Issue_Summary__c}"/></td>
</tr>
<tr>
<th>Type of Issue:</th>
<td><apex:inputText required="true"/></td>
</tr>
<tr>
<th>Issue Description:</th>
<td><apex:inputTextarea required="true"/></td>
</tr>
<tr>
<th>Your Email:</th>
<td><apex:inputText required="true"/></td>
</tr>
<tr>
<td><apex:commandButton value="Submit" action="{!submitCase}"/></td>
</tr>
</table>
</apex:form>
</apex:page>
public access object setting-> field if field not show
Can you try to access the page now.
I hope your problem is solved.
--
Thanks,
Prashant
<td><apex:inputField required="true" value="{!c.Issue_Summary__c}"/></td>
the above field is not visible and rest of the inputtext doesn't have "value" attribute. So I cant read the value of those text boxes in my controller.
--
Thanks,
Prashant
If I use the String to store the input value and then assign that value to the field of the custom object in the controller, then it is working.
I am not sure if that is the best way to do it or not, but for now I am proceeding with that approach. Let me know if you have any suggestions for this.
I have pasted the sample of working code below.
----------------VFP-------------------------------
<apex:page controller="RegistrationClass" >
<apex:form >
<apex:pageMessages />
<table>
<tr>
<th>First Name:</th>
<td><apex:inputText value="{!firstName}"/></td>
</tr>
<tr>
<th>Last Name:</th>
<td><apex:inputText value="{!lastName}"/></td>
</tr>
<tr>
<td><apex:commandButton value="Submit" action="{!register}"/></td>
</tr>
</table>
</apex:form>
</apex:page>
------------Controller-----------------------
public class RegistrationClass {
public Registration__c reg{get ; set; }
public String firstName{get;set;}
public String lastName {get;set;}
public RegistrationClass() {
reg = new Registration__c();
}
public PageReference register() {
try {
reg.First_Name__c = firstName;
reg.Last_Name__c = lastName;
Database.DMLOptions dmlOpts = new Database.DMLOptions();
dmlOpts.assignmentRuleHeader.useDefaultRule = true;
reg.setOptions(dmlOpts);
insert reg;
return new PageReference('/Thanks');
} catch (Exception e) {
ApexPages.addMessages(e);
return null;
}
}
Thanks