I trying to learn set up automaticaly using client script lookupField where input at field customer, then the field in the salesman section will change according to record_customer_sales_person.
/**
* @NApiVersion 2.1
* @NScriptType ClientScript
*/
define(['N/search'],
function (search) {
function fieldChanged(context) {
var currentRecord = context.currentRecord
var fieldId = context.fieldId
if (fieldId != 'customer') return
const id = currentRecord.getValue({ fieldId: 'custrecord_me_customer_name' })
if (!id) return
search.lookupFields.promise({
type : search.Type.record_customer_sales_person,
id : 60,
columns : [ 'custrecord_me_customer_name','custrecord_me_join_sales_person' ]
}).then(function(user) {
currentRecord.setValue({ fieldId: 'custrecord_me_customer_name', value: user.customer });
currentRecord.setValue({ fieldId: 'custrecord_me_join_sales_person', value: user.custbody_salesman });
log.debug({
details: "test: " + user});
});
}
return {
fieldChanged: fieldChanged
}
});
I trying this but has not respond( even error notification is not showing). How to fixed this case. Thank you for your helping
I'm assuming this is a custom record?
search.Type.record_customer_sales_person does not exist as a valid Enum value. Here's the list of valid Enum values for search.Type
Use
customrecord_record_customer_sales_person
instead ofsearch.Type.record_customer_sales_person