SCFormView template contains 3 hidden fields which...
# suitecommerce
c
SCFormView template contains 3 hidden fields which are not included when the form is submitted. Is there any reason why hidden fields values not be included?
s
Have you included these in your
prototype.getFormValues
method?
c
yes
@Steve Goldberg Having a hard time at grasping the
prototype.getFormValues
method, perhaps you can provide guidance? This is my getFormValues… Hidden fields have a value set, however the data is not passed to the backend.
Copy code
CustomApplicationFormView.prototype.getFormValues = function (form) {
		var formValues = form.serializeObject();

		return {
			companyname: formValues.companyname,
			address1: formValues.address1,
			city: formValues.city,
			state: formValues.state,
			country: formValues.country,
			zipcode: formValues.zipcode,
			firstname: formValues.firstname,
			lastname: formValues.lastname,
			email: formValues.email,
			phone: formValues.phone
		};
	};
s
I assume this is a typo: lastname: formValues.firstname,
👍 1
c
I am getting 2 errors
Copy code
Impossible to parse backend error - Request {"url":"<https://www.domain.com/scs/extensions/Inte>….0.0/services/CustomForm.Service.ss?c=1311312&n=2","type":"POST","isLocal":false,"global":true,"processData":false,"async":true,"contentType":"application/json","accepts":{"*":"*/*","text":"text/plain","html":"text/html","xml":"application/xml, text/xml","json":"application/json, text/javascript","script":"text/javascript, application/javascript, application/ecmascript, application/x-ecmascript"},"contents":{"xml":{},"html":{},"json":{},"script":{}},"responseFields":{"xml":"responseXML","text":"responseText","json":"responseJSON"},"converters":{"text html":true},"flatOptions":{"url":true,"context":true},"jsonp":"callback","cache":true,"dataType":"json","data":"{\"country\":\"US\",\"companyname\":\"Company name\",\"address1\":\"Address 1\",\"city\":\"City\",\"state\":\"HI\",\"zipcode\":\"12345\",\"firstname\":\"First\",\"lastname\":\"First\",\"email\":\"<mailto:please.delete@email.com|please.delete@email.com>\",\"phone\":\"<tel:(555)555-5555|(555) 555-5555>\"}","validate":true,"parse":true,"wait":true,"emulateHTTP":false,"emulateJSON":false,"dataTypes":["text","json"],"crossDomain":false,"hasContent":true}
Copy code
Uncaught TypeError: (intermediate value).showError is not a function
s
the data is not passed to the backend
As in, it is not being included in the JSON data that is being POSTed to the service file? Ie, the request object which you view in your Network tab does not show the hidden fields?
c
The hidden field that has a hard coded value is NOT included with the data POSTed to the service file. This is the submitted data, which is missing the value from a custom field.
Copy code
{
   country: "US",
   companyname: "Please Delete",
   address1: "adress 1",
   city: "City",
   state: "HI",
   zipcode: "12345",
   firstname: "First",
   lastname: "Last",
   email: "<mailto:please.delete@email.com|please.delete@email.com>",
   phone: "<tel:(555)555-5555|(555) 555-5555>",
   custentity_sc_store_is_online: "F",
   custentity_sc_store_is_brick_mortar: "F",
   subsidiary:1
}
s
I'm confused. There's big discrepancies between the request object and the map you created in
getFormValues
Where do
custentity_sc_store_is_online
,
custentity_sc_store_is_brick_mortar
,
subsidiary
come from?
And which of your fields is the hidden field?
c
custentity_sc_store_is_online
, 
custentity_sc_store_is_brick_mortar
are both in the form as checkbox inputs and  
subsidiary
is set in the service.
The hidden field is in the template
Copy code
<input class="cust-form-input" name="custentity_cust_location" type="hidden" id="custentity_cust_location" value="13">
s
OK, and why haven't you put that field in your map?
c
So all form fields have to be added to the return of getFormValues?
s
... yes
You're using that to tell the model what form fields map to which properties in the model
If you don't include a property that you want, its property won't be set
c
ok