I need to save and submit the information for a fo...
# suitescript
s
I need to save and submit the information for a form for enrollment > employees, each time it is filled out. I need to save and submit the information for a form for enrollment > employees each time it is filled out. I sent an image of where I want the information to be stored. I created a send button, but it doesn’t send. I made this code, but I think something is missing. However, I'm not sure what it would be.
Copy code
/**
*@NApiVersion 2.x
*@NScriptType Suitelet
*/
define(['N/ui/serverWidget'], function (serverWidget) {
    function onRequest(context) {
        var formulario = serverWidget.createForm({
            title: 'Formulário',
            hideNavBar: false
        });
        formulario.addCancelButton({
            id: 'btnCancel',
            label: 'Cancelar'
        })
        formulario.addSubmitButton({
            id:'btnsubmit'
            label: 'Enviar'
        });
        formulario.addField({
            id: 'sublista_campo1',
            label: 'Código empresa',
            type: serverWidget.FieldType.INTEGER
        });
        formulario.addField({
            id: 'sublista_campo2',
            label: 'Código funcionário',
            type: serverWidget.FieldType.TEXT
        })
        formulario.addField({
            id: 'sublista_campo3',
            label: 'Código evento',
            type: serverWidget.FieldType.INTEGER
        });
        var fieldReference = formulario.addField({
            id: 'sublista_campo4',
            label: 'Referência',
            type: serverWidget.FieldType.INTEGER
        });
        var fieldValue = formulario.addField({
            id: 'sublista_campo5',
            label: 'Valor',
            type: serverWidget.FieldType.FLOAT
        });
        formulario.addField({
            id: 'sublista_campo6',
            label: 'Mês e ano',
            type: serverWidget.FieldType.DATE
        });
        if (fieldReference === " && fieldReference === null) {
            fieldReference.defaultValue = '0000'
        };
        if (fieldValue === " && fieldValue === null) {
            fieldValue.defaultValue = '0000'
        }
        context.response.writePage(formulario);
    };
    return {
        onRequest: onRequest
    };
});
c
When you say "where I want the information to be stored" what do you mean? You want a link to the suitelet on that menu? Or something else? Your suitelet doesn't do anything apart from display a form
s
As CD pointed out, the important part you are missing is handling the submit button. You need to add something that checks the
_context_.request.method
for
'GET'
(where you display the form) and
'POST'
where you handle the action of the submit button.
👍 1
For the second part, you should read on the sections in
Customization -> Centers and Tabs
and understand the layers there
👍 1
s
Hey @CD What I said was to store the data in "employee". He understands? Every time this form is filled out, I wanted the form data to be stored there, under "employees", as in the picture. Every time the person accesses this tab, the data will be there.