This topic contains 3 replies, has 0 voices, and was last updated by chanarbon 8 years, 2 months ago.

  • Author
    Posts
  • #1836

    david.smith

    Anyone find it weird or wrong that the lookupFields returns an array for the select field? I see this as necessary for multiselect fields but not for a regular select.

    https://netsuite.custhelp.com/app/an…ail/a_id/43711
    This is a cached copy. Click here to see the original post.

  • #1837

    michoel

    Absolutely, it took me a while to figure this out. It’s unintuitive and seems pointless.

    I also prefer the way SS1.0 returns the value directly instead of an object if you are only looking up a single field.

    SS1.0

    Code:
    var salerep = nlapiLookupField(‘customer’, id, ‘salesrep’);
    SS2.0

    Code:
    var results = search.lookupFields({type: search.Type.CUSTOMER, id: id, columns: ‘salesrep’});
    var salesrep = results.salesrep[0].value;
    Considering that this function is basically a convenience wrapper function instead of doing a search directly it should be as convenient as possible..

  • #1838

    ironside

    If it were convenient, it wouldn’t require passing an object with properties for the function params. Just count the number of characters and notice how much longer the SS2.0 solution is. In this regard, SS2.0 is a step backwards from SS1.0.


    david.smith replied on 09/06/2016, 08:47 AM: I’ve been doing a lot with SS2.0 and I’m still neutral about if it’s better or not. I do like working with objects much better. I’ve found some advantages and a few bugs.

  • #1839

    chanarbon

    Hi David,

    Yes. It returns an array which means that you always have to expect that you need to check whether the result has a content through the result value’s length. But I agree that regular select fields are better off as objects instead of array of objects with one element

You must be logged in to reply to this topic.