Kevin Baxter
07/10/2023, 7:23 PM[3:03 PM] const beforeLoad = (scriptContext) => {
try {
// only run in view mode
// if (scriptContext.type !== scriptContext.UserEventType.VIEW) return;
// get form and record then attach our client script to the form. This will ensure that the button click action
// will run our client script function.
const { form, newRecord } = scriptContext;
const recCurrent = scriptContext.newRecord;
const objForm = scriptContext.form;
const stStatus = recCurrent.getValue({
fieldId: 'status'
});
const stSuiteletLinkParam = runtime.getCurrentScript().getParameter({
name: 'custscript2'
});
// attach client script to form.
objForm.clientScriptModulePath = "./OpenSuiteClientScript.js";
//const suiteletURL = '\"' + stSuiteletLinkParam + '\"';
if (stStatus === 'Pending Fulfillment') {
// objForm.addButton({
// id: 'custpage_suiteletbutton',
// label: 'Print CompN',
// functionName : 'window.open(' + suiteletURL + ')',
// });
// }
// create button, give it a name, and assign it the function we will write in our client script
// When the button is clicked, it will run the function we assign to it.
const printButton = form.addButton({
id: "custpage_custom_button1",
label: "Something",
functionName: "callSuitlet",
});
}
} catch (e) {
log.error({ title: "Error in beforeLoad", details: e });
}
}
[3:06 PM] I tried to log out the stSuiteLinkParam but I didnt get anything
[3:06 PM] log.debug("suitelink", stSuiteLinkParam)reptar
07/10/2023, 7:53 PMKevin Baxter
07/10/2023, 8:04 PMKevin Baxter
07/10/2023, 8:04 PMKevin Baxter
07/10/2023, 8:05 PMreptar
07/10/2023, 8:05 PMreptar
07/10/2023, 8:07 PMreptar
07/10/2023, 8:07 PMKevin Baxter
07/10/2023, 8:15 PMKevin Baxter
07/10/2023, 8:15 PMfunction pageInit(scriptContext) {
function callSuitlet() {
try {
log.debug("this is firing", suiteletUrl);
// call the suitelet
const suiteletUrl = url.resolveScript({
scriptId: "customscript1197",
params: {},
returnExternalUrl: false,
});
// load the suitelet in the browser
window.open("<https://www.google.com>");
} catch (e) {
log.error({ title: "error in callSuitelet", details: e });
}
}
}
reptar
07/10/2023, 8:18 PMpageInit
, and returned like any other entry point function.Kevin Baxter
07/10/2023, 8:18 PMNElliott
07/12/2023, 7:41 AM