When trying to handle the POST as stated above and...
# suitescript
i
When trying to handle the POST as stated above and then redirecting to another Suitelet I get the following error even though it is not disabled..
b
code?
i
Copy code
/**
 * @NApiVersion 2.1
 * @NScriptType Suitelet
 * @NModuleScope SameAccount
 */
define(['N/https', 'N/render', 'N/ui/message', 'N/ui/serverWidget','N/log','N/redirect','N/currentRecord'],
/**
 * @param{https} https
 * @param{render} render
 * @param{message} message
 * @param{serverWidget} serverWidget
 * @param{log} log
 * @param{redirect} redirect
 * @param{currentRecord}
 */
function(https, render, message, serverWidget, log, redirect,currentRecord) {
   
    /**
     * Definition of the Suitelet script trigger point.
     *
     * @param {Object} context
     * @param {ServerRequest} context.request - Encapsulation of the incoming request
     * @param {ServerResponse} context.response - Encapsulation of the Suitelet response
     * @Since 2015.2
     */
    function onRequest(context) {


        if (context.request.method == 'GET') {
            log.debug(context.request.method);
            let detrackListRequestForm = serverWidget.createForm({
                title: 'Local Delivery List Selector'
            });
            detrackListRequestForm.addField({
                id: 'custpage_selectshipdate',
                type: serverWidget.FieldType.DATE,
                label: 'Ship date'
            });
            detrackListRequestForm.addSubmitButton({
                label: 'Get list'
            });

            context.response.writePage(detrackListRequestForm);
        } else if (context.request.method == 'POST') {
            log.debug(context.request.method);
            let activeForm = currentRecord.get();
            let shipDate = activeForm.getValue({
               fieldId: 'custpage_selectshipdate'
            });
            redirect.toSuitelet({
                scriptId: 1294,
                deploymentId: 1,
                parameters: {
                    'custparam_shipdate': '11/04/2020'
                }
            });
        }
    }

    return {
        onRequest: onRequest
    };
    
});
s
cange those id's to strings not numbers
and you might need the
custscript
and
custdeploy
versions instead of the actual numbers
also if you are in
POST
, then you should have the data passed from the submit, specficially that ship date you are getting in post should be sitting on
context.request.parameters.custpage_selectshipdate
i
Still getting it with them as strings
I'll try pulling in the prefixes as well
s
Use the
custscript_
and
custdeploy_
versions
i
This didn't work
I'll try that way now
This didn't work either
b
Copy code
redirect.toSuitelet({
  scriptId: "99",
  deploymentId: "1",
  parameters: {
    custparam_shipdate: "11/04/2020",
  },
});
works for me
make sure your deployment has its status and audience setup correctly
i
So I don't think it's the redirect. If I comment everything out and run the POST deployment I still get the error...
So the suitelet is posting to itself from the form that is generated from the 'GET' portion. Is that a problem?
b
my guess is that you have a url wrong or somthing
you shouldn't be able to use currentRecord serverside
n
currentRecord.get() is an issue - perhaps not related to the the error you are getting. Regarding this error, can you check if there is any method set on your Suitelet deployment?