This topic contains 6 replies, has 0 voices, and was last updated by jmkplessers 7 years, 1 month ago.

  • Author
    Posts
  • #18200

    mburstein

    I’m working with the Contracts Renewals module and I’m trying to set some line values on the Contract Item Sublist based on the originating Sales Order. However, it looks like I’m unable to get the “Original Transaction” and “Original Line No” fields using getSublistValue in a User Event script?

    The item field comes back fine but originalTransaction/originalLineNo just come back undefined. Is there a better way to do this? or is there a different fieldId I should be using?

    I was also looking into trying to use the subrecord APIs but I couldn’t figure out what fieldId I was suppose to use to get the Contract Item subrecord from the Contract records sublist. Anyone know what the fieldId should be?

    Code:
    var contractRecord = context.newRecord;
    var contractItemCount = contractRecord.getLineCount({
    sublistId: ‘recmachcustrecord_ci_contract_id’
    });
    for (var i = 0; i This is a cached copy. Click here to see the original post.

  • #18201

    mburstein

    Looks like the right way to do this is through the search module lookupFields():

    Code:
    var contractItemId = contractRecord.getSublistValue({
    sublistId: ‘recmachcustrecord_ci_contract_id’,
    fieldId: ‘id’,
    line: i
    });

    var fieldLookUp = search.lookupFields({
    type: ‘customrecord_contract_item’,
    id: contractItemId,
    columns: [‘custrecord_ci_original_transaction’, ‘custrecord_ci_original_so_lineno’]
    });

  • #18202

    erictgrubaugh

    Careful doing your `lookup`s inside the loop; if you get large contracts, you might run out of governance. Instead you can pull out all of the `contractItemId`s into a single Array in your loop, then do a single `search` to get all of the original SO data for each one.

  • #18203

    mburstein

    Thank you for the tip. I ended up having to approach this from the Contract Item record anyway, so I was able to avoid a loop. However, I ran into a different problem when trying to set my custom field. When I edit/save the record everything works fine but if I use the “Create Contract Items” button on the Contract record I get the following error:

    Code:
    INVALID_FLD_VALUE You have entered an Invalid Field Value 8.0 for the following field: custrecord_count
    The field is definitely an integer field and sets without a problem in other contexts, so I’m a bit confused. Is this a Suitescript 2.0 issue?

  • #18204

    JohnCCole

    Perhaps SuiteScript 2 is doing greater type checking. Have you tried using parseInt on the value just to see if that works?

  • #18205

    mburstein

    Yes, I tried parseInt, I tried toString, I tried setting text instead of value, I even tried a few different options with the N/format module. Pretty much everything gives the same result where it sets the value fine in edit/save but I get INVALID_FLD_VALUE when I use the processing buttons.

    Any other ideas?

  • #18206

    jmkplessers

    Hi mburstein, today I experienced a similar issue with INVALID_FLD_VALUE , except I was trying to set a currency field.

    The following is all server-side.

    I saw:

    Code:
    You have entered an Invalid Field Value 4 for the following field: amount
    when I tried to save a record after doing this:

    Code:
    // …
    var amt = 4;
    rec.setSublistValue({
    sublistId: ‘expense’,
    fieldId: ‘amount’,
    line: 0,
    value: amt
    });

    Like you I was trying to use a JavaScript number.

    I was able to get NetSuite to accept my value by using the toFixed() method, which converts a number to a string with a certain number of decimal places:

    Code:
    // …
    var amt = 4;
    rec.setSublistValue({
    sublistId: ‘expense’,
    fieldId: ‘amount’,
    line: 0,
    value: amt.toFixed(2)
    });
    I hope this helps.

You must be logged in to reply to this topic.