0
votes

I recently started SuiteScript 2.0 development and am stuck on the following:

Customer has a need for a custom form. The form has 3 header fields:

location, week number and subsidiary. Depending on the values he enters in these three fields the values of a custom record need to be returned.

So I have built the custom form but am stuck on the proper function. I think I can do this by calling a client script from a custom button after filling in the values in the three header records. So my code would be:

/**
* @NApiVersion 2.x
* @NScriptType Suitelet
* @NModuleScope SameAccount
 */
 define(['N/record', 'N/redirect', 'N/ui/serverWidget'],
 /**
 * @param {record} record
 * @param {redirect} redirect
 * @param {serverWidget} serverWidget
  */
function(record, redirect, serverWidget) {

 /**
 * 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) {
    var request  = context.request;
    var response = context.response;


    var form     = serverWidget.createForm({
        title : 'Planning',
        hideNevBar : false

    });

    var LocationGrp = form.addFieldGroup({
        id : 'custpage_grp_main',
        label : 'Location'
    });

    var PlanningGrp = form.addFieldGroup({
        id : 'custpage_grp_sub',
        label : 'Planning'
    });


    var locatieFld = form.addField({
        id : 'custpage_location',
        type: serverWidget.FieldType.SELECT,
        label : 'Location',
        source : 'location',
        container : 'custpage_grp_main'
    });

    var subsidiaryFld = form.addField({
        id : 'custpage_subsidiary',
        type: serverWidget.FieldType.SELECT,
        label : 'Subsidiary',
        source : 'subsidiary',
        container : 'custpage_grp_main'
    });

    var weekFld = form.addField({
        id : 'custpage_weeknr',
        type: serverWidget.FieldType.SELECT,
        label : 'Weeknumber',
        source : '500',
        container : 'custpage_grp_main'
    });


    var sublijst = form.addSublist({
        id : 'custpage_lines',
        type: serverWidget.SublistType.INLINEEDITOR,
        label : 'LINES'
    });


    var itemFld = sublijst.addField({
        id : 'custpage_item',
        type : serverWidget.FieldType.SELECT,
        source : 'item',
        label : 'Item'
    });



    // Buttons

    form.addButton({
        id: 'getval',
        label: 'Get lines',
        functionName: 'setButton'
    });
    form.clientScriptModulePath = './script.js';


    response.writePage(form);
}
    return {
            onRequest: onRequest
        };

});

However, I am unsure what code to use in the client script in order to retrieve 'Item' on the line.

The custom record containing all the item lines has four columns:

Location, week number, subsidiary and item.

Who can help (and is my question somewhat coherent)?

1

1 Answers

0
votes

Ok, so I found the answer by going another route.

I have 2 forms, the first has the input fields and a button. After clicking on the button the second form is loaded and uses the input from form 1 as input values for the filters in a saved search. The saved search is then posted to the second form.

Works..... kind of.