Artur_K
04/27/2022, 6:49 AM/**
*@NApiVersion 2.0
*@NScriptType UserEventScript
*@NModuleScope Public
*/
define(['N/record', 'N/runtime', 'N/email'], function(record, runtime, email) {
function afterSubmit(context) {
var status = context.newRecord.getValue({
fieldId: 'approvalstatus',
});
var currentRecord = context.newRecord.id; // get record id
email.send({
author: runtime.getCurrentUser().id,
body: 'This record has following information ' + currentRecord + status,
recipients: 'test',
subject: 'Test',
})
}
return {
afterSubmit: afterSubmit,
}
});
battk
04/27/2022, 6:50 AMArtur_K
04/27/2022, 6:52 AMvar status = context.newRecord.getValue({
fieldId: 'approvalstatus',
});
battk
04/27/2022, 6:54 AMbattk
04/27/2022, 6:55 AMbattk
04/27/2022, 6:55 AMbattk
04/27/2022, 6:55 AMArtur_K
04/27/2022, 6:56 AMif(status == 'Approved'){
// do something
}
battk
04/27/2022, 6:57 AMArtur_K
04/27/2022, 6:57 AMbattk
04/27/2022, 6:57 AMbattk
04/27/2022, 6:57 AMbattk
04/27/2022, 6:58 AMArtur_K
04/27/2022, 6:59 AMbattk
04/27/2022, 7:00 AMbattk
04/27/2022, 7:01 AMArtur_K
04/27/2022, 7:02 AMArtur_K
04/27/2022, 7:58 AM/**
*@NApiVersion 2.0
*@NScriptType UserEventScript
*@NModuleScope Public
*/
define(['N/record', 'N/runtime', 'N/email', 'N/search'], function(record, runtime, email, search) {
function afterSubmit(context) {
var id = context.newRecord.id; // get record id
var fieldLookUp = search.lookupFields({
type: search.Type.PURCHASE_ORDER,
id: id.toString(),
columns: 'entity'
});
email.send({
author: runtime.getCurrentUser().id,
body: 'This record has following information ' + id + fieldLookUp.entity + ' MARK ' + fieldLookUp,
recipients: '<mailto:artur.kasakow@aimsport.com|artur.kasakow@aimsport.com>',
subject: 'Test',
})
}
return {
afterSubmit: afterSubmit,
}
});
Somehow I cannot access the object and return a valid output.
The email I receive is always the object itself:
This record has following information 12795[object Object] MARK [object Object].
It should output the entity that I defined in the columns, no?
I tried to access the list element with the index 0 as well, but the output was undefined.
What am I doing wrong here?battk
04/27/2022, 8:03 AMbattk
04/27/2022, 8:05 AMfieldLookUp.entity
is an object, and converting an object to a string ends up using Object.prototype.toString()battk
04/27/2022, 8:05 AMbattk
04/27/2022, 8:05 AMArtur_K
04/27/2022, 8:19 AM