This topic contains 2 replies, has 0 voices, and was last updated by lukaszMycs 8 years, 1 month ago.

  • Author
    Posts
  • #1675

    lukaszMycs

    Today I wanted to create first 2.0 Suitelet, but I couldn’t find any simple and easy way to get sublist data from sublist which was created as a part of Suitelet form. Of course you have context.request.parameters.sublistdata where all the data are stored after page submit, but you need to manually split it. I thought that maybe I’m missing something, but actually this is the part of an example from Netsuite help:

    var delimiter = /u0001/;

    var textField = context.request.parameters.textfield;

    var dateField = context.request.parameters.datefield;

    var currencyField = context.request.parameters.currencyfield;

    var selectField = context.request.parameters.selectfield;

    var sublistData = context.request.parameters.sublistdata.split(delim iter);

    var sublistField1 = sublistData[0];

    var sublistField2 = sublistData[1];

    which means that actually splitting is the correct way (Netsuite example is for getting only first 2 fields of first row. If you have more rows you need to split it by /u0002 to get rows and then each row by /u0001/ to get fields.

    If you consider the fact that in SuiteScript 1.0 you have nlobjRequest which has getLineItemCount(group) and getLineItemValue(group, name, line) and in 2.0 you need to split the data to extract it from 1 huge string, it’s just step backwards. I was hoping that either context.request.parameters.sublistdata will have array of row objects, or there will be some method to get sublist data as JSON object.

    Am I missing something? Is there any other (better) way of getting sublist data from suitelet form?
    This is a cached copy. Click here to see the original post.

  • #1676

    chanarbon

    Hi lukaszMycs ,

    You can you context.request.getLineCount() and context.request.getSublistValue() for Suitelets in SuiteScript 2.0

    To use getLineCount()

    Code:

    var lineCount = request.getLineCount({ group: “custpage_transaction_list” });
    where group is the id of your sublist.

    To use getSublistValue()

    Code:
    var markedAsDelete = request.getSublistValue({
    group: “custpage_transaction_list”,
    name: “delete”,
    line: 0
    });
    where group is the id of your sublist, name is the id of the field in the sublist and line is the line number

  • #1677

    lukaszMycs

    Great I will test that later. I was searching under http not https module – my fault, but all in all it would be good to update the example under https://system.eu2.netsuite.com/app/…321345532.html to use getLineCount and getSublistValue instead of splitting by delimiter.

You must be logged in to reply to this topic.