scriptContext.form.addButton({ id: "custpage_prep...
# ask-stanley-ai
j
scriptContext.form.addButton({ id: "custpage_prepayment_journal", label: "Process Prepayment Journal", functionName: "processVendorPrepaymentJournal(" + newRec + ");" }); functionName parameter not working
c
AI generated answer (using internal Slack threads):
Based on the conversations, it seems like the issue is with passing parameters to a custom function through a button click in a Suitelet. The
functionName
parameter in the
addButton
method is a string that gets evaluated when the button is clicked. Therefore, you need to ensure that the string you're passing is a valid JavaScript function call. Here's an example of how you can pass parameters to a custom function:
Copy code
javascript
var newRec = context.newRecord.id;
context.form.addButton({
    id: "custpage_clickme",
    label: "Click Me",
    functionName: `createshippinglabel('${newRec}')`,
});
In this example,
createshippinglabel
is the custom function and
newRec
is the parameter being passed to it. Note the use of template literals (backticks) to construct the function call string. This allows you to embed expressions (like variables) within the string. Also, make sure that the custom function you're calling (
createshippinglabel
in this case) is properly defined and accessible in the scope where the button is being clicked. ****** Disclaimer: This response was generated by an artificial intelligence assistant based on previous conversations from multiple Slack channels, and may contain inaccuracies or mistakes. ******
Slack thread 1: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.837402761
Slack thread 2: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.834024727
Slack thread 3: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.833213091
Please provide your feedback on this answer.