Accessing Sublist Lines in POST Request Processing

This article will focus on a crucial aspect of POST request processing – the exploration of sublist lines within custom forms.

Retrieve Sublist Length:

  • scriptContext.request.getLineCount({ group: 'sublistid' });
  • This line retrieves the number of sublist lines (entries) submitted for a sublist with the group ID ‘custpage_jj_customers_list.’
  • The group ID is the id of the sublist.

Iterating Through Sublist Lines and Accessing Sublist Values:

  • Create a loop which iterates through each sublist line.
  • Can use ‘scriptContext.request.getSublistValue({ })’ to retrieve the value of the field for each sublist line.
  • Group: Specifies the sublist group ID. This parameter identifies the specific sublist within the form or record.
  • Name: Specifies the internal ID or name of the sublist field from which to retrieve the value.
  • Line: Specifies the line number (index) of the sublist from which to retrieve the value.

if (scriptContext.request.method === 'POST') {
    let sublistLength = scriptContext.request.getLineCount({ group: 'custpage_jj_customers_list' });
    
    for(let i = 0; i< sublistLength; i++) {
        
        let custSelect = scriptContext.request.getSublistValue({
            group: 'custpage_jj_customers_list',
            name: 'custpage_jj_cust_select',
            line: i
        });

        // [Further code can be added for processing sublist line data]

    }
}

Leave a comment

Your email address will not be published. Required fields are marked *