Need to create custom registration form using extension and pass all the input details to backend and using that details need to create lead or customer
First of all, create the extension and in the template, section complete the creation and styling. On the submit button add the trigger to pass the details to the backend.
<div class="col-xs-12 col-sm-6 sendbutton">
<button class="contactus-submit-button" type="submit">Submit</button>
</div>
In the view section add the event for click function
, events: {
"submit #contact-us-form": "SubmitForm"
}
Create submit function and pass the details
SubmitForm: function (e) {
var promise = BackboneFormView.saveForm.apply(this, arguments),
self = this;
e && e.preventDefault();
return promise && promise.then(
function (success) {
if (success.successMessage) {
window.location.reload()
});
} else {
window.location.reload()
});
}
},
function (fail) {
fail.preventDefault = true;
_.each(fail.responseJSON.errorMessage, function (message, field) {
//self.showMessage(message, 'error', field);
swal('Sorry!', message, 'error').then(function () {
window.location.reload()
});
});
}
);
}
Next step is creating post method in service controller file
post: function post() {
this.sendContent(ContactUsModel.CreateLead(this.data), { 'status': 201 });
},
Create lead section while customer submit the form.for that we need to create function in suitescript side
CreateLead: function (data) {
console.error('In@Model: Forms', JSON.stringify(data))
var CONTENT = '';
var emailad = 'test@gmail.com';
try {
var firstname, lastname, company, email, comments;
firstname = Utils.sanitizeString(data.firstname);
email = Utils.sanitizeString(data.email);
phone = Utils.sanitizeString(data.phone);
companyname = Utils.sanitizeString(data.companyname);
company = Utils.sanitizeString(data.company);
message = Utils.sanitizeString(data.message);
var ADMIN = 171620;
var RECIPIENT = emailad;
var SUBJECT = "New Contact Details";
CONTENT += "Hi,<br>";
CONTENT += "Contact Details.<br>";
CONTENT += "Contact Name : " + firstname;
CONTENT += "<br>";
CONTENT += "Email Address : " + email;
CONTENT += "<br>";
CONTENT += "Phone Number : " + phone;
CONTENT += "<br>";
CONTENT += "Company Name : " + companyname;
CONTENT += "<br>";
CONTENT += "Subject : " + company;
CONTENT += "<br>";
CONTENT += "Message : " + message;
nlapiSendEmail(ADMIN, RECIPIENT, SUBJECT, CONTENT);
return {
successMessage: 'Your request has been submitted, we will get back to you within 24 hours.'
}
} catch (e) {
// statements
console.error('err@contactus', e);
return {
status: 500,
code: 'ERR_FORM',
message: 'There was an error submitting the form, please try again later'
}
}
}