lavi
09/24/2020, 6:36 PMlavi
09/24/2020, 6:37 PMserverWidget.SublistType.INLINEEDITOR
battk
09/24/2020, 6:40 PMlavi
09/24/2020, 6:43 PMcontext.currentRecord.getCurrentSublistText({...context})
returns the text of the current fieldlavi
09/24/2020, 6:43 PMlavi
09/24/2020, 6:44 PMcontext.currentRecord.getField({...context})
returns null
battk
09/24/2020, 6:46 PMbattk
09/24/2020, 6:46 PMlavi
09/24/2020, 6:46 PMbattk
09/24/2020, 6:46 PMlavi
09/24/2020, 6:46 PMlavi
09/24/2020, 6:47 PM// ClientScript
/**
* *@NApiVersion 2.0
* *@NScriptType ClientScript
* *@NModuleScope public
*/
define(['N/currentRecord'], function (currentRecord) { 'use strict';
var currentRecordGet = currentRecord.get();
var lineInit = function (context) {
console.log('lineInit context', context);
};
var fieldChanged = function (context) {
var getFieldValueByContext = function (_a) {
var currentRecord = _a.currentRecord, sublistId = _a.sublistId, fieldId = _a.fieldId;
return currentRecord
.getCurrentSublistValue({
sublistId: sublistId,
fieldId: fieldId
});
};
if (['displayname', 'autocomplete_parent'].includes(context.fieldId)) {
var displayname = getFieldValueByContext(context);
console.log('displayname', displayname);
}
};
var sublistChanged = function (context) {
console.log('sublistChanged context.currentRecord', context);
};
var pageInit = function (context) {
console.log('pageInit context.currentRecord', context);
};
var validateLine = function (context) {
console.log('validateLine context', context);
return true;
};
var validateField = function (context) {
console.log('validateField context', context);
return true;
};
var batchItemCreate_api = {
pageInit: pageInit,
lineInit: lineInit,
validateLine: validateLine,
validateField: validateField,
sublistChanged: sublistChanged,
fieldChanged: fieldChanged
};
return batchItemCreate_api;
});
battk
09/24/2020, 6:49 PMlavi
09/24/2020, 6:50 PMbattk
09/24/2020, 6:50 PMlavi
09/24/2020, 6:50 PMlavi
09/24/2020, 6:51 PM/// Suitelet fields
formFields
.sort(({ sort: a }, { sort: b }) => a < b ? 0 : 1)
.forEach(({
nsid,
label,
type,
source,
sourceArray,
isTextField,
autocomplete
}) => {
if (isTextField && !sourceArray) {
itemList.addField({
label,
id: nsid,
type,
...(source && { source })
})
} else if (!isTextField && source || sourceArray) {
const customSelectItem = itemList.addField({
label,
id: nsid,
type: serverWidget.FieldType.SELECT
})
// Add blank
customSelectItem.addSelectOption({ value: '', text: '' })
if (sourceArray) {
sourceArray.forEach(({ value, text }) => {
customSelectItem.addSelectOption({ value: String(value), text: String(text) })
})
} else if (autocomplete) {
customSelectItem.updateDisplayType({
displayType: serverWidget.FieldDisplayType.HIDDEN
})
itemList.addField({
label: `_${label}_`,
id: `autocomplete_${nsid}`,
type: serverWidget.FieldType.TEXT
})
// add the custom typeahead search
} else {
getSelectOptions(source).forEach(({ value, text }) => {
customSelectItem.addSelectOption({ value: String(value), text: String(text) })
})
}
// noop
}
})
battk
09/24/2020, 6:54 PMlavi
09/24/2020, 6:54 PMSELECT
items to fields based off the contents of a sibling fieldsbattk
09/24/2020, 6:55 PMlavi
09/24/2020, 6:55 PMformFields = Array<AddFieldOptions>
battk
09/24/2020, 6:56 PMlavi
09/24/2020, 6:56 PMbattk
09/24/2020, 6:56 PMlavi
09/24/2020, 6:56 PMbattk
09/24/2020, 6:56 PMlavi
09/24/2020, 6:56 PMbattk
09/24/2020, 6:57 PMlavi
09/24/2020, 6:57 PMlog.debug(JSON.stringify(context.request))?
battk
09/24/2020, 6:58 PMbattk
09/24/2020, 6:58 PMlavi
09/24/2020, 7:01 PMlavi
09/24/2020, 7:01 PMbattk
09/24/2020, 7:02 PMlavi
09/24/2020, 7:03 PMlavi
09/24/2020, 7:04 PMlog.debug(JSON.stringify(context.request.body))
and watch the execution log.battk
09/24/2020, 7:04 PMlavi
09/24/2020, 7:04 PMbattk
09/24/2020, 7:04 PMlavi
09/24/2020, 7:05 PMlavi
09/24/2020, 7:05 PMbattk
09/24/2020, 7:05 PM