-1

I want to add item list as a select option. when user start to enter item name, Related items name shows in dropdown list.

Salman
  • 333
  • 4
  • 18

3 Answers3

0

Create a custom field and assign type as List/Record and in the list/record drop down select existing object or create a new list by clicking the [+] sign.

enter image description here

Jouhar N
  • 311
  • 1
  • 4
0

First create a list and get the internal ID. For example the internal id is 36

form.addField('myselectfield', 'select', 'my label', '36');
//here 36 is the internal id of the list you created
Jouhar N
  • 311
  • 1
  • 4
0

You need to have a search that would return ID and name:

  var fieldSrch= fieldValueSearch();
  var fld = form.addField('custpage_abc', 'select', 'MY SOURCED FIELD', null).setMandatory(true);
  fld.addSelectOption('', '');
  fieldSrch.forEach(function (opt) {
    fld.addSelectOption(opt.id, opt.value);
  });

and your functions would be as follows:

function fieldValueSearch() {
  var savedSearch = nlapiLoadSearch('your_srch_type', 'your_search_id');
  var results = getResults(savedSearch.runSearch()).map(function (x) {
    return {
      "id": x.getId(),
      "value": x.getValue('name')
    };
  }).sort(function (a, b) {
    return parseFloat(a.id) - parseFloat(b.id);
  });
  return results;
}


function getResults(set) {
  var results = [];
  var i = 0;
  while (true) {
    var result = set.getResults(i, i + 1000);
    if (!result) break;
    results = results.concat(result);
    if (result.length < 1000) break;
    i += 1000;
  }
  return results;
}
4N335
  • 267
  • 2
  • 29