-1

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

ImageExample

/**
 
*@NApiVersion 2.x
 
*@NScriptType Suitelet
 
*/

define(['N/ui/serverWidget'], function (serverWidget) {

    function onRequest(context) {

        var formulario = serverWidget.createForm({

            title: 'Formulário',

            hideNavBar: false

        });
        formulario.addButton({

            id: 'buttonid',

            label: 'Cancelar'

        })
        formulario.addSubmitButton({

            label: 'Enviar'

        });
        /*
         
        formulario.addField({
         
        id: 'field_test',
         
        type: serverWidget.FieldType.INTEGER,
         
        label: 'campo teste',
         
        container: 'fieldgroupcapture'
         
        })
         
        */
        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.maxLength = 5;
        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

    };
});

1 Answers1

0

Your script would need to handle a POST request. Right now it doesn't distinguish between GET and POST so it just shows the form over and over.

function onRequest(context){
   if (context.request.method === 'GET') {
      ... your current code
   }else{ // assumes POST
      handle creating/updating an employee record
   }
}

Another approach to consider would be to just have a heavily edited standard employee form linked to a role. That is then code free except possibly a UserEvent script that forces the edited form to be shown based on user and context.

bknights
  • 14,408
  • 2
  • 18
  • 31
  • The question is stupid, but it is necessary for understanding and study. What do I add to ELSE? – NiceGuy240 Sep 03 '21 at 17:48
  • your original question doesn't say what you are trying to do. Is this a self serve portal that an employee uses to update their own records. Is this for HR to update or create a new employee? So Who is meant to use it? Is it for creation or update or either? Also this is not a site where anyone is paid to do your work for you. It's meant to be for answering very specific questions. You have to put in some work here. – bknights Sep 03 '21 at 18:27
  • But I'm not asking you to do my job. And yes, it is HR who will use it. They're going to include an employee tracking system around here. – NiceGuy240 Sep 08 '21 at 13:20