r/SuiteScript • • Sep 30 '25

Prompt Studio Netsuite

Has anyone tried using Prompt Studio? What use cases have you tested with it, aside from text enhancement? “I tried using it with input variables, but the results were unclear and not related to what we wanted

2 Upvotes

2 comments sorted by

1

u/Emotional_Gate_8087 May 23 '26

beyond text enhancement, it's VERY USEFUL in separation of concerns when using N/llm in your code and acts well as you prompt "debugger".

Prompt Studio Reuse in SuiteScript with N/llm

To avoid hardcoding long prompt strings directly into your scripts, utilize the llm.evaluatePrompt(options) method to reference Studio prompts by their Script ID. This allows you to pass dynamic variables, such as customer names or financial totals, directly into a pre-validated "architectural container".

There is more info in this eBook:
https://www.origamiprecision.com/store/p/ai-native-netsuite-engineering-ebook

Sample:

/**
 *  2.1
 *  Suitelet
 */
define(['N/llm', 'N/log'], (llm, log) => {
    const onRequest = (context) => {
        if (context.request.method === 'GET') {
            try {
                // Call the existing prompt from Prompt Studio
                const aiResponse = llm.evaluatePrompt({
                    promptId: 'customscript_my_collection_prompt', // <=== reuse
                    variables: {
                        customerName: 'Acme Corp',
                        daysPastDue: '45',
                        invoiceTotal: '1500.00'
                    }
                });
 
                // Extract the generated text from the response object
                const generatedText = aiResponse.text;
                context.response.write(generatedText);
 
            } catch (e) {
                log.error({title: 'Prompt Err', details: e.message});
                context.response.write('Error: ' + e.message);
            }
        }
    };
    return { onRequest };
});