For a suitelet client script, how do you get field...
# suitescript
k
For a suitelet client script, how do you get fields when a button is clicked? I added a button to call my client script function but not sure of the best way to get the form field values on the client side?
Copy code
// Suitelet side
  form.addButton({
    id: 'custpage_run_command',
    label: 'Run Command',
    functionName: 'runCommand'
  });
Copy code
// Client side
function runCommand() {
  // Do stuff
}
I figured it out myself. ChatGPT and Github Copilot hallucinated awful dom-hacking solutions. I looked through past examples I've done before and forgotten about.
Copy code
const runCommand = () => {
        const rec = currentRecord.get();
        const command = rec.getValue({ fieldId: 'custpage_command' });

        console.log('Current Record Command Field Value:', command);
    };
😆 1
d
I was just coming here to say it was the functionName method but it looks like you worked it out. That's hilarious about the dom-hacking experiences, though. AI is good when it's good and other times maybe not so much. 😵‍💫
🤣 1
b
I wonder if these models got trained on a dom hacking subreddit, they seem to think it is SO fun.
😆 2
k
I think it's more that they see SuiteScript as purely a subset of JavaScript
so they give solutions that are typical for web development in general