I have a List/Record field on a custom record call...
# suitescript
b
I have a List/Record field on a custom record called "Field". The List/Record for the field is Fields. I want to create more of my custom record via script. In my script, I have the script ID of the field I want to set in the "Field" field, but the "Field" field only uses internal ID as the value. How can I find the internal ID of a field from its script ID? Or is there some other solution?
e
So you want all the Internal IDs of the values in the
Fields
list?
You can do a search.
b
Can that give me a list of the values and their script IDs?
e
Probably? Where do these Script IDs come from?
b
Example: I want to set my "Field" field to the script ID "companyname". "Field" only accepts field internal IDs, not field script IDs.
I don't think I can do a search on fields
I'd love to be wrong
e
You said your
Field
is backed by a List/Record, so which List/Record is it?
b
The List/Record is "Fields"
e
And what does
Fields
consist of? Is it a Custom Record itself?
b
message has been deleted
e
Why can't you run a search of
Fields
?
b
Fields is a standard record type
Fields are NetSuite fields
e
I see; have never seen that used before
If they're not searchable, which I don't believe they are as I don't see them in the Saved Searches or the Records Browser, then I don't know of a way for you to programmatically map between Script ID and Internal ID
b
I agree
That's my dilemma 🤷‍♂️
e
ooo While
Field
is not in the Records Browser, it is in the Analytics Browser, so perhaps you could Query for them instead
I'm not sure if it's the right type of
Field
though...
b
🤔
Getting closer. I was able to get a list of all custom fields with their internal ID and script ID using your findings, but I don't see how to get standard fields.
This works in the console to get custom fields.
Copy code
require(['N/query'], query => {
  const myQuery = query.create({
    type: query.Type.CUSTOM_FIELD
  });
  
  myQuery.columns = [
    myQuery.createColumn({
      fieldId: 'internalid'
    }),
    myQuery.createColumn({
      fieldId: 'scriptid'
    })
  ];
  
  const resultSet = myQuery.run();
  console.log(resultSet.asMappedResults());
});
l
you could create an empty record by script (record.create), then get the field (rec.getField) and then field.getSelectOptions. you don't have to save it, you only need it to get the options