Hi
I have a "parent" transaction record such as an invoice.
On this, I have a userevent button which triggers a suitelet to capture the end user data.
Once the suitelet is submitted, this creates a instance of the custom record type (notes).
- Is there a way to also update the parent transaction record using values from the suitelet form?
the parent transaction is in 'view' mode when the suitelet form is opened.
From a demo account:
Once the 'add note' button is clicked:
On submit record created:
/**
*@NApiVersion 2.x
*@NScriptType Suitelet
*/
define(["N/ui/serverWidget", "N/log", "N/record", "N/url"], function (
serverWidget,
log,
record,
url
) {
/**
* @param {SuiteletContext.onRequest} context
*/
function onRequest(context) {
if (context.request.method === "GET") {
// Section One - Forms
var invoice_id = parseInt(context.request.parameters.recordId);
var form = serverWidget.createForm({
id: "notes",
title: "Notes",
});
var customerGroup = form.addFieldGroup({
id: "customerDetails",
label: "Customer Details",
});
customerGroup.isSingleColumn = false;
form.addSubmitButton({
label: "Submit",
});
var select = form.addField({
id: "custpage_source",
type: serverWidget.FieldType.SELECT,
label: "Source of Communication",
container: "customerDetails",
});
select.addSelectOption({
value: "phone",
text: "Phone",
});
select.addSelectOption({
value: "email",
text: "Email",
});
select.addSelectOption({
value: 3,
text: "Website Contact Form",
});
select.addSelectOption({
value: "other",
text: "Other",
});
var parentRecord = context.request.parameters.urlId;
form.addPageLink({
type: serverWidget.FormPageLinkType.CROSSLINK,
title: "Invoice",
url:
"https://tstdrv.app.netsuite.com/app/accounting/transactions/custinvc.nl?id=" +
invoice_id,
});
form.addField({
id: "custpage_parent_transaction",
type: serverWidget.FieldType.URL,
label: "Parent Transaction",
container: "customerDetails",
});
// form.updateDefaultValues({
// custpage_recordurl:
// "https://tstdrv.app.netsuite.com/app/accounting/transactions/custinvc.nl?id=" +
// recId,
// });
context.response.writePage(form);
// function getBaseUrl() {
// return url.resolveRecord({
// recordType: record.Type.INVOICE,
// })
// }
// Section Two - Tabs - See "Steps for Adding a Tab to a Form"
// Section Three - Sublist - See "Steps for Adding a Sublist to a Form"
} else {
// Section Four - Output - Used in all sections
var delimiter = /\u0001/;
var sourceField = context.request.parameters.custpage_source;
var parentField = context.request.parameters.custpage_parent_transaction;
log.debug("parentField", parentField);
// context.response.write(
// "You have entered:" + "<br/> Name: " + sourceField
// );
var recObj = record.create({
type: "customrecord_user_notes",
});
recObj.setValue({ fieldId: "custrecord_source", value: sourceField });
recObj.setValue({
fieldId: "custrecord_parent_transaction",
value: parentRecord,
});
var userNote = recObj.save({});
context.response.write("Note Created");
}
}
return {
onRequest: onRequest,
};
- I am also having issues with passing the url of the original record into the parent transaction field on the suitelet:
Since there is no option to add a list/record type of field in a suitelet, how do I pass the url for the original transaction to this so that it can appear as a hyperlink to the parent transaction record?
i.e. through the UI this is how the field should appear:
I have chosen the datatype as URL on the suitelet form to pass the original record's url to that field in the suitelet though that doesn't work. That field shows as a blank.
thanks