How to deploy Suitelet scripts? And how to test th...
# suitescript
s
How to deploy Suitelet scripts? And how to test them?
j
There’s not really anything different about deploying a Suitelet vs other scripts. Once you create a deployment, it will provide you with a URL where you can access the Suitelet.
message has been deleted
s
Even if it is a form, sublist or field creation, will it generate this URL?
j
I’m not sure what you mean by “sublist or field creation”
what is your Suitelet going to do?
s
Can I show you my code?
j
sure thing
s
Here, I created a form, which inside this form will have a sublist with some fields. These fields will be used ​​in another part of the company to record some employee data
Copy code
/**
 *@NApiVersion 2.x
 *@NScriptType Suitelet
 */
define(['N/ui/serverWidget'], function (serverWidget) {
    function onRequest(context){
        var formulario = serverWidget.createForm({
            title: 'Formulario Teste',
            hideNavBar: true
        });

    var sublista = formulario.addSublist({
            id: 'sublist_custom',
            label: 'Subslita inline',
            type: serverWidget.SublistType.INLINEEDITOR
        });

    sublista.addField({
            id: 'sublista_campo1',
            label: 'Código empresa',
            type: serverWidget.FieldType.TEXT
        });
    
    sublista.addField({
            id: 'sublista_campo2',
            label: 'Código funcionário',
            type: serverWidget.FieldType.TEXT
        });

    sublista.addField({
            id: 'sublista_campo3',
            label: 'Código evento',
            type: serverWidget.FieldType.TEXT
        });

    sublista.addField({
            id: 'sublista_campo4',
            label: 'Referência',
            type: serverWidget.FieldType.TEXT
        });

    sublista.addField({
            id: 'sublista_campo5',
            label: 'Valor',
            type: serverWidget.FieldType.TEXT
        });

    sublista.addField({
            id: 'sublista_campo6',
            label: 'Mês e ano',
            type: serverWidget.FieldType.DATE
        });

        var referencia = formulario.getSublist({
            id: 'sublist_custom'
        }).getField({
            id: 'sublista_campo4'
        })

        context.response.writePage(formulario);  
    };

    return{
        onRequest: onRequest
    };

});
At least that's what I think I'm doing 😧
r
jen is correct. Create the script record, create the deployment record, and click the link.
You're using the native form api to create a webpage. You can make a change to the script and refresh the page to test.
s
@reptar Sorry for the question, how do I do this? Would you have an example?
r
Customization → scripting → scripts → new
Save and deploy will bring you to deployment creation
s
@reptar hmm, i asked the wrong question. But thank you very much
r
Its no problem. Whats the issue?
s
@reptar It was just that. I was imagining that the Suitelet deployment was very different from other scripts. But thank you very much
party furby 1
j
ooops sorry for slow response, but thanks @reptar for taking over
😄 1