How do I get the value of a field I added to a por...
# suitescript
b
How do I get the value of a field I added to a portlet:
Copy code
var container = params.portlet.addField({
                id: 'custpage_cdp_track_container',
                label: 'Enter Container',
                type: serverWidget.FieldType.TEXT
            });
b
if you want to get it clientside, then you would use CurrentRecord.getValue
getting it serverside after the submit button has been pressed depends on the service behind the target url
if its a suitelet, you probably will be using ServerRequest.parameters
b
it's a portlet, here is the complete script:
Copy code
/**
 * @NApiVersion 2.x
 * @NScriptType Portlet
 * @NModuleScope SameAccount
 */
define(['N/ui/serverWidget'],
    /**
     * @param {portlet} portlet
     * @param {serverWidget} serverWidget
     */
    function(serverWidget) {
        /**
         *
         * @param {Object} params
         * @param {Portlet} params.portlet - The portlet object used for rendering
         * @param {number} params.column - Specifies whether portlet is placed in left (1), center (2) or right (3) column of the dashboard
         * @param {string} params.entity - (For custom portlets only) references the customer ID for the selected customer
         * @Since 2015.2
         */
        function render(params) {
            params.portlet.title = 'Container Tracking';
            var container = params.portlet.addField({
                id: 'custpage_cdp_track_container',
                label: 'Enter Container',
                type: serverWidget.FieldType.TEXT
            });
            var urlPre = '<https://connect.track-trace.com/container/>';
            var urlPost = '/action,direct';
            var url = urlPre + '' + urlPost;  //TODO: figure out how to get what was entered
            params.portlet.setSubmitButton({
                url: url,
                label: 'TRACK'
            });
            log.debug({
                title: 'container data',
                details: JSON.stringify(params)
            });
        }

        return {
            render: render
        };
    });
b
your post button goes to https://connect.track-trace.com
thats where you would get the data
b
What I mean, is how do I get what the user put into the portlet field I created
b
use a client script to get it clientside
otherwise your browser will send it directly to the submit url as a form post
b
got it, ok, what if it is on a dashboard suiteapp
can you use client side there?
basically the user enters the container and then is taken to the tracking page
b
dont know, try it out