How do I go through a list of all values of a multi-select in a Netsuite saved search and get a list of the values that haven’t been selected?

I’m writing a saved search in Netsuite that requires that I output the following:

Rather than just a list of the selected values from a multi-select, I need to output the full list and prepend those values that aren’t selected with a minus (-) symbol.

The use case of this is to send this information to a channel management system, so if the items are not selected in the multi-select, rather than not being listed at all, they need to be a
-marketplace_name (e.g. the finished string would look like the following:

“Amazon AU Marketplace, -Bunnings, -Catch”

This essentially translates to mean:

  1. List on Amazon AU Marketplace
  2. Remove from Bunnings
  3. Remove from Catch

I’d like to ask whether anyone’s aware of how to get a list of all values that haven’t been selected, rather than those that are (the default behaviour) of a multi-select list, or alternately, how to get a list of all values, whether selected or not?

The formula I’m using at present is a simple Formula(Text) field to retrieve the actual selected values is as follows:

{custitem_pim_enabled_marketplaces_aus}

Following is a screenshot of what I’m trying to achieve:

further details of what I’m trying to achieve

Many thanks and hopefully there’s some way to get this list simply without resorting to string explodes via SUBSTR(), etc.

Given that at present I only have a list of the “selected” items on the multi-select, thus far I’ve attempted something similar to the following, though given I’m essentially only able to cycle through the list of selected item, not the full list of items, this strategy isn’t going to work.

CASE WHEN {custitem_pim_enabled_marketplaces_aus} NOT LIKE ‘%Amazon AU Marketplace%’ THEN ‘-Amazon AU Marketplace’ ELSE END

Any ideas would be appreciated.

Regards,

Christian

1

If you know the full list of possible values beforehand, and it’s a manageable size, you can specify that list and use REPLACE and REGEXP_REPLACE to modify how it’s shown. In the following example, I start with a full list with hyphens prepended (1). I then use REPLACE to generate a regex pattern (it replaces the commas which NetSuite returns with pipes (|) to provide “alternation” between the various possible values (2). It also wraps the pattern in parentheses to allow for the backreference 1 )

If a match is found I replace it with the same value, but with another hyphen prepended (3). I then replace any double hyphens with an empty string (4).

I’m using a custom field from my account which contains days of the week, so be sure to replace the field reference and values with the relevant data from your account. Also, you may need to remove the comments if you paste it into NetSuite

REPLACE(                                             --4
  REGEXP_REPLACE(                                    --3
    '-Friday,-Monday,-Thursday,-Tuesday,-Wednesday', --1 (replace with your values)
    '(' || REPLACE(                                  --2
      {custrecord_sg_day_of_the_week},               --2 (replace with your custom field)
      ',', '|'                                       --2
    ) || ')',                                        --2
    '-1'                                            --3
  ), 
  '--',                                              --4
  ''                                                 --4
)

EDIT: To handle the scenario where some records have no value selected for that field, you can use a CASE statement to test for that and simply return the initial string containing all values with the prepended hyphen:

CASE WHEN {custrecord_sg_day_of_the_week} IS NULL THEN '-Monday, -Tuesday, -Wednesday, -Thursday, -Friday' ELSE REPLACE(
  REGEXP_REPLACE(
    '-Monday, -Tuesday, -Wednesday, -Thursday, -Friday', 
    '(' || REPLACE(
      {custrecord_sg_day_of_the_week}, 
      ',', '|'
    ) || ')', 
    '-1'
  ), 
  '--', 
  ''
) END

3

This is an add on to @krypton ‘s brilliant answer.

I’ll often create searches in the console so you could generate this even for large somewhat ‘unmanageble’ lists. You’ll have access to the search API in any view or edit window. Open some record, right-click, choose ‘Inspect’ to open a console.

require(['N/search'], search=>{
    // make the name string
    const names = search.create({
        type:'customrecord_listing_markets', //record or list name
        filters:['isinactive', 'is', 'F'], 
        columns: 'name'
    }).run().getRange({start:0, end:1000}).map(ref=>('-'+ ref.getValue({name:'name'}))).join(',');

   //make a search you can open in the UI
    search.create({
    type:'item',
    filter: [...],
    columns: [
       'itemid',
       `formulatext:REPLACE(                                             
  REGEXP_REPLACE(                                    
    '${names}', 
    '(' || REPLACE(                                  
      {custitem_pim_enabled_marketplaces_aus},               
      ',', '|'                                       
    ) || ')',                                        
    '-1'                                            
  ), 
  '--',                                              
  ''                                                 
)`],
title:'Item Marketplaces'
    }).save();
)


Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật