Tim Pilgrim
02/01/2023, 11:14 PMsublist.addButton({
id: 'btnTestGoBack',
label: 'Test',
functionName: "callProcess('7', 'urlOne')"
});
but doesnt work when you do
'<a href="#" onclick="callProcess(\'7'\, \'urlOne\')">Start Process</a>'
Thanks
Timbattk
02/02/2023, 12:16 AMTim Pilgrim
02/02/2023, 1:52 AMfunction callProcess(batchId, passedUrl) {
alert('Requesting Processing');
let response = nsHttps.post.promise({
url: passedUrl,
body: JSON.stringify({
op: 'srtRate',
headerRecordId: batchId
})
}).then(response => {
if (response?.code === 200) {
alert('Submitted');
} else {
log.error({title: 'callProcess', details: {response: response} });
}
}).catch(e => { log.error({title: 'callProcess', details: {e: e} });});
}
battk
02/02/2023, 1:53 AMbattk
02/02/2023, 1:53 AMbattk
02/02/2023, 1:53 AMTim Pilgrim
02/02/2023, 1:53 AMdefine(['N/https', 'N/log'],
(nsHttps, log) => {
/**
* Module Description...
*
* @type {Object} module-name
*
* @copyright 2023 SuiteFunction
* @author Tim Pilgrim <tim@suitefunction.com>
*
* @NApiVersion 2.1
* @NModuleScope SameAccount
* @NScriptType ClientScript
*/
var exports = {};
/**
* pageInit event handler; executed when the page completes loading or when the form is reset.
*
* @gov XXX
*
* @param {Object} context
* @param {string} context.mode - The access mode of the current record.
* @param {CurrentRecord} context.currentRecord - The record in context
*/
function pageInit(context) {
// TODO
}
function callProcess(batchId, passedUrl) {
alert('Requesting Processing');
let response = nsHttps.post.promise({
url: passedUrl,
body: JSON.stringify({
op: 'srtRate',
headerRecordId: batchId
})
}).then(response => {
if (response?.code === 200) {
alert('Submitted');
} else {
log.error({title: 'callProcess', details: {response: response} });
}
}).catch(e => { log.error({title: 'callProcess', details: {e: e} });});
}
exports.pageInit = pageInit;
exports.callProcess = callProcess;
return exports;
});
battk
02/02/2023, 1:53 AMbattk
02/02/2023, 1:54 AMbattk
02/02/2023, 1:55 AMTim Pilgrim
02/02/2023, 1:56 AMonclick="var rConfig = JSON.parse( '{}' ) ; rConfig['context'] = '/SuiteScripts/SuiteFunction/Batching/SF_createBatch_cs'; var entryPointRequire = require.config(rConfig); entryPointRequire(['/SuiteScripts/SuiteFunction/Batching/SF_createBatch_cs'], function(mod){ try{ if (!!window) { var origScriptIdForLogging = window.NLScriptIdForLogging; var origDeploymentIdForLogging = window.NLDeploymentIdForLogging; window.NLScriptIdForLogging = 'customscript_sf_create_batch'; window.NLDeploymentIdForLogging = 'customdeploy_sf_create_batch'; }mod.callProcess('7', 'urlOne');}finally{ if (!!window) { window.NLScriptIdForLogging = origScriptIdForLogging; window.NLDeploymentIdForLogging = origDeploymentIdForLogging; }} }); return false;"
Tim Pilgrim
02/02/2023, 1:57 AMbattk
02/02/2023, 1:58 AMTim Pilgrim
02/02/2023, 2:43 AM