Svenmann
01/22/2021, 11:29 AMdefine(['N/currentRecord', 'N/record'], function(currentRecord, record){
var exports= {};
function beforeLoad(scriptContext) {
scriptContext.form.addButton({
id:"custpage.button",
label:"Press Me",
functionName:"myMail"
}
)
// path to Button function:
scriptContext.form.clientScriptModulePath="SuiteScripts/mybuttonfunc.js";
}
exports.beforeLoad = beforeLoad;
return {exports};
});
ClientScript.js :
define(['N/record'], function(record) {
var exports = {};
function pageInit() {}
function myMail(scriptContext){
var shippingS = scriptContext.newRecord.getText({fieldId: 'shipstatus'})
// var shippingS = scriptContext.newRecord.getValue({fieldId: 'shipstatus'});
}
exports.pageInit = pageInit;
exports.myMail = myMail;
return exports;
});
battk
01/22/2021, 11:33 AMWatz
01/22/2021, 11:33 AMWatz
01/22/2021, 11:33 AMWatz
01/22/2021, 11:33 AMbattk
01/22/2021, 11:35 AMWatz
01/22/2021, 11:36 AMWatz
01/22/2021, 11:36 AMSvenmann
01/22/2021, 11:37 AMWatz
01/22/2021, 11:38 AMWatz
01/22/2021, 11:38 AMWatz
01/22/2021, 11:42 AMsearch.lookupFields({type: 'salesorder', id:currentRecord.get().id, columns:['shipstatus']})
battk
01/22/2021, 11:51 AMbattk
01/22/2021, 11:52 AMscriptContext.form.addButton({
id: "custpage.button",
label: "Press Me",
functionName: "myMail('im a string')",
});
MTNathan
01/22/2021, 2:57 PMfunctionName
works. Do you know otherwise and/or do you see it as fairly low-risk undocumented code? It definitely feels like a better solution to me (better for performance, if nothing else) than constantly using currentRecord.get()
in client functions.b
01/22/2021, 3:55 PMWatz
01/22/2021, 4:01 PMSandii
01/22/2021, 4:02 PM`(function myMail(){
//add all your stuff here
})()`
If using 2.1, the tick string notation makes this much easier to readb
01/22/2021, 4:35 PMMTNathan
01/22/2021, 4:41 PMN/currentRecord
to set values in view? If so, that's probably the issue - you'll need to use N/record
to submitFields or a combination of load/setValue/save instead.b
01/22/2021, 5:58 PMb
01/22/2021, 5:58 PMfunction iBeenClicked (){
var soRec = currentRecord.get();
var soRecObj = r.load({
type: r.Type.SALES_ORDER,
id: soRec.id
});
soRecObj.setValue({
fieldId: 'custbody_gvo_rerelease',
value: true
});
soRecObj.save();
window.location.reload();
}
MTNathan
01/22/2021, 6:32 PMcustbody_gvo_rerelease
is a checkbox field that stores value and that currentRecord
and r
are the N/currentRecord
and N/record
modules). It's not throwing an error, right? Have you tried putting a console.log
or alert
in there to make sure the function is getting triggered at all?b
01/22/2021, 8:55 PMSandii
01/22/2021, 9:18 PMbattk
01/23/2021, 1:26 AMbattk
01/23/2021, 1:28 AMnO3
01/31/2021, 3:03 PM